Jump to content

Recommended Posts

Posted

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]

Posted (edited)

@grungeRocker

_SendMessage function with $VM_CHAR for hexadecimal keys like _IsPressed

Look at #Include <SendMessage.au3>

Cheers, FireFox.

Edited by FireFox
Posted

I'm sorry, but I just can't find that include...

And maybe I should mention, that I need it for moving in a game, so it is necessary, sending WM_KEYDOWN and WM_KEYUP

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

Posted

did this?

ControlSend("title","","","<keystroke here>")

Or...

$hwnd = WinGetHandle("title")

ControlSend("title","",$hwnd,"<keystroke here>")

just curious what your attempts have been...

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Posted

i have the same problem until I created a topic sends number 1 but the magic does not function and when I open chat I see I number it 1 being typed

I don't get your post oO

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

Posted

Alot of games have various protection against things like this.

Not to discourage you, but out of experience I can tell you your probably S.O.L.

Posted

Hm... This game is not protected against memory writing...

So you can easily Teleport and fly....

But it should be protected against messages, sent by an other program?

Man there must be a way to do it :)

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

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
×
×
  • Create New...