WM_KEYDOWN: how to use it?

I am trying to send a key stroke to one application through PostMessage. I use too much Spy ++ to try to figure out how to send a message, since I do not fully understand its inner workings.

alt text

In this picture, the first element (selected element) was made with the actual keystroke made by me. One with a red ellipse around it (bottom) was made with the following code:

WinApi.PostMessage(InsideLobbyHandle, WinApi.WM_KEYDOWN, (int)WinApi.VK_UP, 1);

I suppose this should have something to do with the last PostMessage () parameter, but I can't figure out how this works. I can see in the original key stroke ScanCode = 48, and in mine - 0, and fExtended - 1, and in mine - 0. How can I make it look the same?

At http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx I cannot figure out how the last parameter works.

+2
source share
3 answers

Simulate keyboard input using SendInput , not PostMessage.

You cannot simulate keyboard input using PostMessage .

There are some more warnings regarding keyboard state / async state:

SendInput reset . , - , , . , GetAsyncKeyState .


lParam WM_KEYDOWN :

  • 16 -
  • 8 -
  • 1 , 0
  • 4 0
  • 0 ( WM_KEYDOWN)
  • -
  • 0 ( WM_KEYDOWN)

: , PostMessage, .

+13

In Spy ++, if you right-click on the selected record (registered message) and view its properties, you can see the exact value of lParam. You can then use this as your lParam to ensure that PostMessage produces the same effects as it did manually.

0
source

All Articles