I am after a program to complete a series of key presses automatically, with next to no involvement from a human.

Basicly, I want it to hold down the spacebar, whilst pressing Y a couple of times, then T a couple of times, then loop until I stop it manually.

Is it possible to do this? Can I use Apple Script, or would I have to resort to another program.

link|improve this question

feedback

3 Answers

This should be entirely possible with AppleScript alone.

The basic loop structure is:

repeat

/* your code goes here... */

end repeat

to send keystrokes, you can use keystroke:

tell application "Application Name Here"
    keystroke "A"
end tell

this would send a capital "a" to a specific running application.

If you wanted to send a key while holding another down:

tell application "Application Name Here"
    keystroke "A" using {command down}
end tell

this would send an "a" while holding down the command key.

There is an excellent plethora of information available about AppleScript on Mac OSX Automation.

link|improve this answer
I keep getting "<program name> got an error: Can’t get keystroke "a".". What gives? – David Pearce Feb 26 '10 at 10:53
You may have entered the incorrect application name. Try using System Events as the application name. – John T Feb 26 '10 at 22:30
feedback

I use quicksilver - install it, create a text file with the keystrokes you want, and then create a "custom trigger" and assign it a hotkey.

link|improve this answer
feedback

I love Keyboard Maestro

link|improve this answer
Keyboard Maestro, from my understanding, does not support loops, which is a must. – David Pearce Feb 26 '10 at 10:37
feedback

Your Answer

 
or
required, but never shown

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