counter macro how?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
chuckles
Newbie
Posts: 12
Joined: Tue Oct 11, 2005 5:15 pm

counter macro how?

Post by chuckles » Tue Oct 11, 2005 5:21 pm

Hi i am curious if someone could point me to the right direction on how to make this script simple.
i need to make a script to perform
Ctrl-G then press down
and repeat but ALWAYS increase by 1 until 100.

ie.
press ctrl-g then down
wait 50secs
press ctrl-g then down key 2times.
wait 50secs
press ctrl-g then down key 3 times.
until 100 times.

below is something i have but not really efficient.

Press CTRL
Wait>2.11
Send>g
Wait>2.11
Release CTRL
Wait>2.11
Press Down
Wait>3.11
Press Enter
Wait>50.50
Press CTRL
Wait>2.11
Send>g
Wait>2.11
Release CTRL
Wait>2.11
Press Down * 2
Wait>3.11
Press Enter
Wait>50.50
Press CTRL
Wait>2.11
Send>g
Wait>2.11
Release CTRL
Wait>2.11
Press DOWN *3

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Oct 11, 2005 5:30 pm

Like this perhaps:

Let>count=0
Let>max=100

Repeat>count
Let>count=count+1
Press CTRL
Send>g
Release CTRL
Press Down * count
Wait>50
Until>count=max
MJT Net Support
[email protected]

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Oct 11, 2005 5:39 pm

Try the Repeat Until command. This example presses down arrow on an excel spreadsheet. if you don't have excel, just use any word processor, but be sure to change the SetFocus> command to reflect the appropriate window name.

It might go something like this.

let>counter=0
Repeat>counter
let>counter=counter+1
setfocus>Microsoft Excel*
wait>1
Press Down * %counter%
Until>cntr,100

chuckles
Newbie
Posts: 12
Joined: Tue Oct 11, 2005 5:15 pm

Post by chuckles » Tue Oct 11, 2005 5:58 pm

Thank you for your help, very much appreciated.

i am now getting an error message

Macro Scheduler Information: "Error - Label Not FOUND!"

my script looks like this:



//Recorded Events
CapsOff
Let>count=0
Let>max=100

Wait>13.74
Press CTRL
Wait>2.11
Send>g
Wait>2.11
Release CTRL
Wait>2.11
Press Enter
Wait>5
Repeat>count
Let>count=count+1
Press CTRL
Wait>1.11
Send>g
Wait>1.11
Release CTRL
Wait>1.11
Press Down * count
Wait>1.11
Press Enter
Wait>50
Until>count=max

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 Oct 11, 2005 7:47 pm

Remove all trailing spaces
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

chuckles
Newbie
Posts: 12
Joined: Tue Oct 11, 2005 5:15 pm

Post by chuckles » Tue Oct 11, 2005 8:25 pm

thanks again for your help -- i did the edit/ remove trailing spaces which did not work.

it looks like i'm REQUIRED to use Label>start and Goto commands. i've refined my script below.

the only issue now that i have is the script does NOT stop at 100. the Until>count=max is underneath Goto cmd but if i place the Until command before Goto cmd the script breaks.

any suggestions?



my script looks like this:
//Recorded Events
CapsOff
Wait>10
Let>count=0
Let>max=100
Label>Start
Repeat>count
Let>count=count+1
Press CTRL
Wait>1.11
Send>g
Wait>1.11
Release CTRL
Wait>1.11
Press Down * %count%
Wait>1.11
Press Enter
Wait>4.37
Goto>Start
Until>count=max
Label>Exit

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Oct 11, 2005 8:51 pm

The syntax for the UNTIL> line is wrong. Look at the code I poste earlier.

Repeat>X

some code here

Until>X,Value


NOT Until>X=value

btw, in my code I misnamed the final value cntr and it should be counter....sorry.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Oct 11, 2005 8:53 pm

I just noticed that you are also passing control of the script OUT of the Repeat loop with a Goto>Start. Don't do this. Allow the code to process the Repeat - Until loop as it should.

chuckles
Newbie
Posts: 12
Joined: Tue Oct 11, 2005 5:15 pm

Post by chuckles » Tue Oct 11, 2005 8:55 pm

Thank you!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Oct 11, 2005 9:16 pm

SkunkWorks wrote:The syntax for the UNTIL> line is wrong. Look at the code I poste earlier.

Repeat>X

some code here

Until>X,Value


NOT Until>X=value

btw, in my code I misnamed the final value cntr and it should be counter....sorry.
Actually this is correct. Since 7.3.10.5 Until can take either format. It can also take , or symbols. The backward compatible comma is the same as the equals sign.
MJT Net Support
[email protected]

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Wed Oct 12, 2005 12:32 pm

I was not aware that "Until>x=value" would work. I am on the latest version and the help files don't show that method. Anyway, the code seemed to work.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Oct 12, 2005 1:04 pm

Odd. You sure you have the correct version? The following is copied directly from the latest help file:

"Until>variable,finalvalue

Use in conjunction with Repeat. Iterates the code from the Repeat statement to the Until statement until the specified expression in the Until statement becomes true. Until can take one of the following simple expressions:

variable,value
for backward compatibility. Same as variable=value
variable=value
Until variable equals the value specified
variable>value
Until variable is greater than the value specified
variablevalue
Until variable does not equal the value specified"
MJT Net Support
[email protected]

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Wed Oct 12, 2005 1:53 pm

You are correct. The help file does show those examples. I am looking at the code sample which shows Until>x,value.

Sorry. Typical programmer's attitude "Just show me the code"...

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