Numpad Keys not working as triggers while other keys do work...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
buttonpusher
Posts: 3
Joined: 16 Nov 2017, 12:08

Numpad Keys not working as triggers while other keys do work...

16 Nov 2017, 14:13

I am having trouble with a script. In particular, I can't get the Numpad keys to register as a trigger for any hotkeys. If they do work, they will likely only work immediately after loading the script and will only work one time.

Here is the part of the code I am trying to use:

Code: Select all

#NoEnv
; #Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
SetNumLockState On

#UseHook
#InstallKeybdHook

^!a::
Numpad1::
Send, {Control Down}{c}{Control Up}
Sleep, 300
Run, C:\Program Files (x86)\WinCatalog\WinCatalog.exe -o "C:\Users\MyUserName\OneDrive\Documents\WinCatalog\Music Catalog.w3cat" -s -sq "%Clipboard% AND (*.mp3 OR *.wav OR *.aif)"
Sleep, 300
WinActivate, WinCatalog 2017 - Music WinCatalog File.w3cat
Return

^!s::
Numpad2::
Send, +^{Click, Left}
WinWait, Redirecting...
Sleep, 333
WinWaitClose, Redirecting...
Sleep, 333
SoundPlay, D:\Dropbox\Sounds\work-complete.wav
Return

;Numpad1::^!a
;Numpad2::^!s

^!p::Reload
In the above example, when triggered by pressing the control-alt-a or -s keys, both sequences run correctly and consistently. The Hotkey for control-alt-a will copy the whatever word(s) I have selected to the clipboard and then send it to Wincatalog to run a search. Control-alt-s will click the mouse where I have parked it and waits for an intermediate browser window to appear, do its thing and then move to the next window, and then play a sound to notify me.

As I said, the sequences work correctly when triggered by ^!a or ^!s. The Numpad1 or 2 assignment does not work (or if it does, it will only work the first time). I had also tried defining separate hotkeys for the Numpad keys and having them re-send the keystrokes that do fire the correct sequences, but that didn't work either. They are still in there, but commented out. I've also tried using only the Numpad triggers or putting them above the multi-key trigers with zero success. I also tried using Function keys & they've worked correctly.

Can anyone give me an idea if I'm doing something wrong? Should this work? Is there something in the directives at the top that do or don't make this work?

(FWIW, I tried this script (https://autohotkey.com/board/topic/9675 ... +1%2C+0%2C) on my system and it worked just fine)
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: Numpad Keys not working as triggers while other keys do work...

16 Nov 2017, 16:24

It just seems like your numpad keys aren't being recognized. Do you have Num Lock on? Does this script work:
Numpad1::MsgBox, hello
If not, toggle your Num Lock setting and try again.
buttonpusher
Posts: 3
Joined: 16 Nov 2017, 12:08

Re: Numpad Keys not working as triggers while other keys do work...

16 Nov 2017, 17:00

There's a "SetNumLockState On" directive at the top. And the Numlock light is on on my keyboard (I don't toggle it off very often, so it's on.)

Also, I've tried the "Numpad1:: Send ^!a" and it doesn't work.

I've looked in at the Key History of this macro a bit more and it appears that the Numpad1 key presses just aren't being sensed at all.
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: Numpad Keys not working as triggers while other keys do work...

16 Nov 2017, 22:30

You can actually type numbers using your numpad? And the one-line script I suggested doesn't work?

You might want to try this keyboard on-screen display script and see what it shows as you type with your numpad.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Numpad Keys not working as triggers while other keys do work...

16 Nov 2017, 22:42

Btw:

Code: Select all

Numpad1:: ;works when NumLock is on
NumpadEnd:: ;works when NumLock is off
vState := GetKeyState("NumLock", "T") ? "on" : "off"
MsgBox, % A_ThisHotkey "`r`n" "NumLock is " vState
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
buttonpusher
Posts: 3
Joined: 16 Nov 2017, 12:08

Re: Numpad Keys not working as triggers while other keys do work...

17 Nov 2017, 10:23

I ran the 2 test pieces of code above - both worked correctly. Numlock is *on*. And they type the numbers just fine (1234567890.+-*/ - typed with it just now with no AHK scripts running). My script just doesn't work with the Numpad keys.

I will try my script on two other PC systems I have access to & see if it's this one in particular that's having problems.
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: Numpad Keys not working as triggers while other keys do work...

17 Nov 2017, 11:45

I would try removing certain lines from your code that are different than the simpler test scripts and could be affecting it somehow, like these:

Code: Select all

SetNumLockState On
#UseHook
#InstallKeybdHook

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, dangoscrub, doodles333, joedf, Nerafius and 124 guests