DublTapESC utility: Double tap ESC to send an ESC (single press does nothing)

Here we have answers to common questions about SolidWorks. If you want to request or contribute answers, just flag down a moderator.
KevinC
Posts: 92
Joined: Fri Mar 12, 2021 10:14 am
Answers: 1
x 17
x 70

DublTapESC utility: Double tap ESC to send an ESC (single press does nothing)

Unread post by KevinC »

UPDATED: 06-DEC-2024
Intercepts a single ESC keypress to prevent an inadvertent ESC, such as when building an exploded view.
Instead, a double tap press of ESC is required to send a single ESC press.

This utility is easily converted for other keys, such as for F1 to prevent an unwanted Help starting when you misfired going for an F2 edit.
See the end of this post for the steps needed to replicate this utility for other keys, using F1 as an example.

For this utility, the first ESC press starts a timer and if within a 1/4 of a second (adjustable) another ESC is pressed, then ESC is sent as usual.
If after 1/4 second, another ESC press (1 or more additional within 1/4 second) hasn't happened, then nothing is sent for keypresses.

This utility is written in Autohotkey.

To adjust the timer delay, edit the .ahk file (plain text editor) and modify the "-250" in this line:
SetTimer KeyESC, -250, 0
This number is in milliseconds and it must be entered as a negative integer.

Required files are in the attached zip file, which contains: AutoHotkey32.exe; AutoHotkey64.exe; DublTapESC.exe; DublTapESC.ahk)

To load this utility:
1) Extract zipped files to a dedicated directory
2) DublTapESC.exe DublTapESC.ahk

To load by a batch file, enter these lines:
cd "my path to the DublTapESC files"
<UPDATE: 06-DEC-2024>
When "AutoHotkey64.exe" is copied and renamed to match the AHK script file name (as it is in the line below), you do not need to specify the script in the command line in order to load it. You can just run the renamed exe file by itself.
So this line loads the script:
start "" "DublTapESC.exe" "DublTapESC.ahk"
As does this line:
start "" "DublTapESC.exe"

This exe and its corresponding script file must reside in the same folder for this to work, otherwise a dialog displays stating it can't find a script with the same name as the exe.
</UPDATE: 06-DEC-2024>

Once loaded, DublTapESC will monitor for an ESC, no user interaction is required.
DublTapESC will be an "H" icon in your system tray in the lower right:
image.png
image.png (3.46 KiB) Viewed 212 times
To stop DublTapESC, right click this icon and select Exit. DublTapESC must be loaded again, if required.
To temporarily disable DublTapESC, right click this icon and select Suspend Hotkeys.
Now, the usual single ESC press will be sent, but DublTapESC is still loaded and selecting Suspend Hotkeys again will re-enable the double ESC functionality.

To remove DublTapESC from your computer, delete the files mentioned above and if created, the startup batch file.
If DublTapESC is currently running, it can't be deleted. Right click its tray icon and select Exit, then it can be deleted.
No other mods to your computer are made. No Windows Registry mods are made.

On initial load, a dialog displays and will automatically close in 6 seconds, which is adjustable by editing the integer in "T6" in this line:
Msgbox "Double-tap ESC (2 presses) for normal ESC", "DublTapESC", "48 T6"

Due to Autohotkey has gone to version 2 and that this doesn't play well with Windows 11, the ahk script must be run as shown.
Autohotkey includes a compiler to create a standalone exe file from the script, but these are being flagged as false positive by some anti-virus apps and thus the exe gets quarantined.
DublTapESC.exe is just a copy and rename of AutoHotkey64.exe, so these two lines are the same:
DublTapESC.exe DublTapESC.ahk
AutoHotkey64.exe DublTapESC.ahk

AutoHotkey32.exe is included for those on 32 bit and AutoHotkey64.exe is for those on 64 bit.
Same files as available at https://www.autohotkey.com/

Steps needed to replicate this utility for other keys, using F1 as an example:
1) Copy and rename DublTapESC.ahk to the new keystroke: "DublTapF1.ahk"
2) Edit the new script file (ahk is plain text, so Notepad will do fine)
3) Search and replace "Escape" with "F1" (omitting the quotes in the Replace dialog)
4) Search and replace "ESC" with "F1" (omitting the quotes in the Replace dialog)
5) Step 3 must precede step 4, otherwise "Escape" will become "F1ape"
6) Save your changes
7) Copy and rename AutoHotkey64.exe/AutoHotkey32.exe to be "DublTapF1.exe" (or just use the standard file name to run AHK)
8) Create a startup file to get this script running

You must use the key's spelling as dictated by AHK, listed here:
https://www.autohotkey.com/docs/v2/KeyList.htm
Follow the quoting and {} syntax in the script so that the keystroke itself is sent and not the individual letters comprising the key's name.
Attachments
DublTapESC.zip
(1.66 MiB) Downloaded 34 times
User avatar
AlexLachance
Posts: 2226
Joined: Thu Mar 11, 2021 8:14 am
Answers: 17
Location: Quebec
x 2419
x 2061

Re: DublTapESC utility: Double tap ESC to send an ESC (single press does nothing)

Unread post by AlexLachance »

That is an awesome utility mr. Chandler, thanks for making it public.
Post Reply