c++ - Windows Unicode keyboard hook -


i'm developing application in point needs capture keyboard , mouse user input. had no problems installing , using mouse hook, keyboard not working properly. need capture wide characters multiple keyboard layouts. found relevant did not solve problem: https://stackoverflow.com/questions/15976108/keyboard-hook-not-capturing-unicode-in-other-threads

that's have without not necessary stuff

winmain:

//set hook, threadid = 0 hhook = setwindowshookex(wh_keyboard_ll, keyboardproc, hinstance, 0);  hkl keyboardlayout = getkeyboardlayout(0); //all window , message queue code 

keyboardproc:

wchar unicodechar; byte keyboardlayout[256]; kbdllhookstruct* keyparam = (kbdllhookstruct*) lparam;  if(code < 0)     return callnexthookex(hhook, code, wparam, lparam);  if(wparam == wm_keydown) {     getkeyboardstate(keyboardstate);      int translation = tounicodeex(keyparam->vkcode, keyparam->scancode, keyboardstate, &unicodechar, 1, 0, keyboardlayout);     translation = tounicodeex(keyparam->vkcode, keyparam->scancode, keyboardstate, &unicodechar, 1, 0, keyboardlayout);      if(translation == 0 )//|| translation == -1)         return 0;      pushtobuffer(&unicodechar); }  //return callnexthookex(hhook, code, wparam, lparam); return 0; 

i left commented code show i've tried based on post mentioned , msdn documentation. push buffer receives wchar_t pointer , stores in wstring used buffer, dumps in wofstream.

what happens:

if call tounicodeex once, user input modified , dead-key shown twice him: example, in international english layout, press ' print รก, shows: ''a. application closed user input goes normal.

if call tounicodeex twice, dead-key consumed , char shown.

i wonder why user input being modified, since not change of parameters given callback caller. unicode not possible low-level hooks?

tounicodeex broken when comes dead keys. looking for: https://code.google.com/p/jnativehook/source/browse/tags/1.1.4/src/native/windows/winunicodehelper.c


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -