Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

This should be entirely possible with AppleScript alone.

The basic loop structure is:


/* 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.

share|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

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.

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Ivo Flipse Aug 5 '12 at 21:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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