WaitPixelColor> NOT ?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

WaitPixelColor> NOT ?

Post by Snickers » Sun Aug 05, 2007 6:49 pm

I can easily create a loop that checks to see if a pixel is NOT a certain color, for example:

Let>desiredcolor=4567890

Label>MainLoop
Getpixelcolor>123,123,result
If>resultNext
else
goto>MainLoop
endif

Label>Next
[...insert code here...]



Is it possible to write this same code using something similar to WaitPixelColr>?

For Example:
Label>MainLoop
WaitPixelColorNot>4567890,123,123,0
or
WaitPixelColorNot>%desiredcolor%,123,123,0

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 Aug 05, 2007 9:08 pm

No such function as WaitPixelColorNot. Just use a loop:

//Wait until pixel color is not %undesiredcolor%
Label>WaitNoMatch
Wait>0.5
GetPixelColor>123,123,result
If>result=undesiredcolor,WaitNoMatch
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Mon Aug 06, 2007 1:35 pm

Yea, that is how I currently have it set to run. If there was a WaitPixelColorNot> function, it would shorten the length of my script by 300 lines.

Thank you for your help! You guys are absolutely great with assistance.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Aug 06, 2007 3:06 pm

What am I missing? :?
Since Marcus' solution is only five lines, why not use that vs. your 300 lines?

Make this into a SubRoutine and can call it with one line, just like the function you are asking for.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by Marcus Tettmar » Mon Aug 06, 2007 3:13 pm

Take the comment and the Wait statement out and it's only 3 lines!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Mon Aug 06, 2007 8:32 pm

This is 1 of 60 different color check loops in my script. All 60 desiredcolors are declared at the top of the script.

Let>desiredcolor1=4567890
Let>desiredcolor2=987654
[...]add 58 more colors here

Code: Select all

Label>Action1
//An action will occur that sends me into Loop1.

Label>Loop1
Getpixelcolor>123,123,result
If>result<4567890>Action2
endif
Goto>Loop1

Label>Action2
//An action will occur that sends me into Loop2. 

Label>Loop2
Getpixelcolor>234,234,result
If>result<987654>Action3
endif
Goto>Loop2
If there was a waitpixelnot> command, my script would be simplified in the following way:

Code: Select all

Label>Action1
//An action will occur that sends me into waiting for  a pixel color to change.
waitpixelnot>4567890,123,123,10

Label>Action2
//An action will occur that sends me into Loop1. After this action, it would be normal for me to waitpixelcolornot>4567890
waitpixelnot>987654,234,234,10

So instead of having this single block of code:

Code: Select all

Label>Loop1
Getpixelcolor>123,123,result
If>result<4567890>Action2
endif
Goto>Loop1
...i would have this block of code:

Code: Select all

waitpixelnot>4567890,123,123,10
I usually only post a very small fragment of my code when asking for advice. I'm sorry I wasn't clear enough on the first pass.

Also with the waitpixelcolorNOT> command, I can put a timeout into play that would allow a means of error messaging. Without the timeout, such as in waitpixelcolor>4567890,123,123,10 the SEC> command or MIN>command such as this:

Code: Select all

Min>start
If>start>54
 Let>begin=%start%-5
 Let>finish=%begin%+3
else
 Let>begin=%start%
 Let>finish=%begin%+3
endif

Min>minutecheck
If>minutecheck>54
 Let>extratime=5
else
 Let>extratime=0
endif

Label>TimeCheck
Min>current
Let>current=%current%+%extratime%
If>current=%finish%
  Goto>Errorend2
endif

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

Post by Marcus Tettmar » Mon Aug 06, 2007 8:38 pm

Make a subroutine:

[code]
GoSub>WaitPixelColorNot,4567890,120,120

GoSub>WaitPixelColorNot,987654,240,130

GoSub>WaitPixelColorNot,3435633,100,100

etc

SRT>WaitPixelColorNot
Wait>0.25
Getpixelcolor>%WaitPixelColorNot_Var2%,%WaitPixelColorNot_Var3%,result
If>result=%WaitPixelColorNot_Var1%,WaitPixelColorNot
End>WaitPixelColorNot
[/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?

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Mon Aug 06, 2007 10:35 pm

I'll be darn. I was unaware that you can send to a sub and declare variables such as that:

GoSub>WaitPixelColorNot,4567890,120,120

Thank you very much!

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