Need help with Repeat/Until

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
BSteven
Newbie
Posts: 8
Joined: Sun May 30, 2010 2:59 pm

Need help with Repeat/Until

Post by BSteven » Sun May 30, 2010 3:13 pm

Hey, I want to make a script that keeps clicking a location with random intervals. When the pixels in the rectangular I selected change, It should exit the loop and proceed with the next steps.

Basically I want this to happen...

step1: move mouse to location
step2: wait between 1.2 and 1.6 seconds
step3: click
step5: repeat step 2 and 3 until the pixels in the selected rectangular change
step6: when the pixels change, move mouse
step7: click

I wrote this. Everything works, except I don't know how to make it repeat. Can anybody edit this script so it repeats? Thanks

Code: Select all

MouseMove>527,269
Repeat
Random>0.400,result1
Add>result1,1.200
Wait>%result1%
LClick
Until>WaitRectChanged>512,231,539,245,
MouseMove>420,360
LClick
!!!Lines 3-6 should be repeated until the pixels in the selected rectangular change!!!

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Sun May 30, 2010 4:01 pm

I believe this is what you described. I can't really test it completely because I don't have your environment.

[code]
MouseMove>527,269
GetRectCheckSum>512,231,539,245,result1

Label>Loop

//Returns a random number 0 5,myran
Let>mywait2=myran/10
Let>mywait=1.2+mywait2
Wait>mywait
LClick
GetRectCheckSum>512,231,539,245,result2
If>result2=result1,Loop
Label>Continue
MouseMove>420,360
LClick

[/code]

If you have questions or this doesn't work for you please post back.
Last edited by adroege on Sun May 30, 2010 10:40 pm, edited 3 times in total.

BSteven
Newbie
Posts: 8
Joined: Sun May 30, 2010 2:59 pm

Post by BSteven » Sun May 30, 2010 5:04 pm

That would be great:)

If anybody else found the solution, don't hesitate to post it!
I really need it:p

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Sun May 30, 2010 9:36 pm

Did the corrected code help?

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Mon May 31, 2010 1:59 am

Hi BSteven,

Here is a solution showing use of the Repeat/Until loop and your original WaitRectChanged logic. A Repeat/Until loop needs a variable specified on the Repeat line and an exit condition using that variable on the Until Line.

I have not tested this code:

Code: Select all

MouseMove>527,269
//Not sure if system variable WRC_RESULT may be initialized like this
//User variables are initialized this way before entering a loop.
Let>WRC_RESULT=TRUE
Repeat>WRC_RESULT
	Random>0.400,result1
	Add>result1,1.200
	LClick
	WaitRectChanged>512,231,539,245,%result1%
Until>WRC_RESULT=TRUE
MouseMove>420,360
LClick

BSteven
Newbie
Posts: 8
Joined: Sun May 30, 2010 2:59 pm

Post by BSteven » Mon May 31, 2010 1:59 pm

Hey guys,

Both edits make my script work the way I wanted it to.
Thanks you so much both:)

*Presses reputation button*

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Mon May 31, 2010 3:52 pm

There are differences in the way both code samples work.

Random> command only returns integers
so doing Random>0.400,result1 always in my testing resulted
in a result1=0
step1: move mouse to location
step2: wait between 1.2 and 1.6 seconds
step3: click
Since you stated you wanted a wait before click, the code which uses WaitRectChanged>512,231,539,245,%result1% will actually do a click and THEN wait (but only wait IF the rect has NOT changed) If the rect HAS changed then NO wait occurs at all.

The debugger is your friend. Stepping through both code samples using F8 will help make what I've said clearer. Both samples work, however the devil is in the details. When you said you wanted random wait times between 1.2 and 1.6 seconds, that seems to me VERY precise timing. You won't be able to tell time this precisely by the seat of your pants, you MUST examine the code carefully to see if it doing exactly what you want it to do.

Enjoy!

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