waitrectcolor with if

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
chelo_100
Newbie
Posts: 11
Joined: Sun Jul 23, 2006 5:22 am

waitrectcolor with if

Post by chelo_100 » Sun Jul 23, 2006 5:49 am

hi, i have some problems with a few logic commands, sorry my bad english
i have a rect in my screen and in it appear one number (0 - 100) this number is variable, but it has a color, e.g.
if this number is yellow, press np1
or
if this number is red, press np2

the pixel rect is 716,218,830,232

the cuestion is how i do this command when waitrectcolor doesn??t exist?
what is the best command to use for this?
thank u
________
buy digital scale
Last edited by chelo_100 on Tue Feb 01, 2011 10:34 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Jul 23, 2006 8:06 am

Use GetRectCheckSum in a loop:

Code: Select all

Label>WaitRect
  GetRectCheckSum>716,218,830,232,csum
  Wait>0.2
  If>csum<>whatever,WaitRect
Change whatever to whatever value you want to wait for
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

chelo_100
Newbie
Posts: 11
Joined: Sun Jul 23, 2006 5:22 am

Post by chelo_100 » Sun Jul 23, 2006 8:03 pm

thanks but i changed the value with 255 wich is the red color, and doesn??t work
the example i gived to u is what i want to do
if 65535 (yellow) appears press np1
if 255 (yellow) appears press np2
this two variables appears in the rect

here is the idea

Image

again thanks for this help
________
Ferrari 275 history
Last edited by chelo_100 on Tue Feb 01, 2011 10:34 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Jul 23, 2006 8:52 pm

GetRectCheckSum returns a checksum of ALL the colors in the rectangle. Now, are you saying you want to see if ONE color, e.g. yellow, appears SOMEWHERE within the rectangle, or the ENTIRE rectangle IS yellow?

If the former we can create a loop with GetPixelColor to scan the contents of the rectangle. If the latter run GetRectCheckSum when the entire rectangle is yellow and make a note of the outcome and use that in your comparison, etc (Use the value GetRectCheckSum returns, not an actual color code).

You can do either. To help you, please clarify which you want and I can provide some example code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

chelo_100
Newbie
Posts: 11
Joined: Sun Jul 23, 2006 5:22 am

Post by chelo_100 » Sun Jul 23, 2006 9:05 pm

yes is a number in somewhere of the rect, the color is not in all the rect
is like the draw
________
Honda CB500 Cup history
Last edited by chelo_100 on Tue Feb 01, 2011 10:34 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Jul 23, 2006 9:19 pm

So I think what you want is, for example:

"Wait until any pixel within rectangle 716,218,830,232 is yellow"

Is that correct? If so take a look at:
http://www.mjtnet.com/forum/viewtopic.php?t=1363

So you could do something like:

Code: Select all

Label>FindColor
Let>found=no
Let>XMax=830
Let>YMax=232
Let>X=716
Repeat>X
   Let>X=X+1
   Let>Y=218
   Repeat>Y
      Let>Y=Y+1
      GetPixelColor>X,Y,c
      //Message>c
      If>c=60159
         Let>found=yes
         Goto>done
      endif
   Until>Y,YMax
Until>X,XMax
If>found=no,FindColor
Label>done
So this scans all pixels within the rectangle. If one of those pixels matches the colour we jump out of the loop. If we reached the end of the rectangle without a match we start again. So it loops forever until a pixel matching the specified colour is found.

To determine the colour to check for use the cursor monitor on the Macro Properties window (or in the Editor use Tools/Cursor Monitor - the last number is the colour).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

chelo_100
Newbie
Posts: 11
Joined: Sun Jul 23, 2006 5:22 am

Post by chelo_100 » Tue Jul 25, 2006 12:24 am

thanks for all, the script that u showed me is what i want
i just need a few commands to finish this proyect
here is the script with a few commands wich i changed:

Label>FindColor
Let>found=no
Let>XMax=912
Let>YMax=125
Let>X=854
Repeat>X
Let>X=X+1
Let>Y=110
Repeat>Y
Let>Y=Y+1
GetPixelColor>X,Y,c
//Message>c
If>c=255
Let>found=yes
press np1
Goto>done
endif
if>c=65535
Let>found=yes
Press np2
goto>done
endif
if>c=65280
let>found=yes
press np2
goto>done
endif
Until>Y,YMax
Until>X,XMax
If>found=no,FindColor
Label>done

now i need to add this:

if the colors 65280 and 65535 appears again press np3
if this colors appears again press np4
if appears again press np5
if appears again press np6
if appears again press np7
if appears again press np1 (returns to the first command or the start)

i agree your msn to my list, if u like to explain this better
i hope u understand what i need, it??s easy now, the worst part was the first, thank u for this
________
Dodge Matador history
Last edited by chelo_100 on Tue Feb 01, 2011 10:34 pm, edited 1 time in total.

chelo_100
Newbie
Posts: 11
Joined: Sun Jul 23, 2006 5:22 am

Post by chelo_100 » Thu Jul 27, 2006 1:57 am

do u find an answer?
________
Ford Nucleon history
Last edited by chelo_100 on Tue Feb 01, 2011 10:34 pm, edited 1 time in total.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Thu Jul 27, 2006 1:34 pm

If you want to continually search for the color to appear again and again, just pass control from the Label>done back to Label>FindColor....

I would suggest placing a counter of some sort on the FindColor label so that it runs for a set amount of time or a set number of occurrences.

chelo_100
Newbie
Posts: 11
Joined: Sun Jul 23, 2006 5:22 am

Post by chelo_100 » Thu Jul 27, 2006 6:23 pm

thank for the post SkunkWorks but i don??t want to repeat the script, if i want to repeat it i put

Let>k=1
Repeat>k

script

Let>k=k+1
Until>k

but i want to add a memory
if 65535 or 65280 appears again press np3

i tried with

if>c=65535 or 65280
let>found=yes
press np2
wait>2
if>c=65535 or 65280 (line 17)
let>found=yes
press np3

but in line 17 i need to scan again to found this condition, but if the script scan and found 65535 or 65280 would press np2 not np3
________
no2 vaporizer

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts