How to remap some peculiar key?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zyd199012
Posts: 12
Joined: 13 Jul 2016, 02:27

How to remap some peculiar key?

20 Sep 2017, 22:17

This is my keyboard
Image

I want to remap those four key like
NumLock->0
0->NumLock
menu->pagedown
video->pageup
But I meet some trouble.

One:
Of course I know how to remap the first two group,such as

Code: Select all

NumLock::
    SendInput 0
Return
But I have to say this is very slow.And sometimes it will fail to do it.Is there any more efficient method?hotstring maybe more fast to implement this target but I note :*:NumLock::0 don't work actually..

Two:
I don't know what symbol on behalf of the last two group key in AutohotKey. Such as the video key or the menu key.

Anybody can give me a hand?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: How to remap some peculiar key?

20 Sep 2017, 22:33

Check out trying a Remap. NumLock::0 and 0::NumLock

As for the special Menu and Video keys, you can get a key name for them if you read the instructions for Special Keys in KeyList. They'll probably be a name like vkFFsc123, so you would do something like vkFFsc123::pgdn and vkFFsc124::pgup
zyd199012
Posts: 12
Joined: 13 Jul 2016, 02:27

Re: How to remap some peculiar key?

21 Sep 2017, 02:26

Exaskryz wrote:Check out trying a Remap. NumLock::0 and 0::NumLock

As for the special Menu and Video keys, you can get a key name for them if you read the instructions for Special Keys in KeyList. They'll probably be a name like vkFFsc123, so you would do something like vkFFsc123::pgdn and vkFFsc124::pgup

Code: Select all

NumLock::0
0::NumLock
Work for you?If I run it,then both key map to 0
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: How to remap some peculiar key?

21 Sep 2017, 02:34

Works for me. I realized during testing I made the mistake of pressing Numpad0, which is not affected by that code. Press the 0 on the row above your letters instead (Edit: But I do see your picture points to the Numpad0, so you do want the next part: ) Otherwise, use Numpad0::NumLock. (And optionally, or if it makes any difference to your target program, NumLock::Numpad0.)
zyd199012
Posts: 12
Joined: 13 Jul 2016, 02:27

Re: How to remap some peculiar key?

21 Sep 2017, 02:40

Exaskryz wrote:Works for me. I realized during testing I made the mistake of pressing Numpad0, which is not affected by that code. Press the 0 on the row above your letters instead (Edit: But I do see your picture points to the Numpad0, so you do want the next part: ) Otherwise, use Numpad0::NumLock. (And optionally, or if it makes any difference to your target program, NumLock::Numpad0.)

Yes,I realize that problem before your response. I have change it into

Code: Select all

Numpad0::NumLock
NumLock::Numpad0
But in my pc,the NumLock::Numpad0 work now,but the Numpad0::NumLock don't work still...
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: How to remap some peculiar key?

21 Sep 2017, 02:43

Hi.
The zero key on your keyboard is called "Numpad0". Another thing is to use the $-char to execute only physically pressed buttons.
So try:

Code: Select all

$Numpad0::NumLock
$NumLock::NumPad0
For the other keys follow the steps shown by Exaskryz.
Einfach nur ein toller Typ. :mrgreen:
zyd199012
Posts: 12
Joined: 13 Jul 2016, 02:27

Re: How to remap some peculiar key?

21 Sep 2017, 02:48

divanebaba wrote:Hi.
The zero key on your keyboard is called "Numpad0". Another thing is to use the $-char to execute only physically pressed buttons.
So try:

Code: Select all

$Numpad0::NumLock
$NumLock::NumPad0
For the other keys follow the steps shown by Exaskryz.

Hi,Numpad0::NumLock is work for you?
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: How to remap some peculiar key?

21 Sep 2017, 03:01

Hello zyd199012.
You're right.

Code: Select all

$Numpad0::NumLock
does not works reliable. By first running it deactivates the NumLock function but activating is not possible. Seems to switch only the input mode.
My zero key has second function, when NumLock is deactivated. Second function is NumPadIns. Adding another remapping solves this.

Code: Select all

$Numpad0::NumLock
$NumpadIns::Numlock
$NumLock::NumPad0
Now I can toggle with the zero key but when i trigger the NumLock i have to press twice the zero key to toggle. Your zero key looks like having not another function.
The basics are these. When the NumLock is deactivated, the NumPad0 key is even deactivated. This is the reason for the strange looking behaviour.
Einfach nur ein toller Typ. :mrgreen:
zyd199012
Posts: 12
Joined: 13 Jul 2016, 02:27

Re: How to remap some peculiar key?

