How to Use AutoHotkey to Create Custom Keyboard Shortcuts

554
How to Use AutoHotkey to Create Custom Keyboard Shortcuts

Here we can see, “How to Use AutoHotkey to Create Custom Keyboard Shortcuts”

Some things are just a hassle to type, especially when you have to type them repeatedly. Or, much worse, if the word you’re looking for isn’t on your keyboard. What should you do if you’re typing on an American keyboard and you need to enter a Euro into a document?

This was a difficulty for me. I was becoming irritated, and making matters worse, I was making blunders. I needed to control my annoyance and ensure that the repetitive things I had to type were accurate and consistent. The search for answers was on. It turns out that there is a single solution to both issues: AutoHotKey.

What Is AutoHotkey and How Does It Work?

AutoHotkey (AHK) is a scripting platform at its core. You can construct a script that runs in the background and allows you to do almost anything with a hotkey you set with just a little “code.” You can remap a keyboard shortcut if you want to change it, and you can designate a key combination to a phrase that you type frequently. If you have a set of regularly run commands, AHK can automate them all with a single key combination.

However, don’t be alarmed by terms like “scripting platform” and “code.” AutoHotkey is quite easy to use, especially if you’re only using it to set basic hotkeys to basic actions. You might be able to learn what you need to know in a single afternoon. To get you started, let’s go over some simple instances of what AutoHotkey can perform.

Also See:  A new Apple display with an iPhone chip inside is reportedly in testing

How Do I Install It?

  • To get the programme, go to AutoHotkey’s website. There’s a big green button on the main page that says “Download.” This will take you to the download page if you click on it. To receive the most recent version, click on the teal download button.

Note: AutoHotkey may be flagged as malware by some antivirus products. This is an example of a false positive. AutoHotkey is a very powerful tool, and while it isn’t malicious in and of itself, it is a scripting language, which means you could use it to develop malware if you wanted to. However, you should not be concerned about downloading the fundamental AutoHotkey programme; it will not affect your machine.

  • Double-click the installation file after it has finished downloading to begin installing AutoHotkey. Nearly all users will use the Express Installation button.
  • The custom installation provides you with more control over default behaviour and where the software is installed, and it’s preferable to leave the defaults alone.

After you’ve installed it, you’re ready to start writing your first script.

How to Write an AutoHotkey Script for the First Time

The AutoHotkey application will now launch its help page instead of doing anything. You’ll need a script to tell AutoHotkey about your custom keyboard shortcuts before you can get started. So, let’s begin by making one.

  • Choose New > AutoHotkey script from the context menu of your Desktop (or any other folder). In that folder, a new file with the.ahk extension will be created. Give the file any name you wish, then right-click on it and select Open in Notepad from the menu. (Or, if you have it, a more code-friendly software like Notepad++).
  • The file will contain some text. It can be eliminated for simple scripts like the one we’re displaying here, and you might want to leave it in as you progress.
  • You’ll be given a nearly blank canvas on which to construct your fantasy keyboard shortcuts, and I’ll give you a handful of instances.
  • Let’s begin with a straightforward character insertion script. Every day, I use a script to enter popular German characters that aren’t available on my English keyboard.

Let’s imagine I want to type ß every time I hit Alt+Shift+S on my keyboard. That would look like this in AutoHotkey:

!+s:: Send, ß

Let’s break out that passage of text:

  • ! is the symbol for the Alt key
  • + is the symbol for the Shift key
  • s stands for (obviously) the S key
  • :: denotes what you want the preceeding keys to run when pressed together
  • Send, is a command that types the proceeding text
  • ß is the text we want the command to type.

This command essentially states, “Type ß when Alt, Shift, and S are pushed at the same moment.”

You can also use other modifiers. For example, you may tell AutoHotkey to only perform the command if the Left Alt key is used to add the symbol before your hotkey (so it reads <!+s:: Send, ß).

This is the entirety of my German-symbol-hotkey script:

<!a:: Send, ä
<!o:: Send, ö
<!u:: Send, ü
<!+a:: Send, Ä
<!+o:: Send, Ö
<!+u:: Send, Ü
<!+s:: Send, ß
<!+$:: Send, €

If you know the character’s name you want to include in your script, Google is generally the best place to start. If you don’t know what it is, look it up in an ASCII or Unicode table.

