Jump to content

Can't get query in osascripts


Recommended Posts

Hello!

 

I'm working with my first workflow. At the end of it (in Output), I need to launch an Applescript with some input. The only option I have found to do it is by Run Script with /usr/bin/osascript as interpreter. I know NSAppleScript Action, and there you can get inputs with the variable 'q', but how can I do it with osascript interpreter? NSAppleScript is only an Action and it isn't available as an Output. I've already tried using 'on run argv' with no luck. Input is always empty.

 

Could anyone help me?

 

Thanks in advance!

Link to comment

Hello!

 

I'm working with my first workflow. At the end of it (in Output), I need to launch an Applescript with some input. The only option I have found to do it is by Run Script with /usr/bin/osascript as interpreter. I know NSAppleScript Action, and there you can get inputs with the variable 'q', but how can I do it with osascript interpreter? NSAppleScript is only an Action and it isn't available as an Output. I've already tried using 'on run argv' with no luck. Input is always empty.

 

Could anyone help me?

 

Thanks in advance!

 

They are both ways of running AppleScripts with Alfred. The difference is, NSAppleScript would block Alfred from doing anything else if it was a long running script.

 

For NSAppleScript, you would wrap your script in on alfred_script() like..

on alfred_script(q)
  // your code here. input available through variable q
end alfred_script

 

Using Run Script and setting the language to osascript runs the script in the background and won't block Alfred from performing anything else. Input to a Run Script is available through {query} the same as other scripts. Example.

set temp to "{query}"
return temp
Link to comment

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...