RegEx to strip modifier keys for KeyWait Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

RegEx to strip modifier keys for KeyWait

Post by iseahound » 01 Oct 2022, 23:10

I'm looking for a comprehensive RegEx to strip modifier keys.

For example,
  • ^c → c
  • >+7 → 7
  • XButton2 & LButton → LButton
Here's some ideas:

Code: Select all

RegExReplace(A_ThisHotkey, "<|>|#|\^|!|\+|.*?&\s+")

Code: Select all

KeyWait RegExReplace(A_ThisHotKey, "[#!^+&<>*~$]")

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: RegEx to strip modifier keys for KeyWait  Topic is solved

Post by Rohwedder » 02 Oct 2022, 00:30

Hallo,
try:

Code: Select all

q:: ; → q
.:: ; → .
^c:: ; → c
>+7:: ; → 7
MButton & LButton:: ; → LButton 
~+,:: ; → +
~<+<!3:: ; → 3
+vk02:: ; (Shift & RButton) → vk02
:*?:w:: ; → w
ToolTip,% RegExReplace(A_ThisHotkey, ".*?(\W|\w*)$","$1")
Return

iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

Re: RegEx to strip modifier keys for KeyWait

Post by iseahound » 02 Oct 2022, 09:05

Excellent! I haven't found any edge cases yet, but it seems fairly robust as it is. Thanks!

Post Reply

Return to “Ask for Help (v1)”