Irregular compound/combined Key, How to combine with other Key?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
s_adavan
Posts: 62
Joined: 10 Nov 2020, 06:31

Irregular compound/combined Key, How to combine with other Key?

Post by s_adavan » 25 Oct 2021, 00:35

On my numpad,
the key ( is named as <+9,
the key ) is named as <+0.

I would like to create,
Ctrl + ( for 'Undo',
Ctrl + ) for 'Redo'.

I tried this;

Code: Select all

^<+9:: Send, ^{z}	;Undo
^<+0:: Send, ^{y}	;Redo
and also this;

Code: Select all

Ctrl & <+9:: Send, ^{z}	;Undo
Ctrl & <+0:: Send, ^{y}	;Redo

But both cannot work, how is this supposed to be written?

Your help is much appreciated.

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

Re: Irregular compound/combined Key, How to combine with other Key?

Post by Rohwedder » 25 Oct 2021, 01:54

Hallo,
On my numpad, …
Numpad digits are called differently. When you press your two key combinations, what does the following script show as keys pressed? A mouse wheel rotation saves it to the clipboard:

Code: Select all

#InstallKeybdHook
#InstallMouseHook
SetTimer, KeyCombination, 50,% ClipBoard := ""
KeyCombination:
IF A_TimeIdlePhysical > 100
    Return
KeyCombination := KeyCombination()
ToolTip,% KeyCombination?"you are pressing`n" KeyCombination
:"ClipBoard:`n" ClipBoard
Return
*WheelUp::
*WheelDown::ClipBoard := KeyCombination 
KeyCombination(ExcludeKeys:="")
{ ;All pressed keys and buttons will be listed
    ExcludeKeys .= "{Shift}{Control}{Alt}{WheelUp}{WheelDown}"
    Loop, 0xFF
    {
        IF !GetKeyState(Key:=Format("VK{:02X}",0x100-A_Index),"P")
            Continue
        If !InStr(ExcludeKeys,Key:="{" GetKeyName(Key) "}")
            KeyCombination .= RegexReplace(Key,"Numpad(\D+)","$1")
    }
    Return, KeyCombination
}

s_adavan
Posts: 62
Joined: 10 Nov 2020, 06:31

Re: Irregular compound/combined Key, How to combine with other Key?

Post by s_adavan » 25 Oct 2021, 23:32

Hello Rohwedder, thank you for the response.
I tested your script, and actually it shows the correct key name accordingly.
Then I tried my script again, and it actually works.. :oops:

Because the key names are not normal, I casted a lot of doubts on it.
I assumed it required other special script when it was not working.
Actually I got the wrong 'shortcut' for the #IfWinActive that I tried on.

So sorry for the trouble..

Google translate (hope it translates correctly):
Ich wünsche ihnen einen wunderbaren :D
There is nothing impossible to him who will try. -Alexander the Great-

Post Reply

Return to “Ask for Help (v1)”