Record a series of keystrokes and then replay them

I've had a quick look at Applescript and Automator and they don't seem to do the easy/basic thing I'm looking to do. (Perhaps they do and, if you say so, I'm willing to invest some time into a deeper look.)


I want to "record" a short series of key and mouse actions, save them as a set of actions, and replay them (on a new document/file) - over and over. The particular application is Fireworks, on an open .png image file, but the basic need applies to any kind of file that's open in any application. Here it would be a series of actions like: go to the menubar, click on an item; click on a sub-menu item to bring up its window; tab twice; type a value; key "return" (for ok)


I'm just looking for a fairly 'dumb' series of entries that I would like to "record once" and "play many times." Yes, it would depend on the windows being in the same place all the time (which they are, in this particular case). When I find myself doing the same set of actions a dozen (or a hundred) times, I mutter "There must be a better way!" Is there?!?!?

Mini + Air11, Mac OS X (10.6.8), iPhones, iPods, iPad, MacBook Pro (10.6), PB G4 (10.4), ATV

Posted on Sep 10, 2011 3:33 PM

Reply
7 replies

Jun 26, 2015 10:44 AM in response to keriah

You can certainly script this, and while it may take time to get up to speed learning AppleScript, there are ASC members skilled in scripting who would be willing to assist.


You may also want to take a look at third-party options such as Keyboard Maestro, which has a record function. Keep in mind that UI scripting can at times be temperamental, especially with variable window elements, and requires delays/pauses between some actions to allow time for execution.

User uploaded file

User uploaded file

For straight-up simplicity and recording of keyboard and mouse actions for replay, look at Keyboard and Mouse Recorder. You may need to adjust the speed at which you perform some actions, as controls are spartan.

User uploaded file

User uploaded file

Both apps are available for older versions of OS X and allow you to download and try before purchase.

Sep 10, 2011 7:15 PM in response to keriah

Thanks, Michael & Pierre,

This gives me a lot to look into. (FWIW, I looked at my System Preferences and that "access for assistive devices" was already enabled.)


So, it looks like (from the example) that I will need to write out the script. I think I was hoping that the "Record" function would simply watch my mouse/keyboard movement (clicks and typing) and create those commands for me. I'm thinking that there used to be something that did this (maybe back in OS 9, or earlier??). I did try out the Record button but it didn't seem to "do" anything when I went over to the application I was trying to exercise. Does it matter that that application is a Rosetta app?

Sep 10, 2011 7:24 PM in response to keriah

Does it matter that that application is a Rosetta app?


No, as long as you don't install Mac OS X Lion, it doesn't matter.


Maybe it would also be a good idea to download UIElementInspector 1.4 from this Web page:

http://developer.apple.com/library/mac/#samplecode/UIElementInspector/Introducti on/Intro.html

Just click the Download Sample Code button at the top of the page.

Sep 10, 2011 6:11 PM in response to keriah

In order to record keystrokes etc you first have to "Enable access to for assistive devices", in the "Universal Access" Preference pane. Note that you also need this turned on in order to use this AppleScrpt as well.


Once you have done this, you can create a new AppleScipt, then record the things you do.


It is possible to have the AppleScript turn the "Enable access to for assistive devices" setting on at the start (and restore its setting to what it was before at the end).


Note that what you are recording is exactly the keystrokes, not what they do. That is, the apple events sent to the application are "Pull down this menu, select this item" rather than (open this file). The latter is generally the way AppleScript is 'meant' to work, but it requires familiariity with the particular AppleScript (or Automater) library of the particular application.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Record a series of keystrokes and then replay them

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.