https://bpaste.net/show/54223d43f951
Numpad0 and A works fine, but not 0
Tried on both Win 8.1 and Win 7 SP1. Any suggestions? Using v1.1.16.05
#IfWinActive numbers not working?
-
- Posts: 58
- Joined: 15 Jan 2014, 19:09
Re: #IfWinActive numbers not working?
Numpad keys are weird and change their names based on the current NumLock state. Possibly you have NumLock off, and in this case the key you want is NumpadIns. [edit add] When I'm working with the Numpad keys, I usually wind up defining both names for the physical key so that I don't have to worry about the state of NumLock.
Re: #IfWinActive numbers not working?
Code: Select all
Run, notepad
#IfWinActive ahk_exe Notepad.exe
0::
Msgbox, Works
Return
#IfWinActive ahk_exe Notepad.exe
Numpad0::
Msgbox, Works
Return
#IfWinActive ahk_exe Notepad.exe
A::
Msgbox, Works
Return
What's happening? Numpad0 and A display the messagebox but 0 does not? When you press 0, is it being inputted into notepad or is there no response whatsoever? If you go into AHK's key history and press 0 and refresh, can you see any input has registered?
Re: #IfWinActive numbers not working?
It is being inputed into Notepad, though it's not working like the others.
VK SC Type Up/Dn Elapsed Key Window
-------------------------------------------------------------------------------------------------------------
30 00B i d 5.81 0 Untitled - Notepad
30 00B i u 0.00 0
60 052 h d 2.03 Numpad0
60 052 s u 0.09 Numpad0 test.ahk
0D 01C d 0.91 Enter
0D 01C u 0.06 Enter Untitled - Notepad
41 01E h d 0.45 A
41 01E s u 0.06 A test.ahk
0D 01C d 0.94 Enter
0D 01C u 0.06 Enter Untitled - Notepad
Press [F5] to refresh.
VK SC Type Up/Dn Elapsed Key Window
-------------------------------------------------------------------------------------------------------------
30 00B i d 5.81 0 Untitled - Notepad
30 00B i u 0.00 0
60 052 h d 2.03 Numpad0
60 052 s u 0.09 Numpad0 test.ahk
0D 01C d 0.91 Enter
0D 01C u 0.06 Enter Untitled - Notepad
41 01E h d 0.45 A
41 01E s u 0.06 A test.ahk
0D 01C d 0.94 Enter
0D 01C u 0.06 Enter Untitled - Notepad
Press [F5] to refresh.
Re: #IfWinActive numbers not working?
Forgot to login. Disabling or enabling numpad seems irrelevant.
Re: #IfWinActive numbers not working?
The event type for the press of 0 shows: i=Ignored because it was generated by an AHK script
Are you running any other scripts or does your script contain any other hotkeys (specifically 0::)?
Are you running any other scripts or does your script contain any other hotkeys (specifically 0::)?
Re: #IfWinActive numbers not working?
No, definitely not. It doesn't work on any of the 5 other computers either.Nextron wrote:The event type for the press of 0 shows: i=Ignored because it was generated by an AHK script
Are you running any other scripts or does your script contain any other hotkeys (specifically 0::)?
Re: #IfWinActive numbers not working?
'i' means it was generated by an AutoHotkey script. That does not mean that 0 is registered as a hotkey within a script - it means a script is using Send 0 or equivalent.
Artificial keystrokes generated by other programs (and sometimes keyboard drivers) are shown as 'a', not 'i'. There are only two possible explanations for the 'i' event:
Artificial keystrokes generated by other programs (and sometimes keyboard drivers) are shown as 'a', not 'i'. There are only two possible explanations for the 'i' event:
- An AutoHotkey script is sending a 0 keystroke.
- Another program is sending a 0 keystroke event with its 'dwExtraInfo' field set to a "magic number" which AutoHotkey uses to identify events which should be ignored; i.e. between 0xFFC3D3E9 and 0xFFC3D44F. It's pretty unlikely.
Code: Select all
DetectHiddenWindows On
GroupAdd close, ahk_class AutoHotkey,,, %A_ScriptFullPath%
WinClose ahk_group close
Re: #IfWinActive numbers not working?
I can't for the life of me get this to work at work. It works fine at home, but I don't have a numpad here. Tried Norwegian and English keyboard layout. No other scripts running. Tried closing most of my other apps too.
Re: #IfWinActive numbers not working?
Okay, so there's some unidentified reason why at work your physical 0 sends an artificial 0. Best option to solve the problem would be to remove the source of the behavior, but apparently closing other applications and using lexikos' kill-script does not solve it.
So let's try some stuff to narrow it down. Could you try the script in safe mode? That probably excludes any non-standard keyboard drivers that may be running.
Can you run the script as admin? That places the keyboard hook higher in the chain, possibly above the cause of the problem.
If that still fails you could try to make the hotkey a non-hook variant. Those are unable to distinguish between physical/artificial. Your conditional #IfWinactive (...) directive causes it to become a hook key instead of a registered key. So you'd have to replace that for an empty #if and add that check inside the corresponding code to execute your custom behavior or to default to Send 0.
So let's try some stuff to narrow it down. Could you try the script in safe mode? That probably excludes any non-standard keyboard drivers that may be running.
Can you run the script as admin? That places the keyboard hook higher in the chain, possibly above the cause of the problem.
If that still fails you could try to make the hotkey a non-hook variant. Those are unable to distinguish between physical/artificial. Your conditional #IfWinactive (...) directive causes it to become a hook key instead of a registered key. So you'd have to replace that for an empty #if and add that check inside the corresponding code to execute your custom behavior or to default to Send 0.
Re: #IfWinActive numbers not working?
1. Windows safe mode? (using win 8)
2. Already running as admin.
3. Not entirely sure how to do this step by step...
2. Already running as admin.
3. Not entirely sure how to do this step by step...
Who is online
Users browsing this forum: Google [Bot] and 357 guests