Sending Key Combinations to an Application

Arokh

Well-known member
Joined
Apr 11, 2006
Messages
124
After much trail and error I was finally be able to send some keys to a different application with the Postmessage API.

But now I want to send key combinations but I dont kno how to do it and Im out of ideas too.

So here are my attempts:

Code:
    Structure Button
        Dim Part() As String
        Dim Desc As String
        Dim Pushed As Int16
    End Structure
...
        Dim mymsg As New MSG
...
mymsg.hwnd = MPChWnd
mymsg.message = WM_KEYDOWN
mymsg.lParam = 0  Tried 15 as well
mymsg.wParam = Keys.Control
TranslateMessage(mymsg)

mymsg.wParam = Keys.Right
TranslateMessage(mymsg)

mymsg.message = WM_KEYUP

mymsg.wParam = Keys.Right
TranslateMessage(mymsg)

mymsg.wParam = Keys.Control
TranslateMessage(mymsg)
Code:
PostMessage(MPChWnd, WM_KEYDOWN, Keys.Control, 0)
PostMessage(MPChWnd, WM_KEYDOWN, Keys.Right, 0)
PostMessage(MPChWnd, WM_KEYUP, Keys.Right, 0)
PostMessage(MPChWnd, WM_KEYUP, Keys.Control, 0)

Im trying to simulate a short cut in a Video Player which lets the video jump forward while pressed (CTRL+Right Arrow),
while pressing only the Arrow would only forward the video by one frame.

Using TranslateMessage doesnt work at all,
Postmessage send the keys not as a combination and forwards the video frame by frame.
Sendmessage doest do the job at all, since it just cycles the buttons on the control panel.
 
mhh sorry for posting in the wrong category :rolleyes:

I found a solution which is much better.
Instead of sending the combination I found the message that is send when
the combination is pressed and now I can directly send the forward/backward command.

I just discovered another usefull side of Spy++ instead of just finding the windows handles :D,
I didnt know it could also show the messages for a specific handle,
thanks for the great insight! (Which I got while searching the forum :) )

[EDIT]
Thanks PlausiblyDamp
I will also have a look at the link.
( I was writing this post while you already posted the link :) )
 
Back
Top