3

How can I bring a specific window or program forward (and "active) with a single keyboard shortcut?

I wrote an AHK script to do this on Windows: I would hotkey a window to Win+1 for example, and then whenever I pressed Win+1, I would activate that window.

I want to do the same thing in MacOS now. I have a few frequently used Windows I would like to access deterministically: "You press X hotkey, you get Y window--every time."

Example: Slack. Slack only has one window, so it should be simple.

On Windows, I got a bit fancy because sometimes I wanted one Chrome window out of the lot, so I would make Ctrl+1 "set" the currently active window to be raised whenever Ctrl+1 was pressed, but for the first iteration, I just want to do single-window applications (or every window from an application--whichever is easier).

Detail: when I bring the window "forward", I want to be able to type in that window without also having to click on it. It should be fully "active" as if I had clicked on it.

I'm aware of things like Alt+Tab and the other Apple hotkeys, but they aren't deterministic. There's no way to press a certain keyboard combo and always get the same window. I don't want to scroll through a list of my open windows or anything. I want X app, right now, immediately.

2
  • Why don't you use Spaces? One specific app to each Space. Then it's as simple as using the built-in key-commands to bring each Space to the front & the app will come with it. See apple.stackexchange.com/q/179376/85275
    – Tetsujin
    May 8, 2020 at 6:45
  • I have a 32 inch 4k monitor. I don't need that whole space for, for example, Slack (when Slack's thread view is fixed width). May 11, 2020 at 19:24

2 Answers 2

4

I found a method that works (for all windows for a specific program).

  1. Create an AppleScript as follows (e.g., in /Users/<username>/activate_chrome.scpt:
tell application "Google Chrome"
    reopen
    activate
end tell
  1. Grab https://github.com/deseven/icanhazshortcut (I'm currently running 1.1.0)

  2. Create the shortcut of your choice and point it to run osascript /Users/<username>/activate_chrome.scpt

I tried the same thing in the Automator app, but the there were a lot of permissions issues and it would only activate the shortcuts when I had certain apps active and not others.

2
  • do you know anything more about github.com/deseven/icanhazshortcut running on Catalina...b/c I got it installed ok with HomeBrew, but I cannot get it to run b/c I get the "App can’t be opened because Apple can’t check it for malicious software" Nov 22, 2021 at 15:02
  • 1
    @FlakDiNenno it's been a spell. you can bypass the Apple security by command right clicking on the app, select open, then hit open in the dialogue that shows.
    – eighteyes
    Feb 15 at 17:11
1

I made an open-source tool that does that on Windows and Linux. I had a working MacOS version a while ago but discontinued it because of a lack of experience in the MacOS ecosystem.

If you have the skills, please take a look at this : https://github.com/xurei/hyperkeys/

Like I said, it won't work for MacOS out of the box, but I made it work before, so I guess it's possible to have it back.

Feel free to fill in a Github issue if you need my help ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .