Avoid AutoRaise to activate the window while pressing down the Command Key
Tags: tutorial, macos
Published: 2022-05-14 15:45:02

UPDATE: The author of AutoRaise spent time to take care of the issue I encountered initially. And therefore, what I initially tried to avoid is no longer an issue. However, [I got another situation](https://github.com/sbmpost/AutoRaise/issues/77) so that I am still applying this hack to my laptop.

UPDATE: After I sent the Pull Request with this amendment, I was told to try `mouseStop=true`, and that kind of works, but it's not perfect so that I am using both the feature and my amendment at the moment.

## Summary

- I use [Bartender](https://www.macbartender.com/) and [AutoRaise (installed via Homebrew)](https://github.com/sbmpost/AutoRaise), and the window usually gets activated by AutoRaise when I want to select the icon in Bartender's hidden menu bar.

- I decided to avoid AutoRaise to activate the window while I am pressing the command key.

With above amendment, I can select the icon in Bartender's hidden menu bar as follows:

- Move the mouse to the menu bar.
- Show Bartender's hidden menu bar and then press the command key.
- Keep pressing down the command key until the mouse cursor reaches to the icon.
- Release the command key.
- Click the icon (The icon doesn't move to the menu bar and shows the sub menus if you kept pressing down the command key).

This hack avoids AutoRaise to get activated while pressing the command key so that it gets easier to reach to the window when there is another window on the path in some cases (You may not need this hack if the distance between the windows is close enough with the parameter `mouseStop`).

![Another Issue](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xjk7hc1vmdlhvl1qyrw0.png)

## How To Install via Install Script

- This command downloads [the install script](https://raw.githubusercontent.com/brisbanewebdeveloper/AutoRaise/latest/install-custom-version.sh) and then executes it :

- Remove `AutoRaise` from `System Preference > Security & Privacy > Accessibility > Privacy` at first.

```
curl 'https://raw.githubusercontent.com/brisbanewebdeveloper/AutoRaise/77-make-it-work-with-bartender-custom/install-custom-version.sh' | sh
# OR
# curl 'https://raw.githubusercontent.com/brisbanewebdeveloper/AutoRaise/latest/install-custom-version.sh' | sh
```

## How To Install Manually

- This is what above install script does in case you prefer installing manually.

- Remove `AutoRaise` from `System Preference > Security & Privacy > Accessibility > Privacy` at first.

```
# Create the source directory
# ("myUser" is to be your own username)
mkdir -p /Users/myUser/src/brisbanewebdeveloper/AutoRaise
cd /Users/myUser/src/brisbanewebdeveloper/AutoRaise

# Download the custom version
git clone git@github.com:brisbanewebdeveloper/AutoRaise.git .
git checkout 77-make-it-work-with-bartender-custom
# OR
# git checkout latest

# Build the customised program
make clean && make CXXFLAGS=-DALTERNATIVE_TASK_SWITCHER

# Overwrite the one installed via Homebrew
# (Using "ditto" because "cp" command can get error)
chmod 555 AutoRaise
sudo ditto AutoRaise /opt/homebrew/opt/autoraise/bin/

# Remove the files downloaded
rm -fr /Users/myUser/src/brisbanewebdeveloper

# Restart with the custom program
brew services restart autoraise
```

## How To Uninstall

Just reinstall the program:

```
brew reinstall autoraise
```

## Reference

- [Updating Mac Software](https://developer.apple.com/documentation/security/updating_mac_software)