WaitPixelColor> NOT ?
Moderators: JRL, Dorian (MJT support)
WaitPixelColor> NOT ?
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
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
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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
//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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
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
If there was a waitpixelnot> command, my script would be simplified in the following way:
So instead of having this single block of code:
...i would have this block of code:
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:
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
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
Code: Select all
waitpixelnot>4567890,123,123,10
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
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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]
[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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?