3485
- 收藏
- 点赞
- 分享
- 举报
Windows CE下的键盘钩子
在coredll.dll中有SetWindowsHookEX相关函数,这里用LoadLibrary和GetProcAddress可以调用。
以下是测试代码:
[hide]//Install the KB hook by passing the
//handle of the application to be hooked
//and the address of the KB procedure
//which will handle all the KB events
if(!ActivateKBHook(hInstance, LLKeyboardHookCallbackFunction))
{
MessageBox(GetActiveWindow(),
TEXT("Couldn't intall hook...Terminating"),
TEXT("Warning"), NULL);
exit(1);
}
//LLKeyboardHookCallbackFunction is the funtion whose
//address we passed to the system while installing the hook.
//so all the KB events will bring the control to this procedure.
//Here we want that when the user presse left or
//right key it should be interpreted as an UP key
//so now you can allow the user to configure the
//key boards the way he/she wants it
LRESULT CALLBACK LLKeyboardHookCallbackFunction(
int nCode, WPARAM wParam, LPARAM lParam)
{
if(((((KBDLLHOOKSTRUCT*)lParam)->vkCode) == VK_LEFT) ||
((((KBDLLHOOKSTRUCT*)lParam)->vkCode) == VK_RIGHT))
{
//Generate the keyboard press event of the mapped key
keybd_event(VK_UP, 0, 0, 0);
//release the mapped key
keybd_event(VK_UP, 0, KEYEVENTF_KEYUP, 0);
}
//let default processing take place
return CallNextHookEx(g_hInstalledLLKBDhook, nCode,
wParam, lParam);
}
//we are done with the hook. now uninstall it.
DeactivateKBHook();
Windows CE下的键盘钩子程序的应用这里有个例程...[/hide]
[ 本帖最后由 crystal 于 2008-8-18 22:22 编辑 ]
以下是测试代码:
[hide]//Install the KB hook by passing the
//handle of the application to be hooked
//and the address of the KB procedure
//which will handle all the KB events
if(!ActivateKBHook(hInstance, LLKeyboardHookCallbackFunction))
{
MessageBox(GetActiveWindow(),
TEXT("Couldn't intall hook...Terminating"),
TEXT("Warning"), NULL);
exit(1);
}
//LLKeyboardHookCallbackFunction is the funtion whose
//address we passed to the system while installing the hook.
//so all the KB events will bring the control to this procedure.
//Here we want that when the user presse left or
//right key it should be interpreted as an UP key
//so now you can allow the user to configure the
//key boards the way he/she wants it
LRESULT CALLBACK LLKeyboardHookCallbackFunction(
int nCode, WPARAM wParam, LPARAM lParam)
{
if(((((KBDLLHOOKSTRUCT*)lParam)->vkCode) == VK_LEFT) ||
((((KBDLLHOOKSTRUCT*)lParam)->vkCode) == VK_RIGHT))
{
//Generate the keyboard press event of the mapped key
keybd_event(VK_UP, 0, 0, 0);
//release the mapped key
keybd_event(VK_UP, 0, KEYEVENTF_KEYUP, 0);
}
//let default processing take place
return CallNextHookEx(g_hInstalledLLKBDhook, nCode,
wParam, lParam);
}
//we are done with the hook. now uninstall it.
DeactivateKBHook();
Windows CE下的键盘钩子程序的应用这里有个例程...[/hide]
[ 本帖最后由 crystal 于 2008-8-18 22:22 编辑 ]

下载
我来回答
回答0个
时间排序
认可量排序

或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片
相关问答
-
2008-05-27 11:09:53
-
2008-07-18 20:42:04
-
2010-06-01 23:25:04
-
2008-07-24 01:33:17
-
2012-12-05 14:39:10
-
2012-12-05 11:13:14
-
2012-12-05 14:32:53
-
2012-12-05 11:12:01
-
2012-12-05 13:33:42
-
2012-12-05 14:27:39
-
2010-06-01 23:29:28
-
2012-12-05 11:07:55
-
2008-11-02 17:14:58
-
2012-12-05 13:34:26
-
2012-12-04 14:09:01
-
2012-12-05 13:38:25
-
2012-12-04 14:17:38
-
2012-12-04 13:36:34
-
2012-12-05 14:19:35
无更多相似问答 去提问

点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认