Macro runs too fast and doesn't recognize buttons

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
montanan
Junior Coder
Posts: 49
Joined: Mon Jul 09, 2007 3:44 pm
Location: San Jose, CA

Macro runs too fast and doesn't recognize buttons

Post by montanan » Thu Dec 18, 2008 3:26 pm

I have developed a macro that creates a backup for any macro. I think many users may enjoy this one and it would be a good example to ship with Macro Scheduler. I am having two problems:

- macro won't run slow enough to work
- macro doesn't seem to recognize buttons or commands within dialogs

Here is my code:

Code: Select all

//copy macro name to variable
Let>SK_DELAY=200
Press F2
WaitWindowOpen>Rename*
WaitReady>0
Press CTRL
send>c
Release CTRL
Wait>1
Press Tab
Press Enter
GetClipBoard>macroname

//copy macro code to variable
Press Enter
Press Shift
Press CTRL
Press end
Release Shift
Release CTRL
Press CTRL
send>c
Release CTRL
GetClipBoard>macrocode
Press ALT
send>o
Release ALT

//create new macro file, name the macro, file it in xBackup group, paste the code, then exit
WaitWindowOpen>Macro Scheduler*
WaitReady>0
Press CTRL
send>n
Release CTRL
GetDate>mydate
GetTime>mytime
send>backup_%macroname%_%mydate%-%mytime%
Press Tab*2
Press Up
Press Tab
send>xBackup
Press Enter
Press Tab*7
Press Down
Press Tab
send>%macrocode%
Press ALT
send>o
Release ALT
Any help is appreciated!

-Richard

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Fri Dec 19, 2008 7:54 pm

I would start with adding waits to code. Sometimes Wait>0.1 is enough but sometime you need a little more like 0.5 sec.

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 » Fri Dec 19, 2008 8:41 pm

To expand on Rain's suggestion:
Before adding Wait, make a variable for the delay value, so you can modify the time in one location vs. each line with Wait ....

//Initialize value for Wait Delay of three seconds
Let>vDelay=3

//Use this Wait line wherever needed, change time by modifying vDelay above.
Wait>%vDelay%
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

montanan
Junior Coder
Posts: 49
Joined: Mon Jul 09, 2007 3:44 pm
Location: San Jose, CA

Thank you to Rain and Bob

Post by montanan » Sun Dec 21, 2008 5:25 am

I'll give the variable-based wait approach a try.

Thank you.

-Richard

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