Re: How Can I Get a Launch Agent which is a Script to Talk to Me?
Re: How Can I Get a Launch Agent which is a Script to Talk to Me?
- Subject: Re: How Can I Get a Launch Agent which is a Script to Talk to Me?
- From: Axel Luttgens <email@hidden>
- Date: Mon, 05 Oct 2015 16:27:53 +0200
> Le 5 oct. 2015 à 11:56, S. J. Cunningham a écrit :
>
> […]
>
> Axel,
>
> Thanks. Sure. Here's the plist I put in ~/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>KeepAlive</key>
> <false/>
> <key>Label</key>
> <string>com.example.exampled</string>
> <key>ProgramArguments</key>
> <array>
> <string>osascript</string>
> <string>/Users/sjc/Desktop/exampled.scpt</string>
> </array>
> <key>RunAtLoad</key>
> <true/>
> </dict>
> </plist>
>
>
> and Here's the Launch Agent I put on the desktop:
>
> beep -- this works
> say "example d finished" using "Alex" -- this works
>
> display dialog "exampled finished" -- this doesn't
>
> And here's the shell command to load:
>
> launchctl load Library/LaunchAgents/com.example.exampled.plist
>
>
> Works fine except the "display dialog" is never executed and the following error appears in the console log:
>
> 10/5/15 5:44:31 AM com.example.exampled[7799] execution error: --> No user interaction allowed. (-1713) <--
> 10/5/15 5:44:31 AM com.apple.launchd.peruser.502[149] (com.example.exampled[7799]) Exited with exit code: 1
Thanks for the details, Steve.
So, your agent is a script run thru osascript.
You’ve already got some feedback about the limitations of osascript wrt "user interaction" before Mavericks.
Anyway, I quickly tried the following on 10.6.8:
- save this one as application "exampled.app" from Applescript Editor:
tell me to activate
display dialog "exampled finished"
- in the plist, change the ProgramArguments key:
<key>ProgramArguments</key>
<array>
<string>/Users/sjc/Desktop/exampled.app/Contents/MacOS/applet</string>
</array>
At each logout/login, the "agent" seems to happily display its dialog.
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden