Auto keystrokes

with AutoHotkey

by Denis Lamarre
last updated Jul 11, 2013
difficulty.png Easy

by Denis Lamarre

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 file “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) rather than translating {Enter} to an ENTER keystroke, ^c to Control-C, etc. For example, the following command will send the characters ^c instead of a Control+C hotkey.

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. Escape with a backtick like `%
!
Used to send ALT keystroke. Put within braces like {!}
+
Used to send SHIFT keystroke. Put within braces like {+}
^
Used do send CONTROL keystroke. Put within braces like {^}
#
Used to send WIN keystroke. Put within braces like {#}
{
Put within braces like {{}
}
Put within braces like {}}
;
Escape like `; or within braces like {;} only if the semicolon has a space or tab to its left
`
Escape the backtick with a backtick like ``

As an example with a special character; If you would like to type 25% you can use one of the following commands:

SendInput 25`%
        

Or

SendInput {raw}25%
        

The AutoHotkey documentation provides a lot of information about the SendInput (and other similar) commands at: https://www.autohotkey.com/docs/commands/Send.htm