Autoit ControlSend

半世苍凉 提交于 2019-12-12 04:59:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!