Problem with an API call

  • Thread starter Thread starter Interops
  • Start date Start date
I

Interops

Hi,

I am trying to send keys to inactive window of an application.

I use the PostMessage API Call. (http://msdn.microsoft.com/en-us/
library/ms644944(VS.85).aspx)

The key I want to send is the Down Arrow key.

To send i I have to call the PostMessage function with the WM_KEYDOWN
ad WM_KEYUP notifications as parameters to the function

Private Const WM_KEYDOWN As Integer = &H100
Private Const WM_KEYUP As Integer = &H101
Private Const VK_DOWN As Integer = &H28 'Down Arrow
PostMessage(whnd, WM_KEYDOWN, VK_DOWN, lParam)
PostMessage(whnd, WM_KEYUP, VK_DOWN, lParam)

for lParam, I have to use some mumbo-jumbo that I do not understad at
all. I am a weekend programmer wth no math skills at all :)
ref: (http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx)
and (http://msdn.microsoft.com/en-us/library/ms646281(VS.85).aspx)

So far I have found that the keyboard scancode for the Down arrow key
is 0x50

Also I read that I might have to use the following function:
Shared Function MakeLParam(ByVal LoWord As Integer, ByVal HiWord As
Integer) As IntPtr
Return (HiWord << 16) Or (LoWord And &HFFFF)
End Function

The strangest part is that if found a working code, but fo the left
arrow key:
Private Const WM_KEYDOWN As Integer = &H100
Private Const WM_KEYUP As Integer = &H101
Private Const VK_DOWN As Integer = &H25 'Left Arrow
PostMessage(whnd, WM_KEYDOWN, VK_LEFT, &H2F0001)
PostMessage(whnd, WM_KEYUP, VK_LEFT, &H2F0001)

I have no idea where the guy took &H2F0001(3080193) from.

If anyone can help me with this, I will be one very very happy
panda :)

TIA
 
Check here:
 http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx
2F0001 in the context you cite is a scan code (2F) and a repeat count (1)..

Hi,

Thanks for the reply.

So how do I construct the lParam for the Down arrow key.
Btw, the scan code for the Left arrow is 4B, not 2F, at least that is
what I've found in Internet.

If repeat count is 1, then the whole lParam thing is reverse, as the
repeat count is at bits 0-15, according to MSDN, and then follows the
scan code.
I am wrong?
 
Back
Top