#IfWinActive numbers not working?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

#IfWinActive numbers not working?

20 Nov 2014, 12:15

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
Randy31416
Posts: 58
Joined: 15 Jan 2014, 19:09

Re: #IfWinActive numbers not working?

20 Nov 2014, 12:20

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.
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: #IfWinActive numbers not working?

20 Nov 2014, 12:55

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
Does work for me.

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?
Guest

Re: #IfWinActive numbers not working?

21 Nov 2014, 05:50

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.
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

Re: #IfWinActive numbers not working?

21 Nov 2014, 05:52

Forgot to login. Disabling or enabling numpad seems irrelevant.
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: #IfWinActive numbers not working?

21 Nov 2014, 06:40

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::)?
Guest

Re: #IfWinActive numbers not working?

21 Nov 2014, 07:13

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::)?
No, definitely not. It doesn't work on any of the 5 other computers either.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: #IfWinActive numbers not working?

21 Nov 2014, 22:47

'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:
  • 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.
It could be a remapping like x::0, but in that case the key you are physically pressing must be x, not 0. If what you posted is the exact script you are running, in its entirety, there must be some other script running. I suppose that this should close all running scripts:

Code: Select all

DetectHiddenWindows On
GroupAdd close, ahk_class AutoHotkey,,, %A_ScriptFullPath%
WinClose ahk_group close
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

Re: #IfWinActive numbers not working?

10 Dec 2014, 18:27

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.
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: #IfWinActive numbers not working?

11 Dec 2014, 19:17

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.
zotune
Posts: 85
Joined: 17 Nov 2014, 17:57

Re: #IfWinActive numbers not working?

30 Jan 2015, 07:34

1. Windows safe mode? (using win 8)
2. Already running as admin.
3. Not entirely sure how to do this step by step...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 357 guests