Jump to content

Get keyword in AppleScript


Recommended Posts

Posted

Potential duplicate: http://www.alfredforum.com/index.php?/topic/133-is-there-a-way-to-get-the-keyword-and-not-just-the-arguments/

 

I have multiple keywords going to a single AppleScript. Is there any way I can get the AppleScript to read which keyword has been used?

 

I have an AppleScript that I wanted to do things dynamically depending on the keyword that was entered. Preferably, I would like to do this without using arguments, as I only want to have to type in one keyword to run the script.

Posted

As far as I know it's not possible to read the keyword. However, you could have each keyword run a bash script that sends a keyword to an applescript:

 

osascript scriptname.applescript keyword

 

You'd then just open the workflow folder and create the applescript file there. To get it to read the keyword, you'd use something like this:

 

 

on run argv
    set theKeyword to item 1 of argv

    -- your script here
end run

 

It's not as elegant as I'd like, but hopefully it'll work for you.

Posted

Awesome! I'm probably being stupid but when I run `osascript test.applescript keyword` from terminal, I get:

 

test.applescript:53:78: execution error: No user interaction allowed. (-1713)

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