Jump to content

PixelSearch not working properly


asym
 Share

Recommended Posts

So I wrote this script, but for some reason I have tried it over and over and tested it and made small adjustments and I can never get the second pixelsearch to work properly...

The first pixel search works pretty well on it's own but the second one doesn't just continues de script like it hasn't found anything when it has

Opt("WinTitleMatchMode",1)
Opt("MouseCoordMode",0)
Opt("MouseClickDelay",30)
WinWaitActive ( "PWO")
HotKeySet("{Esc}","Terminate")
HotKeySet("{F9}", "StartScript")
 
$script = False
 
 
While 1
While $script = True
    Sleep(10)
    MouseClick("left", 47, 478, 1)
    Sleep(30)
    MouseClick("left", 47, 478, 2)
Sleep(50)
    MouseClick("left", 47, 478, 2)
    Sleep(4000)
    $n = 0
    $pixel = PixelSearch(265, 108, 450, 156, 0xFFF200)
    If Not @error Then
        SoundPlay(@WindowsDir & "\media\hallelujah.wav", 0)
        Do
            $n = $n + 1
            MouseClick("left", 73, 448, 2)
            Sleep(500)
            MouseClick("left", 106, 559, 2)
            Sleep(500)
        Until $n = 100
    Else
        Sleep(50)
        $pixel1 = PixelSearch(666, 158, 733, 225, 0xFFF200)
        If Not @error Then
            SoundPlay(@WindowsDir & "\media\hallelujah.wav", 0)
            Do
                $n = $n + 1
                MouseClick("left", 73, 448, 2)
                Sleep(500)
                MouseClick("left", 106, 559, 2)
                Sleep(500)
            Until $n = 100
        Else
            Sleep(10)
            MouseClick("left", 277, 557, 1)
            Sleep(150)
            MouseClick("left", 277, 557, 2)
            Sleep(10)
            MouseClick("left", 277, 557, 2)
            Sleep(500)
        EndIf
    EndIf
WEnd
WEnd
 
Func StartScript()
    If $script = False Then
        $script = True
        ToolTip(" Press F9 to Stop",200,100,"V 1.1",1,2)
        Sleep(2000)
        ToolTip("")
    Else
        $script = False
        ToolTip("Press F9 to Start",200,100,"V 1.1",1,2)
        Sleep(2000)
        ToolTip("")
    EndIf
EndFunc   ;==>StartScript
Func Terminate()
    Exit
EndFunc
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...