Jump to content

How can I run a hotkey as output?


Recommended Posts

Hi,

 

I'd like to remap keys using Alfred Workflow. So when I press a specific hotkey (e.g. Shift+left arrow) as trigger that Alfred outputs a different hotkey (e.g. Ctrl+Shift+Tab) as output. Setting the hotkey trigger as input is no problem but I could not find an option in Alfred for a hotkey output.

 

Won't this work as Alfred Workflow?

Link to comment

Hi,

 

I'd like to remap keys using Alfred Workflow. So when I press a specific hotkey (e.g. Shift+left arrow) as trigger that Alfred outputs a different hotkey (e.g. Ctrl+Shift+Tab) as output. Setting the hotkey trigger as input is no problem but I could not find an option in Alfred for a hotkey output.

 

Won't this work as Alfred Workflow?

 

Alfred doesn't currently have this but you could use a Run Script item after the hotkey, set the languages to AppleScript and use AppleScript to simulate the hotkey. Would that work?

Link to comment

Thanks David! I'd have loved a simple way but I guess I have to use an Applescript. Would this be correct, if I want to use it within Safari?

tell application "Safari"
keystroke "TAB" using {control down, shift down}
end tell

In Alfred I've set the Trigger hotkey as "Shift+left arrow" and only be active when Safari is focused.

Link to comment

Thanks David! I'd have loved a simple way but I guess I have to use an Applescript. Would this be correct, if I want to use it within Safari?

tell application "Safari"
keystroke "TAB" using {control down, shift down}
end tell

In Alfred I've set the Trigger hotkey as "Shift+left arrow" and only be active when Safari is focused.

 

You MAY have to use System Events to send it. I also did it with a menu item instead of the hotkey because.. my iMac is being kinda quirky right now. It also won't let me copy and paste text right now (its having a case of the Mondays). This code works on my laptop though.

tell application "Safari" to activate
tell application "System Events"
    tell process "Safari"
        click menu item "Show Previous Tab" of menu 1 of menu bar item "Window" of menu bar 1
    end tell
end tell
Link to comment

You're quite likely to run into problems trying something like this.

 

This issue is that the app receiving the keystrokes can't tell the difference between the modifiers specified in the AppleScript and the ones you're currently holding down to activate the workflow action via Alfred.

 

That is to say, if you set up a hotkey in Alfred, say CMD+SHIFT+A, to send CMD+ALT+S to an application, the application will register CMD+SHIFT+ALT+S because you've probably still got your finger on the SHIFT key.

 

You should make sure that the modifiers you assign in Alfred are the same as, or a subset of the modifiers you want to send to the application.

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