Jump to content

Context sensitive keywords


Recommended Posts

Summary: Requesting context sensitive Keywords - just like the Hotkey's related apps

--- 

More and more I am using Alfred to automate activities within the apps I use daily. Running scripts, loading workspaces, modal menus, macros etc - all context sensitive to the foreground application. While I love putting Alfred to use in this way, my implementation lacks one of Alfred's features I find most valuable… the keyword.

 

I wish there was a way to have something like the 'related apps' function from the hotkey input available for keywords. This would allow the same keyword to do different things depending on the foreground app. For example executing the keyword 'align' would do one thing if Photoshop is foreground, and something completely different if Cinema 4D is foreground.

 

What I love about Alfred is I don't have to remember myriad different keyboard shortcuts to automate my workflows, so if it were possible to have context sensitive keywords, the whole system would become a little more flexible :)

Link to comment
Share on other sites

Making Keywords context sensitive is trickier than for Hotkeys. Invoking Alfred and typing only not to see some results could be confusing and lead to unnecessary bug reports. Prioritising Keywords depending on context might be best, but may not fit with Alfred’s learning.


Right now, there’s two ways to achieve what you want:


The first is to have multiple Keywords with the same text. At the time, you chose the relevant one (a good icon will help there).


The other requires a couple of objects:

  1. Make a Keyword Input.
  2. Connect it to a Run Script Action with Language set to /bin/bash and Script set to osascript -e 'tell application "System Events" to return name of first process whose frontmost is true' | tr -d '\n'. This will return the name of the frontmost app.
  3. Connect that to a Conditional Utility and set is equal to to the names of the apps you want to affect.
  4. Then connect those to the appropriate actions.


If your Keyword takes input, you may have to add an Argument and Variables Utility in there to save it.

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...