Home > Back-end >  Delphi keyboard hook to consult
Delphi keyboard hook to consult

Time:10-12

The function KeyBHkHandle (iCode: Integer; WParam: wParam; LParam: lParam) : LRESULT; Stdcall; Export;
Const
//SfileName='c: \ logfile. TXT';
_keypressmask=$80000000;
Var
PEvt: TEventMsg;
HFocus: THandle;
SzTitle: an array of Char [0.. 255];
Stream: TextFile;
VKey: Integer;
Ch: Char;
STR: array [0.. 10] of Char;
Pt: TDateTime;
Time1: String;
ICtrl iAlt, iShift: Integer;
INumLock: Integer;
ICapital: Integer;
BAlt bCtrl, bShift bCapital, bNumlocl: Boolean;
MouPos: TPoint;
StrString: String;
SPCH: Char;



The begin


Result:=0;
If (iCode<0) then
The begin
//Result:=CallNextHookEx (hNextHookProc, iCode wParam, integer (lParam));
Result:=CallNextHookEx (hNextHookProc, iCode wParam, lParam);
exit;
end;


If iCode=HC_ACTION then
The begin
PEvt:=PEventMsg (lParam) ^;
If (pEvt. Message=WM_KEYDOWN) or (pEvt. Message=WM_SYSKEYDOWN) then
The begin
//vKey=wParam;

Myshiftchar:=';
Mypresschar:=';
Dulictrl:=';
VKey=LOBYTE (pEvt. ParamL);
If vKey=116 then mypresschar:='F5';
end;





end;
If mypresschar='F5' then begin
Form1. Memo1. Lines. The Add (mypresschar);
Mypresschar:=';
VKey:=0;
Showmessage (" OK ");//as long as add this sentence, I couldn't stop, ran to the crash
end;







end;
I want to increase press F5, here came out a message,

CodePudding user response:

Add the showmessage (" OK ");//as long as add this sentence, I couldn't stop, ran to the crash, without it, you can detect the F5 key, also won't appear ran to the crash of
.

CodePudding user response:

ShowMessage is MODEL MODEL with a custom window!
  • Related