Send prefix key if no combinations match Topic is solved
-
- Posts: 4
- Joined: 04 Oct 2022, 16:10
Send prefix key if no combinations match
I have these two parts in my scrypt:
********************************************************************
Numpad0::
...
return
Numpad0 & Numpad1:: (this doesn't matter, i am just showing that i have some combinations for Numpad0)
...
return
********************************************************************
Problem: when i hold the prefix key {Numpad 0} and click a key, that doesn't match any combinations, only the clicked key gets sent to output.
Example: i was typing 127.0.0.1 on the numpad, but i only got 127...1. So I figured it was happening because i was clicking {Numpad 0} and '.' simultaneously, and {Numpad 0} was ignored as it is a prefix key.
I was wondering: if i hold the prefix key and then click some key, that doesn't match any combinations, could both of them be send to output?
********************************************************************
Numpad0::
...
return
Numpad0 & Numpad1:: (this doesn't matter, i am just showing that i have some combinations for Numpad0)
...
return
********************************************************************
Problem: when i hold the prefix key {Numpad 0} and click a key, that doesn't match any combinations, only the clicked key gets sent to output.
Example: i was typing 127.0.0.1 on the numpad, but i only got 127...1. So I figured it was happening because i was clicking {Numpad 0} and '.' simultaneously, and {Numpad 0} was ignored as it is a prefix key.
I was wondering: if i hold the prefix key and then click some key, that doesn't match any combinations, could both of them be send to output?
Re: Send prefix key if no combinations match
Welcome to this AutoHotkey forum!
With your custom combo, your prefix key fires by itself on release. It will work if you release the key before pressing the next key.
With your custom combo, your prefix key fires by itself on release. It will work if you release the key before pressing the next key.
-
- Posts: 4
- Joined: 04 Oct 2022, 16:10
Re: Send prefix key if no combinations match
Yes, but it is really annoying when typing fast. I also use spacebar as another prefix, so the problem is even worse in this case. Was just wondering if there is a way around it.
Re: Send prefix key if no combinations match
Hallo,
try:or without sending the BackSpace:
try:
Code: Select all
~Numpad0 & Numpad1::
SendInput, {Bs}
SoundBeep
Return
Code: Select all
Numpad0::
Input, Key, L1
SendInput,% [0][InStr(A_ThisHotkey,"Numpad0")] "{" Key "}"
Numpad0 Up::Input
#IF GetKeyState("Numpad0","P")
Numpad1:: ; Numpad0 & Numpad1::
Input
SoundBeep
Return
-
- Posts: 4
- Joined: 04 Oct 2022, 16:10
Re: Send prefix key if no combinations match
@Rohwedder I tried this, but it didn't work. Numpad0:: and Numpad0 Up:: are completely ignored if you press some other key with a prefix key, which is Numpad0. I guess ahk just works that way - if you have clicked some key while holding the prefix key then ahk looks for combinations and, if it didn't find any, ignores prefix and sends the other pressed key. There is probably some way to do what i want, but it most likely requires some shenanigans.
Re: Send prefix key if no combinations match Topic is solved
I have now integrated the two hotkey combinations Numpad0 & Numpad1 and Numpad0 & Numpad3. With both comes here the associated MsgBox. When entering other Numpad0 & (Key) combinations 0 and the Key is sent.
Code: Select all
Numpad0::
Numpad0 := True
Input, Key, L1
Numpad0 Up::
Input
SendInput,% [0][Numpad0] "{" Key "}"
Numpad0 := False , Key := ""
Return
#IF GetKeyState("Numpad0","P")
Numpad1:: ; Hotkey: Numpad0 & Numpad1
Input
MsgBox,,, your pressed Numpad0 & Numpad1, 1
Return
Numpad3:: ; Hotkey: Numpad0 & Numpad3
Input
MsgBox,,, your pressed Numpad0 & Numpad3, 1
Return
#IF
-
- Posts: 4
- Joined: 04 Oct 2022, 16:10
Re: Send prefix key if no combinations match
@Rohwedder
Yes, this is exactly what i was looking for, thank you!
Most people have keys that have no text bound to them as a prefix key probably, so it is not really a problem for most people.
Yes, this is exactly what i was looking for, thank you!
Most people have keys that have no text bound to them as a prefix key probably, so it is not really a problem for most people.