Small Help with "Repeat"

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
New Here

Small Help with "Repeat"

Post by New Here » Tue May 11, 2004 9:27 pm

Hi Guys,

I'm new to Macro Scheduler, have been trying for hours to code a simple script, no success in the mean while, unfortunately.

All I want to create is a simple script that "presses" on the {Press Down} key (the key with the arrow pointing downward) 500 times, with a wait of 3 seconds between each press.
It must be a simple one!!

Any help is appreciated.

Sam.

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 » Tue May 11, 2004 10:37 pm

Hi Sam.....Welcome to Macro Scheduler

Your request:
All I want to create is a simple script that "presses" on the {Press Down} key (the key with the arrow pointing downward) 500 times, with a wait of 3 seconds between each press.
Here a basic script to do that, without comments:
Let>Count=0

Label>Loop
Press Down
Wait>3

Let>Count=%Count%+1
If>%Count%=500,End,Loop

Label>End
Since you are new, I have also added a few more lines as a tutorial example. Here is the same script with some //Comments, an input to change the count, and a Message Box to show progress:
//Prompt user for maximum times to press key
Input>Max,How many times do you want to press the DOWN arrow?

//Initialize counter
Let>Count=0

//Start loop, press Down arrow, and wait for 3 seconds
Label>Loop
Press Down
Wait>3

//Increase counter
Let>Count=%Count%+1
Let>Remainder=%Max%-%Count%
Message>"DOWN" arrow has been pressed %Count% times.%CRLF%%CRLF%It will be pressed %Remainder% more times.

//Check to see if loop has processed 500 times.
//If not yet 500, then go back to Loop again, else go to End
If>%Count%=%Max%,End,Loop

Label>End
Message>Process is DONE!
Be sure to remove any Trailing Space Characters on each line. You can do this in the Editor, clicking on Edit, Show All Chars, and Remove Trailing Spaces.
Last edited by Bob Hansen on Tue May 11, 2004 11:07 pm, edited 7 times in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Lumumba

Post by Lumumba » Tue May 11, 2004 10:41 pm

Let>k=1
Repeat>k
Press Down
Add>k,1
Until>k, 500

Lumumba

Post by Lumumba » Tue May 11, 2004 10:43 pm

Let>k=1
Repeat>k
Press Down
Add>k,1
Wait>3
Until>k, 500

Nearly the same as Bob's :idea:

Sam

Thanks for the code, BUT...

Post by Sam » Wed May 12, 2004 6:28 am

Hi Bob & Lumumba,

I cut & pasted your code, Bob, and basically I understand the concept pretty OK now (from the coding perspective).
The thing is, there must be something I'm doing wrong, as it doesn't work.
Let me tell you what I did: I created a new script with Bob's code, and presses the "Run Now" option from the "right click" menu. Indeed, the Macro Scheduler icon worked very well in the bottom right.
Then, I manually opened a text document (an old one I have) in Notepad, expecting the script to press the {Down Key} each 5 seconds, unsuccessfully - as the script (my fault, I guess) hasn't performed even once!

Would you please be so kind and let me know what I'm doing wrong ?

Thanks,
Sam.



Thanks for the help.

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 » Wed May 12, 2004 8:17 pm

I suspect that what is missing is SetFocus>WindowName*

It sounds like you are expecting to see the DOWN movement happening 500 times. I have inserted another line at the top of the loop. Repklace "NotePad" with the name of the Window that you want the macro to be running in. You may also need to initialize the position of the cursor with a MouseMoveRel> command. or CTL-HOME to get to top of document.

Let>Count=0

Label>Loop
SetFocus>Notepad*
Press Down
Wait>3

Let>Count=%Count%+1
If>%Count%=500,End,Loop

Label>End
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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