AutoType / AutoClick

Tools for macintosh input automation!


Applescript is a really great way to control your mac! Unfortunately many many applications still aren't scriptable. Thats why you need AutoType. It allows you to control even non-scriptable applications from within Applescript. Using AutoType you can send simulated key strokes to the front application. This means you can control dialog boxes, hit menu short-cuts, or do anything else that can be done from the keyboard. AutoClick allows you to send simulated mouse clicks to any spot on the screen.


Note, AutoType is now free. 


Download trial version (A-Z keys only) -

autotype.unreg.hqx

Download complete version -

autotype.reg.hqx


FAQ

Where can I get additional help?

I'm quite happy to help with problems you have with AutoType, but I'm definitely not an Applescript expert. I don't use it myself. Good places to get additional help are:

Does it work with OS X?

I've had reports that it does not. I have no personal experience. I'm interested in anyone who got it to work. I'd be willing to make the source available to someone who wanted to port it. I have no idea whether this would be a difficult task, since I don't know about the new system architecture.

Why doesn't this key with lots of modifiers work?

Let take an example from a user:

>>I think I may have found a limitation in the Autotype scripting
>>addition. I'm writing AppleScripts for QuickTime Player Pro 4.1 which
>>has a limited set of AppleScript commands. My script is to automate
>>the adding of a QuickTime movie into another QuickTime movie using
>>either Add (Option-Command-V) or Add Scaled (Shift-Command-Option-V).
>>
>>Add works fine (Autotype "V" holding "Option Command"), but the Add
>>Scaled (Autotype "V" holding "Shift Option Command") does not.

And the solution from Sal at Apple:

this works for adding scaled:

tell application "QuickTime Player"
        activate
        AutoType "`#118" holding "command shift option"
end tell
 

When you give a direct sequence of letters, autotype assumes these are the right ascii codes and passes them through in the event record. It also sets the event record flags for the modifier keys you specify. When you use the keycode method of specifying a key, then autotype uses the current keyboard definition to determine the correct ascii value. In some cases the behavior can be different. If you don't get what you want, try specifying in several different ways. See the docs that came with autotype for more details on specifying things in this way.

Why doesn't the first character work?

For some reason, when you use OSA Menu and AutoType together in some applications, the first character or so gets dropped. Many people have just padded the comand with a dummy character, and things work fine. Another solution is to surround the Autotype command with a 'tell app finder; autotype; end tell', even though the command is destined for something other than finder. This fixed the problem for me.
 

Can Autotype control a remote machine?

You can use AutoType over the network, if you have AS and AutoType on the remote machine. Use something like
tell application "finder" of machine "X" of zone "Y"
autotype
end tell
You should be able to send to the finder regardless of the destination front app.
 

How do I know what screen coordinates to use with Autoclick?

Since several people have asked. I use SmartMouse to find coordinates for use with AutoClick. I think smartmouse crashes some newer macs though, so Delta-XY was recommended to me.

http://www-graphics.stanford.edu/~jedavis/projects/mac/smartmouse.hqx
http://www-graphics.stanford.edu/~jedavis/projects/mac/delta-xy-271.hqx
 

How can I send coordinates relative to the front window?

From a user: -----
By the way, I found a very nice technique for AutoClick. The Akua
Sweets OSAX's "reposition window" command, called with no parameters,
returns a window's bounds...take items 1-2 of that as {x,y}....and then
use some utility like deltaxy to find the position {x2,y2} of some
control within its window....now, just AutoClick {x+x2,y+y2}, and you've
got a fully (mostly) portable way to click buttons, check boxes, radio
buttons, close & zoom boxes (those can probably even be generalized for
EVERY window), and everything else. Kind of like PreFab, but without the
$139 fee...
--------
 

Is there a way to pick menu items without key equivalents?

You can reach some menus that don't have command key equivalents by using a utility called KeyMenu. It is an init that lets you hit any menu from the keyboard. I've used it to for example reach a 'Save As...' menu item with Autotype.

http://www-graphics.stanford.edu/~jedavis/projects/mac/keymenu.hqx
I've also been told that

" Just wanted to inform you that Speed Doubler (or at least the version I 
have, v8) also lets you access menus with the keyboard. It's commercial, 
but many people have it, so you should probably add it to your AutoType 
FAQ. Also, there's an AS Addition called MenuEvents (check for it on 
MacDownload) that lets me access menus directly from my script.  "

 

Why doesn't Autotype work with my dialog box?

The most common answer to this question is as follows:
-- Example of doing it WRONG
tell application "foo"
  activate
  autotype "S" holding "command"
  autotype "myfile"
  autotype "`return"
end tell


-- Example of doing it RIGHT
tell application "foo"
  activate
end tell
autotype "S" holding "command"
autotype "myfile"
autotype "`return"
You can not put the autotype calls inside a 'tell application' block. To understand why this is true you need to think about the flow of CPU control. The applications on your macintosh share CPU resources in a cooperative manner. One application gets an event, processes it, and then asks for another. Whenever an application asks for another event, the MacOS might let some other application do some work before returning control. But when an application is sitting in a dialog box, typically it only knows how to handle typing events, and ignores all others until the dialog box is finished. If you have told an application to run a script for you, then all processing of that script stops until after the dialog box. The key then is to make sure the application running the script is not the same one receiving the typing and bringing up dialog boxes. So don't tell application foo to perform the autotype commands, something else should do that. The applet, the script editor, the finder, anyone else. The following example might help someone.
Script Editor                  Application Foo
-------------                  ---------------
Start running the script
tell application foo
Send event activate to foo
Check for next line/event
                               Recieve the activate event
                               activate
                               Brings itself to front
                               Check events
end tell
autotype "s" holding "command"
                               Invoke Save Dialog
                               Check typing events only
autotype "myfile"
                               "myfile" is typed
                               Check typing events only
autotype "`return"
                               Close save dialog
                               Check all events
Now lets consider what happens in the wrong case
Script Editor                  Application Foo
-------------                  ---------------
Start running the script
tell application foo
Send event activate to foo
Check for next line/event
                               Recieve the activate event
                               activate
                               Brings itself to front
                               Check all events
Send autotype to foo
                               autotype "s" holding "command"
                               Check all events
                               Invoke Save Dialog
                               Check typing events only

                               Foo is looking for typing and
                                 doesn't know how to handle the next
                                 autotype event at this point so
                                 it just sits waiting

 

Autotype still doesnt work with my dialog box!

Some dialog boxes, like the 'Replace/Cancel' mini box if you try to save over a file, are poorly behaved. Meaning they don't let other applications get any processing time, so no matter who is running your script, it doesn't get a chance to do anything after the box comes up. The only solution I know of, which works sometimes, is to try and sneak in the typing before the box comes up. Maybe include it with the previous autotype command which caused the box to appear.
 

I need the keyboard key-codes. Where is IM V-192?

Ok, so my copy was printed in 1986. Its definately been replaced by newer versions of
Inside Mac. To make sure you are looking at the same thing as I am, here's a scan of my book.
keyboard.gif
 
 

How do I pay you?

You don't anymore. I asked for payment in the past when I was a student. 

Kagi
Kagi is an online payment processing service. They can accept payment by credit card, and many users outside the US find this to be the most convenient way to get money to me.

http://order.kagi.com/cgi-bin/r1.cgi?IEK

postal mail
James Davis
376 Gates Building
Stanford CA 94305

I'll take checks that pay in US$, or cash from anywhere in the world. US$ cash
is probably the easiest for me, but suit yourself.


James Davis - jedavis@cs.stanford.edu