unit Unit11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm11 =
class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private-Deklarationen }
public
var q : integer;
{ Public-Deklarationen }
end;
var
Form11: TForm11;
implementation
{$R *.dfm}
var
HookHandle: Cardinal;
Type
tagMSLLHOOKSTRUCT =
record
POINT: TPoint;
mouseData: DWORD;
flags: DWORD;
time: DWORD;
dwExtraInfo: DWORD;
end;
TMSLLHOOKSTRUCT = tagMSLLHOOKSTRUCT;
PMSLLHOOKSTRUCT = ^TMSLLHOOKSTRUCT;
function LowLevelMouseProc(nCode: Integer; wParam: wParam; lParam: lParam): LRESULT;
stdcall;
begin
if (nCode >= 0)
then
begin
if wParam = WM_MOUSEMOVE
then
begin
inc(form11.q);
Form11.Caption := inttostr(form11.q);
end;
end;
Result := CallNextHookEx(HookHandle, nCode, wParam, lParam);
end;
function InstallMouseHook: Boolean;
begin
Result := False;
if HookHandle = 0
then
begin
HookHandle := SetWindowsHookEx(WH_MOUSE_LL, @LowLevelMouseProc, hInstance, 0);
Result := HookHandle <> 0;
end;
end;
procedure TForm11.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if HookHandle <> 0
then
UnhookWindowsHookEx(HookHandle);
end;
procedure TForm11.FormCreate(Sender: TObject);
begin
q:=0;
InstallMouseHook;
end;
end.