Why Does Clicking on Applescript Notifications Open the AppleScript Editor?

I'm experimenting with AppleScript and with Python. But the big issue i'm having now is not about Python specifically. The end goal is to be able to write Python scripts that use AppleScript features. While doing this, I'm testing in AppleScript, from the command line, and in IDLE.

If I type:

osascript -e 'display notification "Lorem ipsum dolor sit amet"'

in bash in the Terminal and run it, I get a Growl notification, but when I click on it, the Applescript editor opens up. If it's open but not active, it becomes the active application. If I create the following AppleScript file:

on run display notification "This is a notice." end run

And run it with osascript from the Terminal, when I click the Growl notification, the Script Editor opens. And the same thing happens when I use osascript in Python to run the same command.

In other words, if I use AppleScript to post a Growl notification, it always opens up the AppleScript Editor.

(I've been trying a number of sample scripts online and it appears that, at some point, maybe with Mavericks, a lot of rules for Applescript and Growl changed, since many scripts, when cut and pasted and saved, will no longer work.)

(I'm on OS X 10.9.4.)

Why does the Script Editor open? And what can I do to stop this?


(I've also asked this on a StackExchange site here: http://superuser.com/questions/782814/why-does-clicking-on-applescript-notificat ions-open-the-applescript-editor)

Posted on Jul 14, 2014 9:26 AM

Reply
6 replies
Sort By: 

Jul 14, 2014 10:57 AM in response to HalNineThousand

First, the display notification command has nothing to do with Growl: it's a part of the Standard Additions osax that uses the user notification center that's built into Mavericks. I have no idea what changes Growl has undergone since the user notification center was incorporated, but I imagine they are significant, and that many of your scripts will need to be rewritten from scratch.


As for the main question, the Script Editor is the default application for applescripts, so when you launch a notification from an applescript it will assume that the action of the notification points back to the Script Editor. This will be true even if you launch the notification from osascript (since the system will still consider it a script). I don't know of any way around this - encasing the command in a tell block doesn't help, at any rate.

Reply

Jul 14, 2014 12:20 PM in response to twtwtw

My bad about Growl - it took a while for me to separate Growl and just plain notifications and documentation is not always as clear as it can be.


So, as I understand it, any AppleScript use of a normal notification will mean, when I click on it, that it will want to go to the Script Editor (unless I can find a way to go to some other application - in which case, it'll still open some application or switch to the Finder when I dismiss the notification).


If I add Growl, can I create notifications in AppleScript that use Growl that don't automatically open an application?

Reply

Jul 15, 2014 9:10 AM in response to HalNineThousand

HalNineThousand wrote:


So, as I understand it, any AppleScript use of a normal notification will mean, when I click on it, that it will want to go to the Script Editor (unless I can find a way to go to some other application - in which case, it'll still open some application or switch to the Finder when I dismiss the notification).


If I add Growl, can I create notifications in AppleScript that use Growl that don't automatically open an application?


In vanilla applescript, that is the case. Applescript's notifications support is sparse. If you want to switch to applescript-objc you can get more control over notifications, including choosing the action that occurs when a notification is clicked. ASOC requires snow leopard or later (or Mavericks if you want to create a script library for more versatility). I can pound out an asoc script later if that's out of your skill-set (or someone else may do it; on my way to a meeting right now).


I haven't looked at Growl in a few years, so anything I might say about it is out of date. You should check their webpage.

Reply

Jul 15, 2014 11:20 AM in response to HalNineThousand

I wonder if 'Terminal notifier' helps with any bash/ python scripts…

https://github.com/alloy/terminal-notifier


The manual has these two nuggets…

-open URL The URL of a resource to open when the user clicks the notification.

-execute COMMAND A shell command to perform when the user clicks the notification.


Could be worth a look.

I have used it with scheduled bash scripts.

Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Why Does Clicking on Applescript Notifications Open the AppleScript Editor?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.