Sign in to follow this  
Followers 0
Vane

Loop until PixelSearch gives error?

4 posts in this topic

Hello everyone. I'm new to AutoIt so i'm sorry if this is a simple minded question.

I'm trying to make a script to:

- Use PixelSearch to search a color in a frame

- If color is to be found, run a function,

- - check again for the color,

- - if it is still found, run function again over and over

- when color is not found, change frame

- do it all over again until frame is done

- repeat by x number of frames.

My problem is I can not end Do - Until loop once it has started. It detects the color I want to detect (true and false value), but even after reaching the desired result it continues in the loop ("There it is" when there it is not).

Func CheckClick($posX, $posY, $posX2, $posY2, $th) 
   OpenSy()
   ToolTip("looking",0,0)
   Local $coord = PixelSearch($posX, $posY, $posX2, $posY2, 0x15374e, 15)
   If @error Then
 MsgBox(0, "???", "Not found")
 NextThumbnail($th)
   Else
 Do
MsgBox(0, "???", "There it is")
Filter1()
Filter2()
Sleep(1000)
OpenSy()
$coord = PixelSearch($posX, $posY, $posX2, $posY2, 0x15374e, 15)
 Until $coord = @error,
   EndIf
EndFunc

I'm not Sure Do-Until is the best thing to do, or a While either. Any pointing would be appreciated.

Thanks.

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

Can you please tell us which application you try to automate? Maybe there is an easier way to do what you want.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Welcome to AutoIt and the forum!

Can you please tell us which application you try to automate? Maybe there is an easier way to do what you want.

Hello, I'm trying to automate a program named GraphicsGale. It's like paint but a bit more to pixel art and animation.

Change

Until $coord = @error

To

Until @error

And get rid of the comma.

Thank you, that fixed it.

Thanks everyone for the fast response. This is how the code ended up, if anyone has any use for it:

Func ColorCheck($NoT, $StartX, $Area)
OpenSy()
Posit()
$i = 0
$Rt = $StartX
Do
DoRow($Rt)
$Rt = $Rt + $Area
$i = $i + 1
Until $i = $NoT
MouseClick("primary", 455, 585, 1, 5)
EndFunc

Func DoRow($Yi, $StartY, $Color, $Area)
$Xc=$StartY
$Yc=$Yi
Do
Local $coord = PixelSearch($Xc, $Yc, $Xc+2, $Yc+2, $Color, 15) ;not broken color
If @error Then
$Xc = $Xc + $Area
Else
Do
SelectIt($Xc+2, $Yc+2)
Filter1()
Filter2()
OpenSy()
Posit()
$coord = PixelSearch($Xc, $Yc, $Xc+2, $Yc+2, $Color, 15)
Until @error
EndIf
Until $Xc > 900 ;( 874 is max )
;MsgBox(0, "???", "FINISHED ROW", 1)
EndFunc

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