Sign in to follow this  
Followers 0
bikerbrooks

loops for a noob

7 posts in this topic

#1 ·  Posted (edited)

just trying to make a bot where it finds pxels clicks but if no pixel found move to next command tried so many ways i just cant seem to figure out simple loops

;i want this to find pixel then click  until no $search found then move on to next
;i have tried many loops but they all seem to only run though this once


;; i want this to loop until not found
$search = PixelSearch(1920,50,3839,1079,0xEF0FFF)
If Not @error Then
    MouseMove($search[0],$search[1])
    Sleep(750)
    MouseClick ("left")
EndIf

send("{ctrldown}{f}{ctrlup}{altdown}{c}{altup}{altdown}{a}{altup}")
sleep(300)
Send("open")

 

 

 

 

 

 


EndIf

Edited by bikerbrooks
code out of place

Share this post


Link to post
Share on other sites



Have a look in the help: Do...Until

Share this post


Link to post
Share on other sites

haha i noticed as i have tried if, while, also tried within a function and none to work i was trying to get some insight on what i need the loop within ie a while ? else ?

 

Share this post


Link to post
Share on other sites

Have a look in the help: Do...Until

i have tried the do until i am trying so find juist a simple loop for the pixelsearch where when i have ran the loops i either get erroe mouse click $seach error

 

so how do i

do pixel search

until no pixel then

 

Share this post


Link to post
Share on other sites
_Example()

Func _Example()
    While 3
        $search = PixelSearch(1920, 50, 3839, 1079, 0xEF0FFF)
        If Not @error Then
            MouseMove($search[0], $search[1])
            Sleep(750)
            MouseClick("left")
        Else
            Return SetError(1) ; Not found
        EndIf
        Send("{ctrldown}{f}{ctrlup}{altdown}{c}{altup}{altdown}{a}{altup}")
        Sleep(300)
        Send("open")
    WEnd
EndFunc   ;==>_Example

 

1 person likes this

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

JohnOne's code is surely perfection... I just wanted to point out that the 3 after While is arbitrary. Any number other than zero (0) will evaluate as true. So these are all the same:

While 3

While 1

While True

While 2 > 1

Just so you don't get hung up thinking it will repeat 3 times or something like that.

1 person likes this

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