dcsimg
Results 1 to 6 of 6

Thread: GetAsyncKeyState vs Keyboard Layout What's the solution... or alternative?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    43

    GetAsyncKeyState vs Keyboard Layout What's the solution... or alternative?

    As I understand it, and I have quite a few hours of searching and testing, GetAsyncKeyState doesn't get the "translated" (OS-processed) keystroke input. Hence, my "" key is detected as keycode 186, which represents ";" and ":" depending on whether Shift is pressed.

    I read that to do what I want, I need to use SetWindowsHookEx instead of GetAsyncKeyState. I tried it, but without success. The A-Z letters are all capitalized and it still can't capture keys like "" and others.

    Is there a way to get the OS-processed/translated "messages" that I (or the OS if you will) send to the presently focused window?

    Please, it's driving me nuts. My experience is not that great, so I go slowly, though I usually get there. If you are knowledgeable enough, what is a matter of two or three minutes for you can be a matter of hours, if not more, to me.

    Thanks in advance.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    11,014

    Re: GetAsyncKeyState vs Keyboard Layout What's the solution... or alternative?

    I am wondering how were you able to type "" without key combination?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2012
    Posts
    43

    Re: GetAsyncKeyState vs Keyboard Layout What's the solution... or alternative?

    Quote Originally Posted by dee-u View Post
    I am wondering how were you able to type "" without key combination?
    My keyboard is Brazilian/Portuguese. It has the key "" to the right of "L"

    Quote Originally Posted by fafalone View Post
    Maybe WM_CHAR has the right code?
    Where can I start? Does it use the SetWindowsHookEx API?

  5. #5
    Fanatic Member
    Join Date
    Dec 2014
    Posts
    873

    Re: GetAsyncKeyState vs Keyboard Layout What's the solution... or alternative?

    i believe you need to look into MapVirtualKeyEx and ToUnicodeEx. check: https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,370

    Re: GetAsyncKeyState vs Keyboard Layout What's the solution... or alternative?

    WM_CHAR is received in the WndProc of a subclassed form/control. From there, if it's still not correct, you could further translate with functions in the link baka pointed out from additional information provided in the lParam.

    Also, you generally shouldn't use GetAsyncKeyState and use GetKeyState instead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width