21 Sep 2017, 11:30

divanebaba wrote:Hello zyd199012.
You're right.

Code: Select all

$Numpad0::NumLock
does not works reliable. By first running it deactivates the NumLock function but activating is not possible. Seems to switch only the input mode.
My zero key has second function, when NumLock is deactivated. Second function is NumPadIns. Adding another remapping solves this.

Code: Select all

$Numpad0::NumLock
$NumpadIns::Numlock
$NumLock::NumPad0
Now I can toggle with the zero key but when i trigger the NumLock i have to press twice the zero key to toggle. Your zero key looks like having not another function.
The basics are these. When the NumLock is deactivated, the NumPad0 key is even deactivated. This is the reason for the strange looking behaviour.

After some struggle,I always know what you say..So you mean since my zero key have no second function.The it is impossible to implement this target?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: How to remap some peculiar key?

21 Sep 2017, 14:42

Check that there isn't a second function by looking in your KeyHistory of the script. If the Numpad0::NumLock remap does not work (it should work the first time), just spam the Numpad0 key a few times. Then check the Key History to see what key name has been detected.

Oh my Keyboard the Numpad5 button does not have a symbol under the 5. (Numpad0 has "ins", Numpad1 has "end", Numpad2 has a down arrow, Numpad3 has "pg dn", etc.) Turns out there is such a character as NumpadClear which is what is sent with my Numpad5 key when the NumLock is off. You might have that same character. If not, you may be able to at least get a special key name as per the Special Keys section in KeyList. This would have a "code name" like vkFFsc123.
zyd199012
Posts: 12
Joined: 13 Jul 2016, 02:27

Re: How to remap some peculiar key?

21 Sep 2017, 22:29

Exaskryz wrote:Check that there isn't a second function by looking in your KeyHistory of the script. If the Numpad0::NumLock remap does not work (it should work the first time), just spam the Numpad0 key a few times. Then check the Key History to see what key name has been detected.

Oh my Keyboard the Numpad5 button does not have a symbol under the 5. (Numpad0 has "ins", Numpad1 has "end", Numpad2 has a down arrow, Numpad3 has "pg dn", etc.) Turns out there is such a character as NumpadClear which is what is sent with my Numpad5 key when the NumLock is off. You might have that same character. If not, you may be able to at least get a special key name as per the Special Keys section in KeyList. This would have a "code name" like vkFFsc123.

Thanks very much,everything work now.Just one behavior is unexpected.When I run NumLock::0,it will trigger off then on,then output a zero..It is very slow..I don't know your machine can reproduce thise behavior. Maybe I have miss something..
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: How to remap some peculiar key?

21 Sep 2017, 23:09

I don't notice a slow behavior using that, no. I'm not sure what "it will trigger off then on" is, but I guess the NumLock flashes to off then back on for you. I don't have any native visual indicator - no keyboard LED nor an icon that pops up to indicate I changed the NumLock state. I coded one myself in AHK, but it is not toggling when I use the remap NumLock::0. So while I can't outright confirm my NumLock doesn't have a little misbehavior, I can't confirm it does have the misbehavior.

I don't think you've missed anything and it could be an unfortunate quirk about your keyboard. About how slow is it? Do you notice any difference if you hold down the NumLock key physically? I wonder if the 0 is produced when NumLock is released.
zyd199012
Posts: 12
Joined: 13 Jul 2016, 02:27

Re: How to remap some peculiar key?

22 Sep 2017, 01:07

Exaskryz wrote:I don't notice a slow behavior using that, no. I'm not sure what "it will trigger off then on" is, but I guess the NumLock flashes to off then back on for you. I don't have any native visual indicator - no keyboard LED nor an icon that pops up to indicate I changed the NumLock state. I coded one myself in AHK, but it is not toggling when I use the remap NumLock::0. So while I can't outright confirm my NumLock doesn't have a little misbehavior, I can't confirm it does have the misbehavior.

I don't think you've missed anything and it could be an unfortunate quirk about your keyboard. About how slow is it? Do you notice any difference if you hold down the NumLock key physically? I wonder if the 0 is produced when NumLock is released.

I have record a `.gif` for this behavoir for this.You can check the attachmemts
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: How to remap some peculiar key?

22 Sep 2017, 10:24

I didn't see a gif attached. I do anticipate that I may not be able to help you even after seeing it, but hopefully someone else can. Especially if they get the same behavior on their hardware.

For the sake of clarity and getting everyone on the same page, can you share your full updated code? It may be possible that there is other code interfering with the NumLock::0 that results in these delays.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Afinka, Google [Bot] and 137 guests