Jump to content

Help with "choose from list"


Recommended Posts

I'm making my first workflow.  It's fairly simple: it will allow me to set the status of my IM clients (both Skype and Adium) to Away, Meeting, DND or Available all at once, as well as pause or play iTunes (based on the status).

 

The bit I'm having trouble with is:

 

set imState to {"Available", "Away", "Meeting", "Do not Disturb"}
choose from list imState with prompt "Choose the Status..." default items "Available" OK button name "Set" cancel button name "Cancel"
set imState to result as string
 
The shows the right prompt and everything works correctly.  However, the dialog that pops up is not in focus, so I have to click on it, select my selection and click Set.  If I can force it to be in focus, I can arrow down to the status I want and press enter to set it.
 
If someone can point me in the right direction, I'd be a happy guy.
Link to comment

Applescript dialogs get to be a bit wonky with focus. Why not just write the first part as a script filter so that you can set the argument from Alfred?

 

Basically you'd just need a script filter that would pass the argument to the Applescript that you use to control things. You can do something much more elegant than this, but, at minimum, just have a script filter set to "PHP" and paste this in it.

echo "<?xml version='1.0'?>";
echo "<items>";
echo "  <item uid='available' arg='Available' valid='yes'>";
echo "    <title>Set Status to `Available'</title>";
echo "    <subtitle>Set for both Adium and Skype</subtitle>";
echo "    <!-- <icon>iconfile.png</icon> -->";
echo "  </item>";
echo "  <item uid='away' arg='Away' valid='yes'>";
echo "    <title>Set IM status to `Away'</title>";
echo "    <subtitle>Set for both Adium and Skype</subtitle>";
echo "    <!-- <icon>iconfile.png</icon> -->";
echo "  </item>";
echo "  <item uid='meeting' arg='Meeting' valid='yes'>";
echo "    <title>Set IM Status to `Meeting'</title>";
echo "    <subtitle>Set for both Adium and Skype</subtitle>";
echo "    <!-- <icon>iconfile.png</icon> -->";
echo "  </item>";
echo "  <item uid='dnd' arg='Do not Disturb' valid='yes'>";
echo "    <title>Set IM Status to `Do not disturb'</title>";
echo "    <subtitle>Set for both Adium and Skype</subtitle>";
echo "    <!-- <icon>iconfile.png</icon> -->";
echo "  </item>";
echo "</items>";

If you want to use an icon, then uncomment the icon part of the xml, and replace it with your own icon file stored in the workflow folder.

 

After that, just put a script action, and then what is selected will be available in the "{query}" variable later.

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