Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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? – Josh Hunt 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
doesn't work for me neither – MeV Aug 3 '15 at 15:25

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

I've tried Automator and it's not the easiest thing to do if you're looking to move beyond your immediate request.

If you're willing to try a 3rd-party program, Keyboard Maestro is incredibly powerful and easy to use. I installed it and had my keyboard shortcuts running in no time.

One nice thing about KM is that you can create simple text-based shortcuts, so that you don't have to take your hands off the keyboard to use the macro. I'm a developer and use vim and the command-line extensively so not having to use any special keys is important to me.

So, in my case... I created a macro that was invoked with ',,,sign' which entered my testing user id, tabbed to the next field, entered the password, tabbed to the next field, entered the [Enter] key and - voila! - I am signed in.

Simple and incredibly effective. It's not free; after a trial period, you have to purchase it, but it was a no-brainer for me.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .