Sign in to follow this  
Followers 0
Timebombx

Loop/If Problem

6 posts in this topic

So I have a for loop that's running, at the end of each loop I have a pixel check:

If $coord = PixelSearch( 557, 206, 806, 628, 4199436 )

;Coding here, but assuming it's wrong

;I'm trying to set it to if this pixel color is true, than it will call a function.

;

if $i < $numpass Then

Sleep(180000)

EndIf

Next

Exit

How exactly would I set it up so it will call a function if true? Looked through the help, but couldn't seem to find it exactly.

Thank you

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

Welcome to AutoitScript Forum.

According to the help file PixelSearch() the following code should work if the color is found to be true.

; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
;If color found equals true
If Not @error Then 
   MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
   ;Call the function
   CallFun()        
EndIf

jfcby

Edited by jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Share this post


Link to post
Share on other sites

Welcome to AutoitScript Forum.

According to the help file PixelSearch() the following code should work if the color is found to be true.

; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
;If color found equals true
If Not @error Then 
   MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
   ;Call the function
   CallFun()        
EndIf

jfcby

Oh no it won't.

Improper use of the Call() function, which is a good function to avoid (if possible) anyway.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Oh no it won't.

Improper use of the Call() function, which is a good function to avoid (if possible) anyway.

Tried the one off the example which is why I figured I did something wrong. I guess not. How exactly would I use a function if it does find the color without exactly calling it?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Tried the one off the example which is why I figured I did something wrong. I guess not. How exactly would I use a function if it does find the color without exactly calling it?

The example by jfcby looks fine to me, I think GEO misread it, his callfun() is just an example of where you would call your function whatever its name is.

But rightly avoid the native call() function where possible.

Edited by JohnOne

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

The example by jfcby looks fine to me, I think GEO misread it, his callfun() is just an example of where you would call your function whatever its name is.

But rightly avoid the native call() function where possible.

You're oh so correct. I'm pleading old age and standing by it.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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