Jump to content

In-Workflow navigation (passing selected option to "myself" or other keyword)


Recommended Posts

Hi folks,


 


I am working on a Alfred workflow that will have elements in different levels to browse through. I would like to call a workflow and show (and filter) the first level elements, then, when choosing one of these elements I want to list (and filter) the sub-elements below this specific top-level element, and so on. At every of the elements I would like to have a secondary option which allows me to do other things with this element instead of jumping into the sub-elements (cmd-click).


 


I now have several questions on which could be the best practices for that to achieve:


 


I have found it very practical to pass the selected element as a „autocomplete“ argument and set the „validity“ to „no“, so when selecting an element, I can pass this one to the very same workflow and display its sub-elements. Very nice, because the Alfred dialog doesn’t disappear from the screen, it just refreshes nicely etc. Unfortunately, when using this variant I have no possibility to go further in the workflow, for example using the cmd-click to do „other things“ with this object. Is there a way to combine these two?


 


Another way of calling one workflow from within itself is an AppleScript:


 



tell application „Alfred 2“


  search „mykeyword „


end tell



 


Unfortunately, I am not able to combine this with the „{query}“ macro. When I use 


 


  search „mykeyword {query}“


 


this doesn’t work. Any idea why? Of course, I can save the {query} into a tmp-file and read this tmp-file afterwards, but this method would make some other things complicated. How can I pass a selection to „myself“ the best way?


 


 


Is there a way to get „back“ to the previous query somehow? Lets say, I am at the level of seeing some sub-elements that I have called somehow (using the method you guys will hopefully suggest me to use to solve the above issue) and I want to get back to see the upper-level elements. The only way seems to be to hit „ESC“, „cmd-space“ „arrow up“, „arrow up“ to use the history function. Is there any better way?


 


 


I hope my questions are not too confusing, but I am unfortunately not yet able to give examples, as I am in a very early stage of developing this workflow.


 


 


Looking forward to any feedback.


 


 


Christian


Link to comment

If I've understood you correctly, you want to be able to "drill down", like browsing the filesystem in Alfred.

 

There's no reason to pass valid="no". Instead use TAB to autocomplete and pass valid="yes". Then you are able to action items in Alfred and pass a {query} to scripts.

 

My own workflows, Smart Folders and MailTo, do this. TAB to complete, ENTER to action (if applicable).

 

It's the idiom that Alfred users are used to: TAB to stay in Alfred's query mode, ENTER to do something else.

 

To get back to a previous level, you typically have to leave the full "path" in the query box, so users can delete their way back up the levels.

Edited by deanishe
Link to comment

Stupid me! I didn't know about the "Tab" autocompleting. Now that I have been told, it's obvious and totally clear to me :)

 

So, that helped me a lot. I will use the Tab key for navigating and drilling down. As an "action" I would like to jump into another workflow that offers me (depending on the type of element I have chosen) different options, such as "jump to it's web site", "delete this entry", and so on. To achieve this, I have to create a second "script filter" and make the move from one action to this script filter. The only way I have seen up to now to achieve this is the above mentioned AppleScript method, which unfortunately seems to not work using the {query} macro. Is there a way handing over data to another script filter using appleScript without having to save stuff into a temporary file?

 

 

Thanks and cheers

 

 

Christian

Link to comment

If you are inputting the code directly into Alfred's Run Script actions, then {query} alone should work. But if you are writing independent scripts that the Run Script is merely calling (e.g. python this_script.py "{query}"), then you could use some form of string formatting. Here's an example using Python and a simple AppleScript wrapper: 

query = sys.argv[1]
a_script = """
tell application "Alfred 2" to search "z:attach %s"
""" % query
res = applescript.asrun(a_script)
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...