1

I want to have an alert / dialog box to fire up periodically in foreground on my Mac.

I tried a combination of AppleScript and launchd and managed to have the script (actually converted to a app) fired up periodically via launchd. However, the alert box does not show up in front of all other windows (rather totally hidden until I tab to it – though it does get started via launchd). How can I get it in front?

My script is as follows:

on run
    activate me --> tried to get alert in foreground
                --> didn't help, though
    display alert "Should show up in foreground..."
end run

My launch.plist is (in /Users/bernhard/Library/LaunchAgents/):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>bernhard.sitstraight.plist</string>

    <key>Program</key>
    <string>/Users/bernhard/programming/periodic.app/Contents/MacOS/applet</string>

    <key>RunAtLoad</key>  
    <true/>

    <key>StartInterval</key>
    <integer>1200</integer>
</dict>
</plist>

1 Answer 1

0

Got an answer on Ask Different:

The solution is to open the app, which seems to be more like a double-click on the app icon. That is, one has to replace the program to be called by /usr/bin/open and pass the app as an argument as follows within the launchd.plist:

<key>Program</key>
<string>/usr/bin/open</string>
<key>ProgramArguments</key>
<array>
    <string>open</string>
    <string>/Users/bernhard/programming/periodic.app</string>
</array>

The first argument (in this case open) actually gets passed as argv[0] and, hence, is not relevant here. The actual first argument then is /Users/[...]/periodic.app – the app directory rather than the actual binary.

You must log in to answer this question.

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