How to Make App-Specific Hotkeys With AutoHotkey

Is not it annoying when nearly similar apps use completely different key combos to realize the identical end result? Even worse, do not you hate it when a bit of software program insists on utilizing obscure keyboard shortcuts with out providing an choice to remap them? Would not it’s nice to have absolute management over how your keyboard capabilities in each utility? Effectively, that is doable, because of AutoHotkey.

With AutoHotkey, you’ll be able to remap your entire keyboard or create customized shortcuts, each “globally” and for every utility individually. If you want, you’ll be able to even have customized strings of textual content—and even entire templates—for every app certain to the identical key combos. You solely want AutoHotkey and a textual content editor—even Notepad will do. Sounds fascinating? Then let’s hop proper in.


Getting Began With Home windows Spy in AutoHotKey

These days, many keyboards include software program for creating customized shortcuts and macros. Nonetheless, as we are going to see, AutoHotkey is extra versatile because it’s keyboard-agnostic.

With it, your “keyboard customizations” will not be tied to a specific keyboard. You can take your customization script to different computer systems and have your customized app shortcuts and shortcodes up and working very quickly.

Since on this article we’re hitting the bottom working, if you would like a correct introduction to AutoHotkey, test our fast AutoHotkey Information for Newbies.

Begin by downloading AutoHotkey from its official website. Then, set up it like every other app. You do not have to run it afterward. It springs into motion robotically while you run a script made for it. So, let’s create such a script.

MAKEUSEOF VIDEO OF THE DAY

With AutoHotkey put in, right-click wherever, in your desktop or inside a folder the place you wish to create your script. Select New > AutoHotkey Script. Give your script-to-be a reputation and press Enter.


Windows 10 right-click menu option to create new AHK script.

With AutoHotkey, you’ll be able to create “world” shortcuts that shall be energetic in all places or app-specific ones that may work solely inside an energetic utility’s window. To “goal” a particular utility, you will need to establish it in your script. AutoHotkey may help with that via its Window Spy.

Double-click in your presently clean script to run it, and with it, AutoHotkey. Proper-click on AutoHotkey’s icon on the Home windows tray, and select Window Spy from the menu that pops up.


Launching AutoHotkey's Window Spy tool.

To seek out the identifiers wanted to focus on an utility, go away Window Spy in your display screen, and click on in your app’s window. Then, discover the ahk_class, ahk_exe, and ahk_pid entries, on the high of Window Spy’s window. In our case, we wished to focus on the favored Obsidian note-taking utility. Since different software program might have the same ahk_class and ahk_pid, we used its executable file as our goal, utilizing ahk_exe Obsidian.exe, as talked about in Window Spy.


Using AutoHotkey's Window Spy to find a window's ID.

When you recognize your goal, it is time to script.

Time to Make a Script in AutoHotKey

Proper-click in your script and select Edit Script to open it in your default textual content editor. As you will notice, it will likely be pre-populated with some values that assist with compatibility and efficiency. Ignore them, press Enter one or two occasions, and goal your app utilizing:


#IfWinActive APP_IDENTIFIER

Exchange APP_IDENTIFIER with the precise goal that you just copied from AutoHotkey’s Window Spy. In our case, this translated to:

#IfWinActive ahk_exe Obsidian.exe


AutoHotkey's IfWinActive states that anything following it should activate only if a specific window is active.

When writing AutoHotkey scripts, you need to use the next symbols for the modifier keys in your keyboard:

  • ! for Alt
  • + for Shift
  • ^ for CTRL
  • # for the Home windows Key

Earlier than creating your precise shortcuts, although, take a look at if the script will certainly solely work when your chosen utility is energetic. The best approach to do it’s through the use of what AutoHotkey calls “a message field” or, reasonably, a “msgbox”.


Using AutoHotkey's MSGBOX command is an easy way to troubleshoot a script.

Sort the next straight below the road the place you focused the applying you selected:

^a::
msgbox it really works!
return

If translated into plain English, this is able to seem like:

  • When CTRL + A are pressed collectively on the keyboard…
  • … present a message field on the display screen that states “it really works!”.
  • When the person acknowledges that message field, return to the earlier state.

Run your script, press CTRL + A in your keyboard, and nothing ought to occur. That is since you’ve focused a particular utility however have not but switched to it. So, activate that utility’s window, press the identical mixture, and you must see a message field pop up stating that “it really works”.

Now, swap again to every other utility and retry your key combo. Hopefully, nothing ought to occur. If that’s the case, this implies your MSGBOX prompts solely in your focused app, which is the specified end result we would like from this script.


AutoHotkey's MSGBOX should show up only when the defined keyboard combination is pressed in the targeted app.

If the keybind does “leak” into different apps, double-check your syntax, and guarantee there is no such thing as a typo in your chosen goal.

How one can Make Customized Keyboard Profiles for Your Apps

AutoHotkey makes it straightforward to remap what the keys in your keyboard do, each individually and when mixed. Would you prefer to swap the A and B keys? In AutoHotkey syntax, this is able to seem like this:


a::b
b::a

Nonetheless, you in all probability do not wish to remap particular person keys, however to have multi-key combos, with a number of modifier keys, carry out particular actions.

To construct on the earlier instance, if you need B to seem while you press CTRL+A and, vice versa, A to pop up when urgent CTRL+B, strive:

^a::b
^b::a

After all, that is merely an instance. In actual life, urgent a number of keys to sort a single character is the very definition of counterproductive. In distinction, assigning textual content strings to key combos can considerably pace up textual content entry. To have your identify, e mail deal with, or every other piece of textual content typed while you press a key mixture, you need to use AutoHotkey’s “ship” command. This “tells” AutoHotkey, as its identify states, “ship” the string of textual content that follows it to the energetic window. In motion, it might seem like this:

^+O::
ship Odysseas
return

Use AutoHotkey's Send command to type whole strings of text in the targeted app.

Within the above script:

  • We start by “telling” AutoHotkey that it ought to do one thing after we press Shift + CTRL + O on the similar time.
  • That “one thing” is sending the string “Odysseas”, which occurs to be this author’s identify, to the energetic window.
  • Lastly, with “return”, we state the equal of “that shall be all, thanks, AutoHotkey!”.


The same key combination can enter your name in your note-taking application and use a health-replenishing potion in your favorite RPG.

Strive experimenting with completely different key combos and having AutoHotkey ship numerous textual content strings to your chosen utility. You’ll be able to have a number of guidelines in the identical script.

Utilizing keyboard combos to enter textual content strings could also be useful for immediately coming into your identify and e mail deal with. Nonetheless, it is not intuitive when typing. After some time, it turns into arduous to maintain monitor of what dozens of shortcuts do. That is the place textual content growth may help.

As a substitute of mapping particular key combos to textual content strings, AutoHotkey lets you outline shortcodes. Then, when it detects that you just typed certainly one of them, it may well robotically change it with an extended textual content string. It is so simple as:

:*:MUO~::Make Use Of
  • The “:*:” originally of the road states that this can be a textual content growth rule.
  • Then comes the shortcode, which in our case is “MUO~”.
  • As with shortcuts, “::” are the logical equal of “=” on this state of affairs.
  • The ultimate piece of the puzzle is the precise string of textual content with which we wish to change “MUO~”.

With this rule, at any time when we sort MUO~ in our focused app, AHK will leap in and change it with Make Use Of.

After you are executed defining guidelines for an utility, you’ll be able to goal one other one in exactly the identical means. Use “#IfWinActive APP_IDENTIFIER” once more, this time concentrating on one other app’s window, and sort your guidelines for it straight beneath.

Repeat as many occasions as you would like, creating app-specific profiles of shortcuts and shortcodes.

Since AutoHotkey scripts are mainly textual content information, here is a nifty thought: incorporate different scripts in your personal, and likewise make them app-specific! Examine our checklist of cool AutoHotkey Scripts. Select any that you just like, however as an alternative of utilizing them as standalone scripts, open them in a textual content editor.

Copy their contents and add them below an app-targeting part of your script. Save and re-run your script, and theoretically, these scripts ought to work as a part of your personal when the app you’ve got focused is energetic.

Making Your Keyboard Good With AutoHotKey

As you will see in the long term, creating such scripts is a course of, not a one-time affair. As your calls for and the methods you might be utilizing your software program change, so will your scripts.


By repeatedly extending and tweaking your scripts, chances are you’ll quickly really feel like how hackers are depicted in tech-illiterate sequence. By urgent half a dozen keys, and obscure combos of them identified solely by you, you’ll be able to a wall of textual content seem in your display screen as if by magic.


Typing on Keyboard
40+ Cool Productiveness Keyboard Methods Few Folks Know About

Need to get issues executed extra rapidly? Listed here are greater than 40+ highly effective keyboard shortcuts that may prevent probably the most time.

Learn Subsequent


About The Creator

Leave a Comment