Page 1 of 1

#If bug maybe

Posted: 28 Nov 2015, 11:57
by tmplinshi

Code: Select all

~LAlt & ~g::MsgBox % A_ThisHotkey

#If WinActive("ahk_class Notepad")
  ~LAlt & ~t::MsgBox % A_ThisHotkey

#If !WinActive("MozillaWindowClass")
  !+t::MsgBox % A_ThisHotkey ; This hotkey doesn't work
The 3rd hotkey !+t doesn't work.

Changes to global hotkey works fine:

Code: Select all

~LAlt & ~g::MsgBox % A_ThisHotkey

~LAlt & ~t::
	If WinActive("ahk_class Notepad")
		MsgBox % A_ThisHotkey
Return

!+t::
	If !WinActive("MozillaWindowClass")
		MsgBox % A_ThisHotkey
Return

Re: #If bug maybe

Posted: 28 Nov 2015, 14:56
by guest3456
tmplinshi wrote:

Code: Select all

#If !WinActive("MozillaWindowClass")
  !+t::MsgBox % A_ThisHotkey ; This hotkey doesn't work
aren't you missing an ahk_class ?

Code: Select all

#If !WinActive("ahk_class MozillaWindowClass")

Re: #If bug maybe

Posted: 28 Nov 2015, 15:13
by tmplinshi
yes, but that's not the point. The hotkey was setup on any window except "xxxxx". So whatever "MozillaWindowClass" or "ahk_class MozillaWindowClass" is fine.

Re: #If bug maybe

Posted: 28 Nov 2015, 18:50
by lexikos
If you have a wildcard hotkey *x:: and a normal hotkey !x::, Alt+X resolves to the latter. If that hotkey is inactive, AutoHotkey looks for a wildcard hotkey which matches the current set of modifiers.

AutoHotkey doesn't support this for custom combination hotkeys, because they are meant for custom combinations. LAlt+t is a standard combination; a combination of a standard modifier and another key. Custom combinations act like wildcard hotkeys in that they don't care what other modifiers are held down. Since the prefix key is a custom modifier, it is presumed that no other hotkeys could match that combination, since you can't define multiple modifiers, like !x & y:: or z & x & y::. Even if you define separate combos, AutoHotkey only supports holding one custom modifier at a time.

So in short, use *~<! instead of ~LAlt &. If you didn't intend the wildcard behaviour (which is always present for custom combinations), remove the *.

Re: #If bug maybe

Posted: 28 Nov 2015, 21:45
by tmplinshi
So it's about priority:
  • wildcard hotkey is higher than normal hotkey
  • custom combination hotkeys is higher than normal hotkey
BTW, just a thought:

Code: Select all

*x::MsgBox, x king
!+x::MsgBox, you won't see me :(
When !+x hotkey being pressed, why not choose !+x to fire? Just like context-sensitive hotkeys has higher priority than global hotkey.

Never mind, I will remember the priority.

Re: #If bug maybe

Posted: 28 Nov 2015, 23:10
by lexikos
Hotkey prioritization is not possible for registered hotkeys, and !+x:: is most likely a registered hotkey unless you #UseHook.

Hook hotkeys are sorted according to specificity: *x < *^x < *^+x < x < ^x ...

Code: Select all

*x::MsgBox, x
$!+x::MsgBox, you will see me :P
Custom combinations are not sorted, but are handled separately and before other hotkeys. If you have both Alt & x and LAlt & x, which one fires when you press LAlt+x depends on the order of definition.

Re: #If bug maybe

Posted: 28 Nov 2015, 23:34
by tmplinshi
Cool. Good to know the hotkey can be sorted.