You may go beyond just individual characters with this. AutoHotkey is your new best buddy if you routinely struggle to translate complex, irritating, or just plain long character strings from your brain to your fingers. In my other employment, I frequently have to contact colleagues at different universities to discuss security issues on projects without being introduced by the people I work with.

This necessitates that I introduce myself and explain why I’m approaching them. I utilize a hotstring in AHK instead of typing out the entire message. This is how the script looks:

The:*: at the start warns AHK to be on the lookout for the sting that follows. In this situation, the string is ncm (in my thinking, it stands for “new cold message”). So, whenever I type the letters ncm in a box, the string of text that follows the:: in the script replaces them. Not only have I reduced a paragraph of typing to three keystrokes, but I also know it will be correct every time.

Instead of using hotscript, this might be achieved with a hotkey. You could substitute!+n for:*:ncm in the script to get the same text string when you press Alt+N on your keyboard.

AutoHotkey may also get basic information from your PC, and it can, for example, obtain the current date. This script could be a lifesaver if you’re someone who has to enter the date into several fields.

AutoHotkey will drop the current date wherever your cursor is if you run this script. In the script, you can experiment with formatting (dd/MM/yyyy versus MM/dd/yyyy, for example).

Also See:  192.168.0.1 Default Router IP Login

The Best AutoHotkey Scripts to Try

Here are a few of the most effective AutoHotkey scripts that you can download and start using right away to improve Windows. Check out the AutoHotkey Script Showcase for even more AutoHotkey script examples, including ones that are far more complex than these.

1. AutoCorrect

Even with a desktop keyboard’s precision, you’re going to make mistakes when typing. Typos don’t go out of style, even if this is an old AHK script.

It has thousands of frequent misspellings in its database, and when you make a mistake, it instantaneously substitutes the incorrect word with the correct one. You can also add your own words, which we’ll go into later.

DownloadAutoCorrect Script

2. Disable Lock Keys

The three Lock keys—Num Lock, Caps Lock, and Scroll Lock—are rarely utilized in today’s computers. You probably use the number pad for digits, only accidentally click Caps Lock, and don’t care about Scroll Lock.

If you don’t use these modifiers often, try using this script to change them to a default value:

; Set Lock keys permanently
SetNumlockState, AlwaysOn
SetCapsLockState, AlwaysOff
SetScrollLockState, AlwaysOff
return

This implies you always want Num Lock on if you like it off (or remove it completely and only change Caps Lock and Scroll Lock).

3. Caps Lock with a New Purpose

After you’ve disabled Caps Lock with the script above, it’s a good idea to repurpose that key.

Caps Lock will become another Shift key after running this script, but you can modify it to anything you like (perhaps another Windows key if your keyboard only has one):

; Turn Caps Lock into a Shift key
Capslock::Shift
return

4. View or Hide Hidden Files Quickly

Knowing how to view hidden files and folders in Windows is useful at times. This script is useful if you require access to hidden folders occasionally and don’t want them to clutter your view.

To toggle showing hidden files or directories, press Ctrl + F2 while File Explorer is active. It’s as simple as that! Copy the following code from the linked forum post and paste it into a script:

^F2::GoSub,CheckActiveWindow
CheckActiveWindow:
ID := WinExist("A")
WinGetClass,Class, ahk_id %ID%
WClasses := "CabinetWClass ExploreWClass"
IfInString, WClasses, %Class%
GoSub, Toggle_HiddenFiles_Display
Return

Toggle_HiddenFiles_Display:
RootKey = HKEY_CURRENT_USER
SubKey = Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced

RegRead, HiddenFiles_Status, % RootKey, % SubKey, Hidden

if HiddenFiles_Status = 2
RegWrite, REG_DWORD, % RootKey, % SubKey, Hidden, 1 
else 
RegWrite, REG_DWORD, % RootKey, % SubKey, Hidden, 2
PostMessage, 0x111, 41504,,, ahk_id %ID%
Return

Visit: Toggle Hidden Files Script

5. Show or Hide Known File Extensions Quickly

This one is similar to the last one in that it also involves File Explorer. It’s a good idea to always reveal file extensions for security concerns, making it easier to recognize malicious EXE files posing as PDFs or other documents. It’s also useful for dealing with Windows 10 file associations.

With Win + Y, you can toggle revealing extensions for known file types with the script below.

Download: Toggle Known File Extensions Script

6. Add Unique Characters

