无窗口程序如何响应键盘?xp下 我编写了个无窗口程序,但无法响应键盘.在程序中直接用键盘钩子,无法拦到键盘按下用dll钩子因无窗口程序无HWND,无法通讯,而且不希望用dll用int中断,系统说我没有这个权限怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 天,消息需要什么东西为载体,就是窗体啊,如果你没有窗体,系统要将消息发送给谁。你应该了解了一下Windows编程的基本原理。 program JimPoint;uses Windows, Messages, HookKeyBoard;{$R *.res}var KBH : TSystemKeyBoard; KeyS : String;//对拦截到的键处理procedure RecKeyBoard(Sender: TObject; var Key: Word; Shift: TShiftState);begin if CheckKey then KeyS := KeyS + Chr(Key);end;begin KBH := TSystemKeyBoard.Create; KBH.OnKeyDown := @RecKeyBoard; KBH.Open; while GetMessage(aMessage,0,0,0) do begin TranslateMessage(amessage); DispatchMessage(aMessage); end; KBH.Close; KBH.Free; Halt(aMessage.wParam);end.//HookKeyBoard单元,去http://blog.csdn.net/kiboisme/找 if CheckKey then//这个函数可以不要,就是用来判断是否需要保存的。 那你要响应系统发送给其他程序的键盘鼠标当然可以,用日志钩子。这里看看:http://blog.csdn.net/linzhengqun to 各位高人{$R *.res}varfunction HookProc(nCode:Integer;wParam:wParam;lParam:lParam) : LRESULT ; stdcall;begin//经测试键盘按下后没有经过这里(下断点,textout等方法)为什么????/end;beginHookID := SetWindowsHookEx(WH_JOURNALRECORD, HookProc ,HInstance,0);HOOKID可以获取……//循环 UnHookWindowsHookEx(HookID); end. 仔细地看这两篇文章:http://blog.csdn.net/linzhengqun/archive/2005/10/06/496074.aspxhttp://blog.csdn.net/linzhengqun/archive/2005/10/06/496076.aspx 不就是一个SetWindowHookEx和一个钩子处理过程吗,都是调用Windows的API,不可能会增加多少体积的,你为什么不试试再说呢。 请问delphi7的问题,智能提示,变色 Delphie 如何写Cookie 读取INI文件问题 DELPHI 7下IDFTP编的FTP程序,在WIN7下用不了,如何解决? 请教关于FastReport中字段显示的问题/? 求助:实现这种功能用什么组件? 打印纸张问题? 初学者问题,关于Query查询语句问题 各位高手,SendText限制的发送字符数是多少啊?如何传送长字符串? 怎么让FORM响应键盘事件? 我想请问一下怎么在delphi里面查入事务 一个简单的问题,请教各位大侠
Windows,
Messages,
HookKeyBoard;{$R *.res}var
KBH : TSystemKeyBoard;
KeyS : String;//对拦截到的键处理
procedure RecKeyBoard(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if CheckKey then
KeyS := KeyS + Chr(Key);
end;begin
KBH := TSystemKeyBoard.Create;
KBH.OnKeyDown := @RecKeyBoard;
KBH.Open;
while GetMessage(aMessage,0,0,0) do begin
TranslateMessage(amessage);
DispatchMessage(aMessage);
end;
KBH.Close;
KBH.Free;
Halt(aMessage.wParam);
end.
//HookKeyBoard单元,去http://blog.csdn.net/kiboisme/找
这里看看:http://blog.csdn.net/linzhengqun
{$R *.res}
var
function HookProc(nCode:Integer;wParam:wParam;lParam:lParam) : LRESULT ; stdcall;
begin//经测试键盘按下后没有经过这里(下断点,textout等方法)为什么????/
end;
begin
HookID := SetWindowsHookEx(WH_JOURNALRECORD, HookProc ,HInstance,0);
HOOKID可以获取
……//循环
UnHookWindowsHookEx(HookID);
end.
http://blog.csdn.net/linzhengqun/archive/2005/10/06/496074.aspx
http://blog.csdn.net/linzhengqun/archive/2005/10/06/496076.aspx
你为什么不试试再说呢。