Jump to content

Using Alfred to dispatch a hotkey


Recommended Posts

Since the Alfred-Maestro workflow doesn't work on my M1 Mac mini, I began using Keyboard Maestro's "Trigger Macro by Name" macro to find and execute Keyboard Maestro macros. However, I can't remember the hotkey for this, and would rather just execute this function from Alfred.

 

So I made a workflow, triggered by keyword 'km' which then feeds into a Dispatch Key Combo instance which issues the hotkey to trigger the Keyboard Maestro "Trigger Macro by Name" macro. Simple!

 

I have attached a screenshot of the workflow definition in Alfred.

 

But it doesn't work. I figured out that I had to disable the hotkey for the macro, then set up the hotkey to dispatch, but the dispatch hotkey output function doesn't do anything. 

 

And yes, I did re-enable the Keyboard Maestro hotkey. I even changed the hotkey a couple of times. Currently the hotkey is set to F11 and it brings up the Keyboard Maestro macro properly when used. However, when I try to invoke this from my workflow, it just does nothing. 

 

What am I doing wrong?

 

Screen Shot 2021-01-22 at 9.48.55 AM.png

Link to comment

I read another post that suggested I remove Alfred from privacy settings and then put it there again. No joy.

 

It is also true that this is not a general failure. If I used the same workflow, but change the hotkey to be one that is used in Scrivener, for example, Alfred properly issues the hotkey and the key is accepted by Scrivener. But I can't get anything to happen (other than a faint sort of beep) when I try the hotkey for Keyboard Macro to run a macro.

 

And, to reiterate, I am running this on an M1 Mac mini, with Big Sur 11.1. 

Link to comment

Okay, I have solved the immediate problem of running the Keyboard Maestro macro "Trigger Macro by Name". 

 

Instead of trying to run the macro by sending the hotkey, I found that Keyboard Maestro will create an apple script that will run the macro. So I changed my workflow to run the script and it works properly.

 

I still would like to understand why using the hotkey method doesn't work.

Link to comment

@deanishe simulating F keys should work as expected - I just did a test of a keyword connected to F5, and when using this keyword, macOS correctly shows the list of suggested words for the selected word being edited.

 

@tbrown Alfred needs Accessibility access to dispatch key combos - if Alfred is listed in the Accessibility section, is the lock command working in Alfred? This will test if Alfred can dispatch the key combo to lock your Mac. If not, you may need to look at resetting the accessibility prefs with tccutil.

Link to comment
57 minutes ago, Andrew said:

I just did a test of a keyword connected to F5

 

It works fine if the shortcut is assigned by the active application. It doesn't work if it's a (non-system) global assignment. Try assigning Alfred's hotkey to F5 and then simulating it with Alfred.

 

Pressing the physical key or using key code in AppleScript, in contrast, always trigger the global assignment regardless of what the active application has assigned.

Edited by deanishe
Link to comment

@Andrew Yes, the lock command works when invoked from Alfred. I don't think this is an Accessibility issue.

 

@deanishe I'm not sure how you define "(non-system) global assignment". I played around a bit and found, for example, that on my system, I can invoke the screenshot function by dispatching Shift-CMD-5 with the Alfred workflow, but I cannot invoke Mission Control by dispatching the Ctrl-UpArrow key sequence.

 

So, it's all a bit odd to me.

 

Link to comment
1 hour ago, tbrown said:

I'm not sure how you define "(non-system) global assignment".

 

Like your F11 shortcut to launch KM's "Trigger Macro by Name". It's not defined by macOS, therefore "non-system", and it's active also when KM isn't the focussed application, therefore "global". (Contrast with F11 being bound to "fullscreen" in Firefox.)

 

I wouldn't claim that's a definitive description of the issue, and I was only talking about F-keys. Interesting that you've found another that doesn't work. Perhaps @Andrew knows what they may have in common?

 

Edited by deanishe
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...