0
votes

I'm new to AppleScript but I do have some basic knowledge of Automator. Here is what I want to achieve:

  1. There is a simple list of URLs that I often use throughout my work. Like this:

Product datasheet: URL1

Licensing: URL2

Price list: URL3

...

etc.

In most cases I use these URLs when sending a mail message to a customer, but sometimes I also use them in other applications, like Safari. So the service should be global.

  1. I need the service to prompt me with a list of items where each item is the name of a link (like {"Datasheet", "Price list", "Licensing", etc} ).

  2. When I select an item and click OK, the service must fetch the URL that corresponds to that link name and then put it in the clipboard, so that I can paste it whenever I need to use it.

I followed recommendations in this q&a Automator: How do I use the Choose from List action? and created the first action (Run AppleScript). Also, i created a number of variables and specified names and URLs. I.e. I'm going to store the actual list ("database") in the service. There are somewhere between 30 and 50 links/records in total so I don't probably need an external Excel file or something.

What I can't figure out is how to get/fetch the URL from the variable. The Get Value of Variable doesn't work for me because it requires a constant variable name as input. However, I need an action to receive input from the Run AppleScript action, lookup the variables list and fetch the URL and then pass the resulting URL onto the Clipboard action.

Thank you for your help.

1

1 Answers

0
votes

Make an automator service workflow with a single Run AppleScript action, containing the following code:

set x to item 1 of (choose from list {"Product datasheet", "Licensing", "Price list"})
if x is "Product datasheet" then
    set the clipboard to "URL"
else if x is "Licensing" then
    set the clipboard to "Another URL"
else if x is "Price list" then
    set the clipboard to "Yet Another URL"
end if

To add to this, add to the list of items on the first line, copy the else if line and edit it to check for the newly added item, then copy the set the clipboard line and edit it so that it contains the new URL.

Also, make sure that you set the workflow to work in "any application" and you should also set it to receive "no input".