问题
Just trying to simulate keystrokes with ControlSend(). For some reason it doesn't work.
While 1
ControlSend("PokeMMO", "", "", "{DOWN}")
Sleep(900)
ControlSend("PokeMMO", "", "", "{DOWN}")
Sleep(900)
ControlSend("PokeMMO", "", "", "{DOWN}")
Sleep(900)
ControlSend("PokeMMO", "", "", "a")
Sleep(Random(750, 2000, 1))
ControlSend("PokeMMO", "", "", "a")
Sleep(Random(750, 2000, 1))
ControlSend("PokeMMO", "", "", "a")
Sleep(Random(750, 2000, 1))
ControlSend("PokeMMO", "", "", "a")
Sleep(3000)
WEnd
Au3Info:
Title: РokеММO,
Class: LWJGL
Global $sProcess = "javaw.exe" ;PokeMMO Process
ControlSend(_Process2Win($sProcess), "", "", "{DOWN}")
Func _Process2Win($pid)
If IsString($pid) Then $pid = ProcessExists($pid)
If $pid = 0 Then Return -1
$list = WinList()
For $i = 1 To $list[0][0]
If $list[$i][0] <> "" And BitAND(WinGetState($list[$i][1]), 2) Then
$wpid = WinGetProcess($list[$i][0])
If $wpid = $pid Then Return $list[$i][0]
EndIf
Next
Return -1
EndFunc ;==>_Process2Win
回答1:
You can use WinGetHandle first to recieve a handle to the Window and then use this handle in the ControlSend function, which should work. It looks like the following:
$handle = WinGetHandle("[TITLE:PokeMMO; CLASS:LWJGL]")
ControlSend($handle, Default, $handle, "{Down}")
Try to display the content of handle first to confirm, you're recieving a working handle. Like ConsoleWrite($handle)
or MsgBox(1, "Handle", WinGetTitle($handle))
Go, give it a try ;-)
And good luck!
回答2:
Since I see "MMO" and "a" I can assume you are trying to send it to a Video-Game window maybe?
There are few things you can do : download a window game controller such as IsBoxer, you'll be able to remotly send keystrokes to a remote account easily. Most of MMO blocks .dll that make sending keystrokes possible.
Vlu
来源:https://stackoverflow.com/questions/14783920/autoit-controlsend