Just about every time I want an AppleScript to wait a second or two during script execution, I instinctively insert a “sleep x” statement, where x is some small number of seconds. Every time, I’m surprised when I test the script and my computer promptly… goes to sleep. The command to use is delay, not sleep :)
—
Here’s a short bit of UI scripting I use to wrangle the MouseZoom prefpane, which I require prior to playing Quake4 to get just the right mouse acceleration curve. Even though it’s just an extra click-and-wait, the whole 32 / 64 bit prefpane shuffle has me kinda annoyed, hence this script.
tell application "System Events"
tell application "System Preferences"
activate
set current pane to pane id "com.benhines.mousezoompp"
end tell
delay 1
tell process "System Preferences"
click button "OK" of sheet 1 of window "Loading MouseZoom…"
--that's an elipsis! accessibility inspector ftw
delay 2
keystroke tab
keystroke tab
keystroke ".02"
keystroke tab
end tell
end tel
