📄 gmousehook.dpr
字号:
library GMousehook;
uses
SysUtils,
Classes,
WinTypes,
WinProcs,
Messages;
var
{holds various global values}
IsHooked: Boolean;
HookHandle: HHook;
DesktopWin: HWND;
{this is the procedure called every time a mouse message is processed}
function HookProc(Code: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
{if the user clicked the left mouse button, output a sound}
if (wParam = WM_LBUTTONDOWN) then
MessageBeep(MB_ICONASTERISK);
{call the next hook in the chain. note that leaving this out would
effectively remove this message}
Result := CallNextHookEx(HookHandle, Code, wParam, lParam);
end;
function SetHook: Boolean; stdcall;
begin
Result := FALSE;
{make sure the hook is not already set}
if IsHooked then
Exit;
{get a handle to the desktop window}
DesktopWin := GetDesktopWindow;
{set this hook as a system level hook}
HookHandle := SetWindowsHookEx(WH_MOUSE, HookProc, HInstance, 0);
{indicate if the hook was set right}
Result := HookHandle <> 0;
end;
function RemoveHook: Boolean; stdcall;
begin
Result := FALSE;
{remove the hook}
if (not IsHooked) and (HookHandle <> 0) then
Result := UnhookWindowsHookEx(HookHandle);
{reset the global variable}
IsHooked := FALSE;
end;
exports
SetHook name 'SetHook',
RemoveHook name 'RemoveHook',
HookProc name 'HookProc';
begin
IsHooked := FALSE;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -