简单的自动点击器无焦点

时间:2013-04-16 21:31:29

标签: autoit sendkeys minimized

我正试图找到一种方法来制作一个简单的机器人,在最小化的窗口中点击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#,但我不知道如何使用帖子消息,所以我真的有一个小困境,因为我不想放弃我的开始。

1 个答案:

答案 0 :(得分: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)
相关问题