need command similar to wait

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

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

need command similar to wait

Post by Snickers » Wed Aug 01, 2007 2:53 pm

with the command WAIT, the macro simply waits for the designated time.

I need a command that will skip a certain if then statement if 5 seconds hasn't passed.


Example (simplified--my real script is 45 pages long):
//--------------------------------------------------------------------
getpixelcolor>123,123,thing1
if>thing1=255
do something
endif

if>thing1=65546 and 5 seconds has elapsed from the last time thing1 colorcheck caused and event
do something
endif
//--------------------------------------------------------------------


since checking the system clock using the SEC> or MIN> command will store the current time, I am thinking there must be a way to do this; however, I can't swing it because if it just so happens to record the seconds as 59 seconds, how can i tell if 5 seconds has passed when the SEC> command will actually record 4 as the variable instead of 63 seconds.

Can someone please set me straight on this one? The wait command wont work because it freezes the script to actually "wait".

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

possible solution..

Post by Snickers » Wed Aug 01, 2007 3:38 pm

SRT>Face

SEC>seconds
if>seconds>54
let>seconds1=%seconds%-30
else
let>seconds1=%seconds%
endif

SEC>seconds
if>secondsseconds2=%seconds%+25
else
let>seconds2=%seconds%-5
endif

If>seconds1=seconds2
let>turn=1
endif

getpixelcolor>blah,blah,movecheck1
getpixelcolor>blah,blah,movecheck2
If>turn=1
If>{(%movecheck1% = 251) OR (%movecheck1% = 64498)}
If>{(%movecheck2% = 255) OR (%movecheck2% = 65526)}
mousemove>100,456
wait>.3
Rdown
mousemove>1100,456
wait>.3
Rup
wait>1
add>turn,1
let>fightcounter=1
END>Face
endif
endif
endif

UNTESTED

this will probably work; however, do you know a faster way?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Aug 01, 2007 3:46 pm

Try something like this:

Code: Select all

//--------------------------------------------------------------------
//Set next line to maximum wait time in seconds
Let>WaitMax=5
VBSTART
VBEND
VBEval>Timer,WaitStarted

Label>getpixelcolor_loop
getpixelcolor>123,123,thing1
if>thing1=255
//do something
endif

VBEval>Timer,WaitCheck
Let>WaitDiff=%WaitCheck%-%WaitStarted%

//I don't know what you're doing so I don't know if you want
//an "AND" or an "OR" in the following complex If> statement
if>{(%thing1%=65546)OR(%WaitDiff%>%WaitMax%)}
//and 5 seconds has elapsed from the last time thing1 colorcheck caused and event
//do something by jumping out of this loop
Goto>jump_out_of_loop
endif
Wait>0.01
Goto>getpixelcolor_loop

Label>jump_out_of_loop
//--------------------------------------------------------------------

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

Post by Snickers » Wed Aug 01, 2007 6:05 pm

JRL wrote:Try something like this:

Code: Select all

//--------------------------------------------------------------------
//Set next line to maximum wait time in seconds
Let>WaitMax=5
VBSTART
VBEND
VBEval>Timer,WaitStarted

Label>getpixelcolor_loop
getpixelcolor>123,123,thing1
if>thing1=255
//do something
endif

VBEval>Timer,WaitCheck
Let>WaitDiff=%WaitCheck%-%WaitStarted%

//I don't know what you're doing so I don't know if you want
//an "AND" or an "OR" in the following complex If> statement
if>{(%thing1%=65546)OR(%WaitDiff%>%WaitMax%)}
//and 5 seconds has elapsed from the last time thing1 colorcheck caused and event
//do something by jumping out of this loop
Goto>jump_out_of_loop
endif
Wait>0.01
Goto>getpixelcolor_loop

Label>jump_out_of_loop
//--------------------------------------------------------------------
Thank you,
I managed to use this example and mix it up a bit to make it work nicely.

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