Results 1 to 4 of 4

Thread: unable to get uni-code inputs from another thread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 :
    Qt Code:
    1. LRESULT CALLBACK keyproc(int nCode,WPARAM wparam,LPARAM lparam)
    2. {
    3. if(nCode ==HC_ACTION)
    4. {
    5. if(wparam==WM_KEYDOWN)
    6. {
    7. KBDLLHOOKSTRUCT *p=(KBDLLHOOKSTRUCT*)lparam;
    8. byte b[256];
    9. wchar_t *buff=new wchar_t[0];
    10. AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(),NULL), GetCurrentThreadId(),true);
    11. if (GetKeyboardState(b))
    12. {
    13. ToUnicode(p->vkCode,p->scanCode,b,buff,1,0);
    14. }
    15. s+=QString::fromWCharArray(buff,1);
    16. }
    17. }
    18.  
    19. return 0;
    20. }
    To copy to clipboard, switch view to plain text mode 


    any help please..........

  2. #2
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: unable to get uni-code inputs from another thread

    is there any one can help???????

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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.

  4. #4
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 .

Similar Threads

  1. Need to find a way to save user inputs.
    By "BumbleBee" in forum Newbie
    Replies: 23
    Last Post: 4th November 2011, 14:10
  2. How to implement functionalities of other devices/inputs in Qt
    By qt_user in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 9th October 2011, 10:32
  3. Replies: 6
    Last Post: 26th April 2010, 16:47
  4. Replies: 0
    Last Post: 11th November 2008, 15:36

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.