点击鼠标进行多次像素搜索

时间:2017-06-20 18:12:04

标签: scripting automation autoit bluestacks

WinActivate("BlueStacks App Player")

While 1
    $Button1 = PixelSearch(0, 0, 1365, 767, 0x79b82c)
    MouseClick("primary", $Button1[0], $Button1[1], 1, 0)

    If(PixelSearch(0, 0, 1365, 767, 0x6e6e6e) Or PixelSearch(0, 0, 1365, 767, 0x5e5e5e)) Then
        MouseClick("primary", 748, 274, 1, 0)
    Else
        $Button2 = PixelSearch(0, 0, 1365, 767, 0xfca378)
        MouseClick("primary", $Button2[0], $Button2[1], 8, 0)
        $Button3 = PixelSearch(0, 0, 1365, 767, 0xfd64a7)
        MouseClick("primary", $Button3[0], $Button3[1], 1, 0)
    EndIf
WEnd

我正在为Bluestacks应用播放器制作自动化脚本。

我要做的是PixelSearch()查找按钮的位置,然后左键单击它,这将打开另一个新窗口。另一个PixelSearch()找到新的像素,并在一个坐标上点击8次,在另一个坐标上点击一次。

我做了无限循环,因为我希望它无限发生。问题是,只有第一个PixelSearch()MouseClick()有效;第一次单击后,该功能停止。我希望脚本在新窗口打开后继续(窗口在Bluestacks中的同一个应用程序内打开)。

1 个答案:

答案 0 :(得分:0)

试试这段代码:

WinActivate("BlueStacks App Player")

While 1
    $Button1 = PixelSearch(0, 0, 1365, 767, 0x79b82c)
    If not @error then
      MouseClick("", $Button1[0], $Button1[1], 1, 0)
      If PixelSearch(0, 0, 1365, 767, 0x6e6e6e) Or PixelSearch(0, 0, 1365, 767, 0x5e5e5e) Then
         MouseClick("", 748, 274, 1, 0)
      Else
        $Button2 = PixelSearch(0, 0, 1365, 767, 0xfca378)
        If not @error then MouseClick("", $Button2[0], $Button2[1], 8, 0)
        $Button3 = PixelSearch(0, 0, 1365, 767, 0xfd64a7)
        If not @error then MouseClick("", $Button3[0], $Button3[1], 1, 0)
      EndIf
    EndIf
 WEnd