Repeating multiple keys not working with numpad and alt modifiers Topic is solved

Ask gaming related questions (AHK v1.1 and older)
ast
Posts: 24
Joined: 09 Nov 2019, 23:11

Repeating multiple keys not working with numpad and alt modifiers

Post by ast » 22 Sep 2022, 18:32

Code: Select all

$Numpad4::
$5::
!2::
$e::
Key := SubStr(A_ThisHotkey,0)
SetTimer, Send1, 100
Gosub, Send1
return

Numpad4 up::
!2 up::
5 up::
e up::
SetTimer, Send1, Off
return
Send1:
	Send, {%Key%}
return
When I press Numpad 4 it sends 4 instead and it doesn't work for Alt+2 at all
Would greatly appreciate any help

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: Repeating multiple keys not working with numpad and alt modifiers

Post by mikeyww » 23 Sep 2022, 06:12

Your script is designed so that the key must be held rather than pressed. Does it work in Notepad? Check the KeyHistory.

ast
Posts: 24
Joined: 09 Nov 2019, 23:11

Re: Repeating multiple keys not working with numpad and alt modifiers

Post by ast » 24 Sep 2022, 19:11

mikeyww wrote:
23 Sep 2022, 06:12
Your script is designed so that the key must be held rather than pressed. Does it work in Notepad? Check the KeyHistory.
Yup holding it when theres numpad involved it doesn't send the numpad key but just the number and it just ignores any alt combination completely

Code: Select all

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.05	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	d	0.03	Numpad4        	
34  005	i	d	0.00	4              	
34  005	i	u	0.00	4              	
64  04B	h	u	0.02	Numpad4

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: Repeating multiple keys not working with numpad and alt modifiers

Post by mikeyww » 25 Sep 2022, 05:15

SubStr(..., 0) refers to the last character only. Subst(..., 2) refers to the second character to the end of the string.

Explained: SubStr
If StartingPos is less than 1, it is considered to be an offset from the end of the string. For example, 0 extracts the last character and -1 extracts the two last characters.

Code: Select all

MsgBox, % SubStr("Numpad4", 0)
Since !2 Up is triggered while Alt is still held, you can use :arrow: KeyWait to wait for Alt.

Code: Select all

!2 Up::
Send x
KeyWait, Alt
Send y
Return
Or:

Code: Select all

!2 Up::Send {Alt up}x

ast
Posts: 24
Joined: 09 Nov 2019, 23:11

Re: Repeating multiple keys not working with numpad and alt modifiers

Post by ast » 25 Sep 2022, 07:58

Code: Select all

MsgBox, % SubStr("Numpad4", -7)
Numpad4 comes up fully for the message box but when i made the change below it's doesn't work anymore

Code: Select all

Key := SubStr(A_ThisHotkey ,-7)

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: Repeating multiple keys not working with numpad and alt modifiers  Topic is solved

Post by mikeyww » 25 Sep 2022, 08:08

Code: Select all

#UseHook
Numpad4::
5::
!2::
e::
key := RegExReplace(A_ThisHotkey, "[#^!+]")
SetKeyDelay, 100
While GetKeyState(key, "P")
 Send {%key%}
Return
#UseHook Off

Post Reply

Return to “Gaming Help (v1)”