1

我正在尝试找到一种方法来制作一个简单的机器人,该机器人可以在最小化窗口中单击 4 个位置,而不必专注于它。这是我到目前为止得到的:

#include <Misc.au3>


Local $hDLL = DllOpen("user32.dll")


While 1
ControlClick ( "Eclipse Flyff", "", "" ,"left" , 1 , 724 , 1067 )
ControlClick ( "Eclipse Flyff", "", "" ,"left" , 1 , 757 , 1067 )
ControlClick ( "Eclipse Flyff", "", "" ,"left" , 1 , 791 , 1067 )
ControlClick ( "Eclipse Flyff", "", "" ,"left" , 1 , 1516 , 1010 )
    If _IsPressed("10", $hDLL) Then
        ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF)
        ; Wait until key is released.
        While _IsPressed("10", $hDLL)
             Sleep(250)
        WEnd
         ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF)
    ElseIf _IsPressed("1B", $hDLL) Then
        MsgBox(0, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.")
        ExitLoop
    EndIf
    Sleep(250)
WEnd


DllClose($hDLL)

我的问题是它没有做任何事情,我认为它可能会被游戏阻止,但我不确定这在 AutoIt 中是否仍然可行,或者我要求太多,因为这是我第一次使用它。

人们告诉我使用 C#,但我不知道它如何与 post message 一起使用,所以我真的有一个小困境,因为我不想放弃我开始的东西。

4

1 回答 1

0

这是一个如何将击键发送到最小化控件的工作示例。您需要先找出 ControlID,然后即使在最小化时也要在发送一些键之前设置其焦点。

Run("notepad")
$np = WinWaitActive("[CLASS:Notepad]")
ControlSend($np, Default, "", "Active" & @CR)
$control = ControlGetFocus($np)
WinSetState($np, Default, @SW_MINIMIZE)

ControlFocus($np, Default, $control)
ControlSend($np, Default, $control, "Minimized" & @CR)
于 2013-04-17T08:55:22.297 回答