自动控制发送 [英] Autoit ControlSend
问题描述
只需尝试使用 ControlSend()
来模拟击键.由于某些原因,它不起作用.
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 :
标题:РokеММO,
类:LWJGL
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
推荐答案
您可以先使用WinGetHandle接收Window的句柄,然后在ControlSend函数中使用该句柄,该句柄应该起作用.看起来如下:
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}")
尝试首先显示手柄的内容以确认,您正在接收工作的手柄.类似于ConsoleWrite($handle)
或MsgBox(1, "Handle", WinGetTitle($handle))
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!
这篇关于自动控制发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!