#If bug maybe

Report problems with documented functionality
tmplinshi
Posts: 1487
Joined: 01 Oct 2013, 14:57

#If bug maybe

28 Nov 2015, 11:57

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
guest3456
Posts: 2556
Joined: 09 Oct 2013, 10:31

Re: #If bug maybe

28 Nov 2015, 14:56

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")

tmplinshi
Posts: 1487
Joined: 01 Oct 2013, 14:57

Re: #If bug maybe

28 Nov 2015, 15:13

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.
lexikos
Posts: 6504
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: #If bug maybe

28 Nov 2015, 18:50

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 *.
tmplinshi
Posts: 1487
Joined: 01 Oct 2013, 14:57

Re: #If bug maybe

28 Nov 2015, 21:45

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.
lexikos
Posts: 6504
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: #If bug maybe

28 Nov 2015, 23:10

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.
tmplinshi
Posts: 1487
Joined: 01 Oct 2013, 14:57

Re: #If bug maybe

28 Nov 2015, 23:34

Cool. Good to know the hotkey can be sorted.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 5 guests