Sign in to follow this  
Followers 0
brad25

PixelSearch

10 posts in this topic

Ok having a hard time figuring this out im wanting my program to sleep as long as it finds this color. So its gonna be in a loop to keep checking for a change.

$coord = PixelSearch( 170, 89, 1100, 700, 0xd02929)

and when it no longer see's the color to

MsgBox(4096, "Test", "color not found any longer", 10)

any help would be great and i cant use pixelgetcolor as the cords of the color will change thanks.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Do you know what a loop is?

EDIT:

And how to check a return value of a function call?

Thanks for the fast reply my question is how do i make it sleep until this code is no longer true
$coord = PixelSearch( 170, 89, 1100, 700, 0xd02929)
Edited by brad25

Share this post


Link to post
Share on other sites

PixelSearch(...) is a function call, it returns certain values if it is successful

and sets @error if it is not.

So testing those values in your loop, will tell you if the function was successful

of not.

And a conditional statement (If...Else...EndIf) can act (or not) your messagebox.

Have a quick look at Pixelsearch in the helpfile, and try it.


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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

PixelSearch(...) is a function call, it returns certain values if it is successful

and sets @error if it is not.

So testing those values in your loop, will tell you if the function was successful

of not.

And a conditional statement (If...Else...EndIf) can act (or not) your messagebox.

Have a quick look at Pixelsearch in the helpfile, and try it.

ok i can get the pixelsearch part to work just getting the conditional statement to msgbox the color has not been found im struggling with . Maybe an example?

Share this post


Link to post
Share on other sites

anyone?

Share this post


Link to post
Share on other sites

Can you post your code?

while 1

$coord = PixelSearch( 170, 89, 1100, 700, 0xd02929)
$yoyoy = PixelSearch( 170, 89, 1100, 700, 0xc72626)
$yovyoy = PixelSearch( 170, 89, 1100, 700, 0xc82626)
If Not @error Then
  
 
;if the colors above are not found i want it to do this below
Else
MouseClick("right")
sleep(5000)
MouseClick("left")
sleep(1500)
EndIf
WEnd

Share this post


Link to post
Share on other sites

You are trying to find multiple colours but only checking if the last one is found

So you need to test each one, and if any one of them is not found, then continue the

loop from the beginning

while 1

$coord = PixelSearch( 170, 89, 1100, 700, 0xd02929)
If @error Then
_DoStuff()
ContinueLoop
EndIf

$yoyoy = PixelSearch( 170, 89, 1100, 700, 0xc72626)

If @error Then 
_DoStuff()
ContinueLoop
EndIf
$yovyoy = PixelSearch( 170, 89, 1100, 700, 0xc82626)

If @error Then 
_DoStuff()
ContinueLoop
EndIf

;Code to do something if the colours are found

WEnd


;if the colors above are not found i want it to do this below
Func _DoStuff()
MouseClick("right")
sleep(5000)
MouseClick("left")
sleep(1500)
EndFunc

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

Monkey's are, like, natures humans.

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