Jump to content

If pixel isn't found Then do -blahblahblah-


Lambort
 Share

Recommended Posts

HotKeySet("{F2}", "start")
HotKeySet("{ESC}", "exitt")


While 1
    Sleep(100)
WEnd
    
    
    
    

Func Start()
    WinActivate("")
    sleep(2000)
    Send("1")
    sleep(1000)
    While 1
        
        
        
        
$coord = PixelSearch( 300, 0, 1024, 700, 0xffffff, 7 )
If Not @error Then
    MouseClick("right", $coord[0], $coord[1], 1)
    Sleep(3000)
    MouseClick("left", 54, 257)
    Sleep(2000)
    Send("{e down}")
    Sleep(1000)
    Send("{e up}")
    Sleep(1000)
    Send("1")                           ;right
EndIf
If @error = 1 Then
    Send("1")
    MouseClick("right", $coord[0], $coord[1], 1)
    Sleep(3000)
    MouseClick("left", 54, 257)
    Sleep(2000)
    Send("{e down}")
    Sleep(1000)
    Send("{e up}")
    Sleep(1000)
    Send("1")                           ;right
EndIf
        
    WEnd
EndFunc

Func exitt()
    Exit
EndFunc

I get the error: "Subscript used with non-Array variable"

All I want to do is get it to where:

If it doesn't find the pixel color "0xffffff, 7" after searching for 30 seconds Then:

Send("1")
    MouseClick("right", $coord[0], $coord[1], 1)
    Sleep(3000)
    MouseClick("left", 54, 257)
    Sleep(2000)
    Send("{e down}")
    Sleep(1000)
    Send("{e up}")
    Sleep(1000)
    Send("1")

;)

Edited by Lambort
Link to comment
Share on other sites

  • Developers

EndIf
If @error = 1 ThenoÝ÷ Ø(Z­¡«­¢+Ù±Í

Its better to test for @error rigth after the function since it reports the success or failure of the Last executed function

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

If pixel is not found then you would not have co-ordinates to use in MouseClick, hence the error.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

maybe...

HotKeySet("{F2}", "start")
HotKeySet("{ESC}", "exitt")

While 1
    Sleep(100)
WEnd

Func Start()
    WinActivate("")
    Sleep(2000)
    Send("1")
    Sleep(1000)
    
    While 1
        $coord = PixelSearch(300, 0, 1024, 700, 0xffffff, 7)
        If Not @error Then
            MouseClick("right", $coord[0], $coord[1], 1)
            Sleep(3000)
            MouseClick("left", 54, 257)
            Sleep(2000)
            Send("{e down}")
            Sleep(1000)
            Send("{e up}")
            Sleep(1000)
            Send("1")                            ;right
        Else
            Send("1")
            ;MouseClick("right", $coord[0], $coord[1], 1); you cannot use $coord here because they were not found
            Sleep(3000)
            MouseClick("left", 54, 257)
            Sleep(2000)
            Send("{e down}")
            Sleep(1000)
            Send("{e up}")
            Sleep(1000)
            Send("1")                            ;right
        EndIf
    WEnd
EndFunc   ;==>Start

Func exitt()
    Exit
EndFunc   ;==>exitt

8)

NEWHeader1.png

Link to comment
Share on other sites

with 30 second search loop

HotKeySet("{F2}", "start")
HotKeySet("{ESC}", "exitt")

While 1
    Sleep(100)
WEnd

Func Start()
    WinActivate("")
    Sleep(2000)
    Send("1")
    Sleep(1000)
    
    While 1
        $begin = TimerInit()
        $dif = ""
        Do
            $coord = PixelSearch(300, 0, 1024, 700, 0xffffff, 7)
            If Not @error Then
                MouseClick("right", $coord[0], $coord[1], 1)
                Sleep(3000)
                MouseClick("left", 54, 257)
                Sleep(2000)
                Send("{e down}")
                Sleep(1000)
                Send("{e up}")
                Sleep(1000)
                Send("1")                            ;right
                ExitLoop ; ??????
            EndIf
            $dif = TimerDiff($begin)
        Until $dif > 30000
        
        Send("1")
        ;MouseClick("right", $coord[0], $coord[1], 1); you cannot use $coord here because they were not found
        Sleep(3000)
        MouseClick("left", 54, 257)
        Sleep(2000)
        Send("{e down}")
        Sleep(1000)
        Send("{e up}")
        Sleep(1000)
        Send("1")                            ;right
        
    WEnd
EndFunc   ;==>Start

Func exitt()
    Exit
EndFunc   ;==>exitt

***** NOT TESTED

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

with 30 second search loop

HotKeySet("{F2}", "start")
HotKeySet("{ESC}", "exitt")

While 1
    Sleep(100)
WEnd

Func Start()
    WinActivate("")
    Sleep(2000)
    Send("1")
    Sleep(1000)
    
    While 1
        $begin = TimerInit()
        $dif = ""
        Do
            $coord = PixelSearch(300, 0, 1024, 700, 0xffffff, 7)
            If Not @error Then
                MouseClick("right", $coord[0], $coord[1], 1)
                Sleep(3000)
                MouseClick("left", 54, 257)
                Sleep(2000)
                Send("{e down}")
                Sleep(1000)
                Send("{e up}")
                Sleep(1000)
                Send("1")                            ;right
                ExitLoop ; ??????
            EndIf
            $dif = TimerDiff($begin)
        Until $dif > 30000
        
        Send("1")
        ;MouseClick("right", $coord[0], $coord[1], 1); you cannot use $coord here because they were not found
        Sleep(3000)
        MouseClick("left", 54, 257)
        Sleep(2000)
        Send("{e down}")
        Sleep(1000)
        Send("{e up}")
        Sleep(1000)
        Send("1")                            ;right
        
    WEnd
EndFunc   ;==>Start

Func exitt()
    Exit
EndFunc   ;==>exitt

***** NOT TESTED

8)

Heh, I never would have figured that out. Thank you so much ;).

One more thing:

;MouseClick("right", $coord[0], $coord[1], 1); you cannot use $coord here because they were not found

How could I get it to search for the pixel again?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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