能不能用hook接键盘点击,修改键盘输入 类似h5软键盘把布局顶上去c++

他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)| Copyright &
. All Rights Reserved .网站已改版,请使用新地址访问:
mousehook WINCE5.0 下键盘鼠标钩子源码
注: 6下貌似不能用 Windows CE 277万源代码下载- www.pudn.com
网站已改版,请使用新地址访问:
&文件名称: mousehook
& & & & &&]
&&所属分类:
&&开发工具: Visual C++
&&文件大小: 32 KB
&&上传时间:
&&下载次数: 64
&&提 供 者:
&详细说明:WINCE5.0 下键盘鼠标钩子源码
注:WINCE6下貌似不能用-wince5.0 keyboard hook
文件列表(日期:~)(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&&&&&mousehook.vcproj&&
&相关搜索:
&输入关键字,在本站277万海量源码库中尽情搜索:
&[] - winCE5.0下软键盘LARGEKB源代码
&[] - EVC下异步读取串口 采用事件触发读取和写入线程
&[] - C#实现键盘 鼠标 钩子
&[] - CC2430 基础实验十二 AVDD实验
&[] - 用java实现的一个简易的网页浏览器,该浏览器实现了网页访问、保存,以及操作的前进、后退等功能。是java学习者的理想资料。
&[] - Microsoft程序设计系列丛书:Programming Microsoft windows CE程序设计
第一部分 Windows编程基础
第一章 Hello WindowsCE第二单
第二章 屏幕绘图
第三章 输入:键盘\输入笔和菜单
第四章 窗口控件和对话框
第二部分 Windo
&[] - wince下的按键钩子示例,里面有一些函数很有帮助!
&[] - 如何在wince下使用键盘hook,因为wince不支持SetWindowsHookEx函数
&[] - 键盘钩子发音程序,当按一个键时,可以读出所铵的是什么键!
&[] - wince 的 消息钩子
有键盘钩子和鼠标钩子
鼠标钩子注意不能断点回调函数
可以同时使用键盘和鼠标钩子
用完记得卸载钩子否则会一直被拦截
有强行卸载钩子的办法请QQwindows - ToAscii/ToUnicode in a keyboard hook destroys dead keys - Stack Overflow
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
It seems that if you call ToAscii() or ToUnicode() while in a global WH_KEYBOARD_LL hook, and a dead-key is pressed, it will be 'destroyed'.
For example, say you've configured your input language in Windows as Spanish, and you want to type an accented letter á in a program. Normally, you'd press the single-quote key (the dead key), then the letter "a", and then on the screen an accented á would be displayed, as expected.
But this doesn't work if you call ToAscii() or ToUnicode() in a low-level keyboard hook function. It seems that the dead key is destroyed, and so no accented letter á shows up on screen. Removing a call to the above functions resolves the issue... but unfortunately, I need to be able to call those functions.
I Googled for a while, and while a lot of people seemed to have this issue, no good solution was provided.
Any help would be much appreciated!
EDIT: I'm calling ToAscii() to convert the virtual-key code and scan code received in my
hook function into the resulting character that will be displayed on screen for the user.
I tried MapVirtualKey(kbHookData->vkCode, 2), but this isn't as "complete" a function as ToAscii(); for example, if you press Shift + 2, you'll get '2', not '@' (or whatever Shift + 2 will produce for the user's keyboard layout/language).
ToAscii() is perfect... until a dead-key is pressed.
EDIT2: Here's the hook function, with irrelevant info removed:
LRESULT CALLBACK keyboard_LL_hook_func(int code, WPARAM wParam, LPARAM lParam) {
LPKBDLLHOOKSTRUCT kbHookData = (LPKBDLLHOOKSTRUCT)lP
BYTE keyboard_state[256];
if (code & 0) {
return CallNextHookEx(keyHook, code, wParam, lParam);
WORD wCharacter = 0;
GetKeyboardState(&keyboard_state);
int ta = ToAscii((UINT)kbHookData-&vkCode, kbHookData-&scanCode,
keyboard_state, &wCharacter, 0);
/* If ta == -1, a dead-key was pressed. The dead-key will be "destroyed"
* and you'll no longer be able to create any accented characters. Remove
* the call to ToAscii() above, and you can then create accented characters. */
return CallNextHookEx(keyHook, code, wParam, lParam);
stop using ToAscii() and use ToUncode()
remember that ToUnicode may return you nothing on dead keys - this is why they are called dead keys.
Any key will have a scancode or a virtual key code but not necessary a character.
You shouldn't combine the buttons with characters - assuming that any key/button has a text representation (Unicode) is wrong.
for input text use the characters reported by Windows
for checking button pressed (ex. games) use scancodes or virtual keys (probably virtual keys are better).
for keyboard shortcuts use virtual key codes.
65.2k99330518
Call 'ToAscii' function twice for a correct processing of dead-key, like in:
int ta = ToAscii((UINT)kbHookData-&vkCode, kbHookData-&scanCode,
keyboard_state, &wCharacter, 0);
int ta = ToAscii((UINT)kbHookData-&vkCode, kbHookData-&scanCode,
keyboard_state, &wCharacter, 0);
If (ta == -1)
Calling the ToAscii or ToUnicode twice is the answer.
I found this and converted it for Delphi, and it works!
cnt:=ToUnicode(VirtualKey, KeyStroke, KeyState, chars, 2, 0);
cnt:=ToUnicode(VirtualKey, KeyStroke, KeyState, chars, 2, 0); //yes call it twice
44.8k1184123
Quite an old thread. Unfortunately it didn't contain the answer I was looking for and none of the answers seemed to work properly. I finally solved the problem by checking the
of the MapVirtualKey function, before calling ToUnicode / ToAscii. Seems to be working like a charm:
if(!(MapVirtualKey(kbHookData-&vkCode, MAPVK_VK_TO_CHAR)&&(sizeof(UINT)*8-1) & 1)) {
ToAscii((UINT)kbHookData-&vkCode, kbHookData-&scanCode,
keyboard_state, &wCharacter, 0);
Quoting MSDN on the return value of MapVirtualKey, if
MAPVK_VK_TO_CHAR is used:
[...] Dead keys (diacritics) are indicated by setting the top bit of the return value. [...]
I copy the vkCode in a queue and do the conversion from another thread
def keyHookKFunc(code,wParam,lParam):
global gkeyQueue
gkeyQueue.append((code,wParam,kbd.vkCode))
return windll.user32.CallNextHookEx(0,code,wParam,lParam)
This has the advantage of not delaying key processing by the os
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Upcoming Events
ends Mar 27
Stack Overflow works best with JavaScript enabled

我要回帖

更多关于 h5软键盘把布局顶上去 的文章

 

随机推荐