Jump to content

Sending a Key to a minimized Window


Recommended Posts

Hey folks!

I'm searching for a way to send a Key to a minimized window.

So I thought of Posting the WM_KEYDOWN message to the handle and then after a small sleep sending WM_KEYUP

So I ended up with this code:

$hWnd = WinGetHandle("Window title")
Sleep(2000)
$ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", Asc("w"), "int", 0)
If IsArray($ret) Then
    DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc("w"), "long", _Long(1, $ret[0]))
    Sleep(500)
    DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc("w"), "long", _Long(1, $ret[0]) + 0xC0000000)
EndIf

Func _Long($LoW, $HiW)
    Return BitOR(($HiW*0x10000), BitAND($LoW, 0xFFFF))
EndFunc

Links to the functions:

MapVirtualKey: http://msdn.microsoft.com/de-de/ms646306(en-us,VS.85).aspx

PostMessage: http://msdn.microsoft.com/de-de/ms644944(en-us,VS.85).aspx

And the WM-messages I need:

#define WM_KEYDOWN 256
#define WM_KEYUP 257

(Taken form winuser.h)

Hope anyone can help and tell me an other way or my mistake

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...