Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like a method for starting a program when another program starts. Specifically, I’d like a to open a MS Word document and have my citation manager open simultaneously (EndNote supports this function within MS Word preferences, but I recently switched citation managers).

I’d like to be able to open any existing Word document on my drive and trigger the second program. The same question was recently answered for the windows 7 environment.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Try saving a property list like this as ~/Libary/LaunchAgents/test.plist and loading it with launchctl load ~/Libary/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>-e</string>
    <string>tell application "System Events"
    set p to name of processes
    if p contains "TextEdit" and p does not contain "Mail"
    do shell script "open -gja Mail"
    end
    end</string>
    </array>
    <key>StartInterval</key>
    <integer>10</integer>
</dict>
</plist>

open -j (--hide) was added in 10.8. open -jg sometimes opens a new visible window if an application is running but has no open windows.

If StartInterval is 9 seconds or less, the program just gets throttled.

com.apple.launchd.peruser.501[128]: (test) Throttling respawn: Will start in 7 seconds
share|improve this answer
add comment

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.