Aside from the few special characters on your keyboard (such as @ and *), many more aren’t as accessible. Using AutoHotkey is one of the quickest ways to enter foreign characters and other unusual symbols.

You may rapidly insert these special symbols with only one line of AHK code, eliminating the need to recall ALT codes or copy and paste from an online list.

Create shortcuts that are most beneficial to you using the template below. The shortcut is triggered by pressing the characters to the left of the two colons, while the symbol inside the brackets is what the shortcut inserts.

For example, if you want to insert the trademark icon by pressing Alt + Q, you’d write a script like this:

!q::SendInput {™}

The characters for keys are as follows for reference. On AutoHotkey’s guide page, you may learn more about hotkeys:

  • ^ for Ctrl
  • ! for Alt
  • # for Win
  • + for Shift

7. Go to Google and do a quick search.

This helpful shortcut allows you to search for any copied text on your computer if you’re a heavy Google searcher.

When you hit Ctrl + Shift + C, it will open your default browser and search Google for any text you’ve marked. It’s great to cut down on the amount of time you spend copying and pasting!

^+c::
{
Send, ^c
Sleep 50
Run, https://www.google.com/search?q=%clipboard%
Return
}

8. Make a mouse out of the Numpad

While you can navigate Windows without a mouse if necessary, having this script on hand eliminates the need to memorize keyboard shortcuts. This clever AutoHotkey software turns your number pad into a mouse, providing you greater precision and a way to navigate your computer in the event of hardware failure.

For instructions on using the script, look at the information at the top of the page.

Download: Using Keyboard Numpad as a Mouse Script

9. Open any application

The Start menu allows you to quickly access any software installed on your computer. However, you might prefer a speedier way to launch your most-used programs.

It’s easy to write a script to start an app; here’s one to open Firefox when you hit Win + F. Change it to your chosen key combination and app as needed.

#f::Run Firefox

10. Temporary Volume Controls

Most keyboards include keys for quickly changing the volume, changing the music track, and other functions. If yours does not have these, you can create your volume buttons with AutoHotkey.

Here’s an example that uses the number pad keys Shift + Plus and Shift + Minus to raise and lower the volume. Toggle mute by using the little-used Break key.

Feel free to tweak the buttons as you would with the other scripts.

+NumpadAdd:: Send {Volume_Up}
+NumpadSub:: Send {Volume_Down}
break::Send {Volume_Mute}
return

Running Programs, Remapping Shortcuts, and More

More than just inserting text is possible with AutoHotkey (although that is one of its more common uses). You may also use it to launch a program when you click a specific key, remap shortcuts like Alt+Tab to custom hotkeys, and remap mouse buttons. You can even use AutoHotkey to generate dialogue boxes or full-fledged applications if you dig deep enough.

The different symbols for hotkeys can be found in AutoHotkey’s documentation. Check out their beginner’s guide for even more examples of what you can accomplish with a script. The AutoHotkey forum is a fantastic place to search, ask questions, and learn more about what AutoHotkey can accomplish if you ever get stuck.

Conclusion

I hope you found this information helpful. Please fill out the form below if you have any queries or comments.

User Questions:

  1. Is AutoHotkey any good?

In the right hands, AutoHotkey is a remarkable programme with nearly endless powers. Some users may find it scary, which is unfortunate because AutoHotkey is very simple and can automate both simple and sophisticated instructions.

  1. Does AutoHotkey contain a virus?

Multiple malware assaults have targeted AutoHotkey, an open-source scripting language for Windows used for form fillers, auto-clicking, macros, and other things. AutoHotkey isn’t harmful or hazardous on its own; it relies entirely on scripts to carry out its functions.

  1. Can AutoHotkey be used on a Mac?

Although AutoHotkey is not available for Mac, several alternatives provide similar functionality and run on macOS. UI. Vision RPA, which is both free and open-source, is the ideal Mac option.

Also See:  NVIDIA RTX 3080 Ti Cards Start Shipping on May 31st, Arrives June 9th
  1. How long has AutoHotkey been around?

To begin with: AutoHotkey was founded in 2003. Chris (also known as Chris Mallett, the founder of AutoHotkey) lost interest in AutoHotkey in mid-2009. Version 1.0 of AutoHotkey was his most recent release. 48.05.

  1. How do I make a hotkey for a text insert?

How do I make a hotkey for a text insert? from AutoHotkey