Jump to content

How can I pass variables to NSAppleScript (workflow)


Recommended Posts

I'm trying to kick off a keyboard maestro macro from a workflow, and I have a couple variables that get captured during the workflow.  I'd like to have my 'NSAppleScript' action use these, but I'm not sure how.

 

Here is the example applescript with what I *thought* would work.

 

on alfred_script(q)
-- ignoring application responses
tell application "Keyboard Maestro Engine"
   setvariable "alfred_build_product" to "{var:product}"
   do script "Build target (from Alfred)"
end tell
-- end ignoring
end alfred_script
Edited by johnofcamas
Link to comment
I don't think it's possible using Run NSAppleScript. Alfred passes variables as environmental variables to its child processes, but NSAppleScript isn't run in a separate process, so no variables…
 

 

Instead of Run NSAppleScript, use a normal Run Script Action with Language = /usr/bin/osascript (AS). Then you can access your variables thus:

 

setvariable "alfred_build_product" to (system attribute "product")

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