Jump to content

script filter + optional argument help

Recommended Posts

I've got a workflow I'm quite happy with but I'm running into a problem trying to add some new functionality. I think I don't fully understand the limitations of script filters or maybe even how they are supposed to work.


Here's what I'm trying to do:


Each time I run my workflow, I store the query value in a text file. I'd like previous values to be populated from a script filter so I can either select one of them or type in a new query value. I've got the argument set to optional and I can get the previous values to populate just fine. I can select one of them by hitting return of selecting one with a command-key number.


What I can't do is type in a new query value. Every time I do and then hit return, I end up selecting whatever is the first of the previous values listed by Alfred in the results.


What am I doing wrong? Am I even using the script filter input correctly?

Link to comment

Script filters are for searching. They don't naturally have the flexibility you describe. But, you could add this flexibility by creating a "search result" that is always at the top of the results which will accept the new query and then pass that to the next script. I'm not certain what language or library you are using for your background code, so I can't get specific with helpful details, but the general idea is to have a "result" that always appears at the top of the filter (don't use id's in the xml, so that Alfred won't log chosen results and reorder things), then set its arg to the inputted query. That will allow you to pass the query to the next action after the filter.

Link to comment

Yes, you can use a script filter like this. Script filters are great for many types of programming. But, when you hit enter, the item selected is the one that get actioned. You need to make sure there is one created for just your current input. And then make sure it is selected before hitting enter. You could write the Script Filter to not show past ones if you are typing anything. Or, as you type in queries, compare them to the others and only show the ones that match the comparison. 


This article shows ways to make this work: http://computers.tutsplus.com/tutorials/alfred-workflows-for-advanced--mac-60963

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