Skip to content

Commit

Permalink
Updated to allow processing by Hook chain
Browse files Browse the repository at this point in the history
  • Loading branch information
fschetterer committed Oct 16, 2019
1 parent e95ee3a commit 512b93c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions HooksMadeEasy.GetMsg.pas
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ class function TGetMsgHook.GetMsgProc(iCode: integer; wParam: WPARAM; lParam: LP
begin
Result := 0;
// Return chained call results if Code is less than Zero
if (iCode < 0) then Exit(CallNextHookEx(0, iCode, wParam, lParam));
if not m_HookData.Active or (iCode <> HC_ACTION) then Exit;
if (iCode < 0) then Exit(CallNextHookEx(0, iCode, wParam, lParam))
// Else allow processing by Hook chain
else CallNextHookEx(0, iCode, wParam, lParam);

if not m_HookData.Active or (iCode <> HC_ACTION) then Exit;
if (lpMsg.Message = WM_SYSCOMMAND) then begin
/// <remarks WM_SYSCOMMAND>
/// The four low-order bits of the wParam parameter are used internally by the system.
Expand Down
12 changes: 7 additions & 5 deletions HooksMadeEasy.Keyboard.pas
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,18 @@ implementation
end;

class function TKeyboardHook.KeyboardProc(iCode: integer; VKCode: WPARAM; lParam: LPARAM): LRESULT;
var lpKey : TKeyMsgRec absolute lParam;
var KeyMsg : TKeyMsgRec absolute lParam;
begin
Result := 0;
// Return chained call results if Code is less than Zero
if (iCode < 0) then Exit(CallNextHookEx(0, iCode, VKCode, lParam));
if not m_HookData.Active or (iCode <> HC_ACTION) then Exit;
if (iCode < 0) then Exit(CallNextHookEx(0, iCode, VKCode, lParam))
// Else allow processing by Hook chain
else CallNextHookEx(0, iCode, VKCode, lParam);

if (VKCode = VK_NUMPAD1) and (kbALTDWN in lpKey.KeyFlagBits)
if not m_HookData.Active or (iCode <> HC_ACTION) then Exit;
if (VKCode = VK_NUMPAD1) and (kbALTDWN in KeyMsg.KeyFlagBits)
then begin
if PostMessage(m_HookData.FHwnd, APP_HOOKMSG, Ord(kbPrevKeyState in lpKey.KeyFlagBits), Ord(kbTransitionState in lpKey.KeyFlagBits)) then
if PostMessage(m_HookData.FHwnd, APP_HOOKMSG, Ord(kbPrevKeyState in KeyMsg.KeyFlagBits), Ord(kbTransitionState in KeyMsg.KeyFlagBits)) then
MessageBeep(0);
end;
end;
Expand Down

0 comments on commit 512b93c

Please sign in to comment.