I know of AutoHotKey and I know of AutoScriptWriter but my issue comes down to timing.

I'm trying to reproduce user input into an application but the application sometimes has a loading time for some functions, other times it doesn't, basically I need to have a script writer be aware that if I don't press the mouse button for 5 seconds, the script writer puts a Sleep in the script for 5 seconds, but if I wait 10 seconds, it puts in a Sleep in the script for 10 seconds, and so on. Right now AutoScriptWriter puts in Sleep 100 as default which is too short and I don't want to go through the script manually after wards trying to remember if this click was supposed to wait 5 or 10 seconds or have just a small sleep.

Thanks all.

  • my workaround suggestion: record an empty (i.e. does nothing with no side effects) keystroke at each point where you want to do a long wait (like Alt-p for a 5 second wait) and then do a find/replace in the script on that keystroke and replace with the sleep 5000 or whatever. – yhw42 Apr 1 '11 at 18:54
  • Thanks yhw42, that could work out well. You should put it as an answer, it may be the correct way to go as a work-around. I still have to try it out and see how it works. – ScottN Apr 11 '11 at 16:10
  • posted as an answer. Hope it works out for you. – yhw42 Apr 11 '11 at 17:41

try WinWaitActive, WindowTitleHere

.... actions here

Then it won't start the action until the application is actually loaded and active.

Actually, AutoScriptWriter usually does add the WinWaitActive command.

  • I'm referring to in-application loading. The window is already active (Application is running), the issue is waiting for certain features of the app to load then to continue with the clicks. For example, loading a large amount of filenames into a list in the window, it doesn't happen instantaneously, especially if there are a lot of files. – ScottN Mar 29 '11 at 14:13
  • If you have a status bar, you can use the second parameter -- WinWaitActive, WindowTitle, WindowText to wait for specific text in the window that only appears when the window has completed loading – Dave Neeley Mar 29 '11 at 21:42
  • Sorry, that won't work because there are certain visual "controls" that update independently and asynchronously depending on what is clicked and there is no window text change to reflect this. Think of a modern Ajax web page that displays some information when you click a button or something loads. – ScottN Mar 29 '11 at 22:09

Here's an idea for a workaround:

  • assign the long wait an "empty" keystroke with no side effects
  • while recording the macro, add the keystroke where you need the long pause
  • once you have the macro script, do a find/replace on the keystroke and replace it with the instruction for the long wait, such as Sleep 5000

By "empty" I mean a keystroke with no side effects and no impact on the workspace of you macro. If it were to change the selected menu item or tab positioning or have any other side effects, the find/replace of that line might make the script unusable. If you have trouble finding a single keystroke (like Alt-p or whatever) you could also use a sequence that does an action with a second keystroke that undoes it, such as a typing a followed by a backspace.

If you have several different lengths of pauses, you could use several different keystrokes for different wait lengths. Just do a find/replace on each separately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.