Jump to content

Overlapped hotkey for different apps in one workflow?


Recommended Posts

I’m creating a workflow of the same function w.r.t. different browsers depending on which browser is being used, so I set the same hotkey for the links between browser apps and their corresponding AppleScripts.  It can work though the workflow highlights the hotkey is overlapped, so I’m wondering is there any better solution?

 

Note that we cannot link one hotkey to two AppleScripts here otherwise it will work on two browser apps simultaneously, which is unnecessary.

 

 image.png.be56fc56b4634e7c9e5b8f6a3893ad25.png

Edited by realliyifei
Link to comment
13 minutes ago, realliyifei said:

so I’m wondering is there any better solution?

 

No, this is how you're supposed to do it. Alfred's warnings about duplicate hotkeys aren't particularly smart and don't consider when or if they're active. Just because it's orange doesn't mean there's an actual problem. You have to check manually, I'm afraid.

 

13 minutes ago, realliyifei said:

Note that we cannot link one hotkey to two AppleScripts here otherwise it will work on two browser apps simultaneously

 

Not so. Alfred can set an environment variable to the bundle ID of the active application. You can use the variable in your script to run different code for different applications.

 

Also, don't use Run NSAppleScript. Use Run Script with Language = "/usr/bin/osascript (AppleScript)" instead. Run NSAppleScript behaves weirdly, and nobody really knows why. It's best to avoid it if possible.

Edited by deanishe
Link to comment

Thanks! I switch to Run Script now. But I fail to figure out how to set the app env var in the Alfred for conditional action?

 

Here’s my workflow demo:

 

image.png.a574d7dfa6b9875176e3ac6f2fa90ba3.png

 

image.thumb.png.68babb2b9d6106037819694995fafc87.png

 

with the apple script

-- Safari
tell application "Safari"
	set tab_idx to index of current tab of front window
	close (every tab of front window whose index is not equal to tab_idx)
end tell

-- Chrome
try
    tell window 1 of application "Google Chrome" to ¬
        close (tabs 1 thru (active tab index - 1))
    tell window 1 of application "Google Chrome" to ¬
        close (tabs -1 thru (active tab index + 1))
end try

```

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