0

I want to do two things when my Mac boots up:

1) Run an app
2) Click a button on that app

Any suggestions for how I can accomplish this? FWIW, this is app I haven't written so I can't change source or pass in command line params.

  • The run part is reasonably simple. Right (alt) click the app in the dock, mouseover "Options", select "Open at Login". – bassplayer7 Dec 7 '12 at 20:10
1

Save a script like this as ~/Library/Scripts/test.scpt in AppleScript Editor:

tell application "Grapher"
    activate
    reopen
end tell
tell application "System Events" to tell process "Grapher"
    click radio button 2 of tab group 1 of window 1
    -- UI elements of window 1
end tell

Save this as ~/Library/LaunchAgents/test.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>test</string>
    <key>ProgramArguments</key>
    <array>
        <string>osascript</string>
        <string>/Users/username/Library/Scripts/test.scpt</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

More information about UI scripting and launchd:

You must log in to answer this question.

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