Jump to content

Passing a string to NotificationCenter with Run NSApplescript


Recommended Posts

Posted

I was encountered a strange problem with my workflow.

I want to use Run NSApplescript to pass a string to NotificationCenter.

So I wrote in Run NSApplescript as follows.

 

set q "foo"

return q

 

And in Post Notification,

 

Text: {query}.

 

But the text field in NotificationCenter is empty.

 

I also tested the case passing a number.

 

ser q 0

return q

 

Then NotificationCenter correctly showed 0 in the text field.

 

What is wrong with the former case?

Posted

I'm not sure why the second one works…

I do know your AppleScript should read `set q to "query"`. Your second declaration should likewise read `set q to 0`

Posted

Thanks Tyler Eich.

 

You are right. They are just my typos.

The correct scripts I wrote are

 

set q to "foo"

 

or

 

set q to 0.

 

The first one didn't work as I wish.

Posted

Thanks Tyler Eich.

 

You are right. They are just my typos.

The correct scripts I wrote are

 

set q to "foo"

 

or

 

set q to 0.

 

The first one didn't work as I wish.

 

So everything works now?

Posted

No. set q to "foo" don't work. Strictly speaking, the query which Post Notification receive is empty.

 

Does your code read like this?:

on alfred_script(q)
  set q to "query"
  return q
end alfred_script
Posted

In that case the notification panel appears and the variable query in Post Notification is empty.

But I don't know the script is working correctly because coding error doesn't prevent appearing a notification panel.

  • 3 months later...
Posted

Run Script worked but Run NSAppleScript didn't.

 

 

I'm running the test workflow and I get the same issue.

 

NSApplescript doesn't seem to send anything to the Notification.

 

For the NSAppleScript, the code should be the following...

on alfred_script(q)
  set temp to "sample"
  return temp
end alfred_script

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...