Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
    
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 Answer 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:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.