2017-06-20 74 views
-1
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次,在另一個座標上點擊1次。

我做了無限循環,因爲我想無限地發生這種情況。問題是,只有第一個PixelSearch()MouseClick()工作;在第一次點擊後,該功能停止。即使在新窗口打開後,我也希望腳本能夠繼續運行(窗口在Bluestacks中的相同應用程序中打開)。

回答

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