Sign in to follow this  
Followers 0
Lambort

If pixel isn't found Then do -blahblahblah-

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I tried that and i get:

"C:\Documents and Settings\Bran\Desktop\gamemessedup.au3 (39) : ==> Subscript used with non-Array variable.:

MouseClick("right", $coord[0], $coord[1], 1)

MouseClick("right", $coord^ ERROR"

;)

Share this post


Link to post
Share on other sites

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



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

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

Argh. is there any way that I can search for the pixel for 30 seconds and if it doesn't find it then do the next command?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Welcome

How could I get it to search for the pixel again?

While 1
    Sleep(100)
    Start()
WEnd

8)


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0