Auto keystrokes

with AutoHotkey

by Denis Lamarre
last updated March 5, 2019
difficulty.png easy

Description

Automatically insert commonly used text, such as addresses, phone numbers, account numbers, credit card information, and more. This is a super easy and useful keyboard shortcut that you can run with AutoHotkey. The AHK Enterpad, with its assignable buttons and customizable overlay, provides a more practical and reliable approach than hotkeys when using multiple shortcuts like this.

To create a simple auto keystroke shortcut that will type in a credit card number, just follow the steps below. Don’t miss the "More Info" section further down on the page for tips on dealing with specific situations.

Steps

1

stencil-v4b-keystroke.gifPrepare your overlay
Choose an unassigned key on the Enterpad where you will assign the credit card number. Name it something appropriate, like "Credit Card".

2

Code installation
Copy and paste the following script in the AutoHotkey script template (Enterpad.ahk) at the location of the key you wish to assign. Replace the sample credit card number (0000 0000 0000 0000) with that of your choice.

001:
SendInput 0000 0000 0000 0000
return

More Info

The SendInput command (used at line #2) has a special {raw} mode to send keystrokes exactly as they appear (with few exceptions). For example, the {raw} mode will not translate {Enter} to an ENTER keystroke, it will insert the character string "{Enter}".

SendInput {raw}^c
        

If you are not using the {raw} mode, you will have to treat the following special characters carefully; they have particular significance in AutoHotkey:

% Used to retrieve a variable’s content. Precede with a backtick like this `%
! Used to send ALT keystroke. Put within braces like this {!}
+Used to send SHIFT keystroke. Put within braces like this {+}
^ Used to send CONTROL keystroke. Put within braces like this {^}
# Used to send WIN keystroke. Put within braces like this {#}
{ Put within braces like this {{}
} Put within braces like this {}}
; Precede with a backtick like this `; or put within braces like this {;} (only needed if the semicolon has a space or tab to its left)
` Precede with a backtick like this ``

For example, if you want to automatically insert "25%", you could use one of the following commands:

SendInput 25`%
        

Or

SendInput {raw}25%
        

The AutoHotkey documentation provides a lot of information about the SendInput command: https://www.autohotkey.com/docs/commands/Send.htm