function GetInfo(count: Integer; Wp:WPARAM; Lp: LPARAM):LRESULT;stdcall;
var
info: String;
Debugfile: TExtFile;
i: Integer;begin
if count<0 then
begin
CallNextHookEx(MyMessageInfo.Hook,count,Wp,Lp);
Exit;
end;
AssignFile(Debugfile,afile);
Append(Debugfile);
i := getkeystate(vk_return);
if getkeystate(vk_return)<0 then
begin
writeln(debugfile,'');
write(debugfile,char(wp));
end //
else
write(debugfile,char(wp));
outputDebugString(PChar(IntToStr(i)));
closefile(debugfile);
result:=0;
end;这段程序有什么问题?为什么每次捕捉到的按键都要写两遍,如我按“i",在debug.txt中就有“ii”,
刚接触钩子,请指教!!!
var
info: String;
Debugfile: TExtFile;
i: Integer;begin
if count<0 then
begin
CallNextHookEx(MyMessageInfo.Hook,count,Wp,Lp);
Exit;
end;
AssignFile(Debugfile,afile);
Append(Debugfile);
i := getkeystate(vk_return);
if getkeystate(vk_return)<0 then
begin
writeln(debugfile,'');
write(debugfile,char(wp));
end //
else
write(debugfile,char(wp));
outputDebugString(PChar(IntToStr(i)));
closefile(debugfile);
result:=0;
end;这段程序有什么问题?为什么每次捕捉到的按键都要写两遍,如我按“i",在debug.txt中就有“ii”,
刚接触钩子,请指教!!!
解决方案 »
- 是不是做毕业设计的都来CSDN问问题了
- 在oracle查询分析器运行正常,在delphi中执行却抛异常?
- 模式在delphi下的可用性
- 数据库服务器中数据库数据表名称的查询问题。请教高手。谢谢
- 哪位用过DBISAM,哪里有它的管理工具下载。。。最好是免费的。。。谢谢
- dll里如何访问数据库?
- ADOQuery中两条SQL语句是否能一起执行(ExecSQL)?
- 知道vxd的看进来
- Excel中的自动提示以前输入的字符功能是如何实现的?内详>>>
- 求助!用的Timage做的按钮 碰到的一个问题..
- 怎样得到本地打印机\网络打印机的打印消息?(N多分相送)
- 高分求代码,oracle数据库的导入导出问题,谢谢了
begin
writeln(debugfile,'');
write(debugfile,char(wp));//写一次
end
else//弹起时,
write(debugfile,char(wp));//写第二次
outputDebugString(PChar(IntToStr(i)));
closefile(debugfile);
result:=0;
end;
所以就出现了两个i
if getkeystate(vk_return)<0 then//
begin
writeln(debugfile,'');
write(debugfile,char(wp));//
end
else//弹起时,
outputDebugString(PChar(IntToStr(i)));
closefile(debugfile);
result:=0;
end;
我调试过这个程序,vk_return是‘Enter’的值,只要我不按回车,这个值是不变的,要不一直是1,要不就是0。
我也觉得是把up和down都执行了,但不知这麽作才能只记录一次按键的值!!!谢谢了·
你既然都扑捉到了所有键盘操作。。干吗还需要getkeystate直接用 WM_KEYDOWN 消息不就OK??
你先开辟缓冲区 保存用户的Key in 然后当key为ENter时 一次性将整个缓冲区全部写入到文件 岂不更好??
加入
KeyPressMask=$80000000;
(lParam and _KeyPressMask) = 0
只有在按下时执行