Jump to content

Simple ideas: making hotkeys less hot


Recommended Posts

Background
Do you sometimes want to restrict an Alfred hotkey to work only in one app and not in others? For example, you might want to use Alfred’s Dispatch Key Combo Output to send keystrokes to a specific app but not to any other app. There’s an easy way to do that.

The skeletal workflow
I’ve included this workflow merely as an example. I use it to clear, with a single keystroke, DEVONthink searches and return the focus to the group (in the sidebar) in which the search was made. However, the specifics are not as important as the basic technique.
Skeletal.thumb.png.0d9b1eb04e542fe66f909f5cf0e58d9f.png

Explanation
We start with Alfred’s Hotkey Trigger and set our hotkey. That is linked to an Automation Task to identify the front app (i.e., the app with focus) and to output the name.

We use Alfred’s Conditional Utility to check that the app in which we wish to use the hotkey has focus. The inner workings of the Conditional Utility (revealed by double-clicking on it) are simple and look like this:

Conditional.thumb.png.cc6d239cda713b5bcbd4d8fbd79d3530.png

The result is also simple: unless the output from the Conditional Utility is, in this case, DEVONthink 3 the workflow quits.

All we then need to do is to send to DEVONthink, using Alfred’s Dispatch Key Combo Outputs the sequence of keystrokes we wish to use. Note that we sometimes have to include short Delays in the sequence in order to make it work effectively.

In conclusion
None of this is sophisticated but it’s a good way to use Alfred to automate something in a specific app when you wish to limit your Alfred hotkey to affecting only that app.

Stephen

The Simple Ideas posts

Link to comment

I am ashamed to admit that I had entirely overlooked the Related Apps tab on the Hotkey Trigger <sigh>. That is indeed a much simpler way of achieiving the desired result.

 

For the benefit of those I have ineptly misled here is a screenshot of the Related Apps configuration for my example workflow.

Relatedapps.thumb.png.020cb18d4b23b2b1a82252754b4b3b41.png

 

With that tweak, of course, the Automation Task and Conditional Utility can be deleted and the workflow accordingly much simplified.

 

I guess the only possible advantage of my original workflow is that it would enable you to provide an alternative course of action if using the hotkey in an app for which it was not intended (perhaps to bring the intended app to the foreground, for example).

 

Thanks for pointing out what I had completely missed!

 

Retires in shame.

 

Stephen

Link to comment

Well, developing my previous idea a little you could use a single, memorable keyboard shortcut, for example, to clear the search field in multiple apps—detecting the relevant app and then applying the relevant sequence of keystrokes in that detected app. In other words, the Automation Task would detect the app with focus and the conditional would lead to application of the relevant sequence of keystrokes for that app. All you'd need to recall is that the ⌃⌥⌘C hotkey clears a search field.

 

OK, I'm desperate for redemption…and it's only an idea. 😀

 

Stephen

Link to comment

As (I think) my final contribution to this little saga the original workflow works well if you want to use a single, memorable hotkey combination to perform the same function in more than one app and where that function requires a slightly different combination of keystrokes in each relevant app. By way of example:

Twoapps.thumb.png.d9a0016fd9fa02a117312709cb318ddc.png

 

I knew it had to be useful for something. 😀

 

Stephen

Link to comment

You can remove the Automation Task in this case. Note in your Related Apps screenshot how there’s a checkbox that can be ticked to send the focused app information as a variable directly to the conditional.

Link to comment

I think this sounds like it's been a worthwhile rabbithole and it reminds me of my system.

 

I love the Related Apps hotkey feature (I still wish we could have Related Apps filters for Keyword Inputs too).

 

I maintain 2 primary Alfred invocation shortcuts:

 

'System mode'

Assigned key: I use my hyper-key (⌘⌥⇧⌃) for this which I've mapped to caps-lock (via Karabiner Elements).

 

Function: When this key is single tapped it invokes normal Alfred. When held and then combined with other keys, it becomes a hotkey, performing a slew of different system-wide functions / automations.


'App specific mode' 

Assigned key: I map this to key to F19 and then have a rule in Karabiner Elements that remaps a single press of the command key to F19 (thus, single tapping the command key will invoke the app specific Alfred menu for the currently focussed app.

 

Function: When this key is pressed, it will launch one of many 'App Control' workflows I have, depending on which app is foreground. 

So as I'm working inside an app, I hit command and am presented with a special Alfred menu, tailored with commands specific to the app. 

 

Link to comment

The simple idea here’s is maintaining 2 hot keys. One for system stuff, one for app specific stuff. Maybe I could do a write up of what my personal ‘App control’ workflows do, but the main point here was that they all share a single hoktkey and it feels nice and simple as a system in operation. 

Link to comment
34 minutes ago, Floating.Point said:

Maybe I could do a write up of what my personal ‘App control’ workflows do

 

That could be interesting in its own post, yes. I was intrigued by the idea and thought that could be interesting in macOS itself, having such a special key that would even have a parallel with the new Action Button in recent iPhones. Then I remembered there is such a key, except it’s not as customisable: the fn/globe key on the bottom left can do some interesting things. Try it out in conjunction with a letter, e.g. fn+A or fn+F. I’ll give you a few tips:

  • fn+F toggles app full screen.
  • fn+A highlights the Dock and allows you to navigate it with the arrow keys, and open apps with ↩. Nice!
  • fn+C Opens Control Center. Which is only useful for reference since you can’t navigate it with the keyboard. Not so nice.
  • Not all keys do something.
  • No key should do anything destructive (unless you count fn+⌫ deleting forward), so try away.

But I digress. The explanation on using Karabiner Elements to get more of Alfred would be something I’d read. So there’s at least one guaranteed reader!

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