Jump to content
syno

Passing a string to NotificationCenter with Run NSApplescript

Recommended Posts

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?

Share this post


Link to post

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`

Share this post


Link to post

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.

Share this post


Link to post

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?

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...