#HotIf fails to activate when global variant is present Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
xypha
Posts: 24
Joined: 24 Apr 2020, 04:14

#HotIf fails to activate when global variant is present

15 Dec 2023, 02:45

#HotIf fails to activate when global variant is present, while using ahk_group in AHK v2 (AutoHotkey v2.0.10)
Please check the examples below.
Why is example #2 failing (when using Firefox) and how can I correct the error?

Example #1 - works when global variant is disabled

Code: Select all

GroupAdd "HorizontalScroll1", "ahk_class MozillaWindowClass"           ; Firefox
GroupAdd "HorizontalScroll1", "ahk_class other"                     ; other

#HotIf WinActive("ahk_group HorizontalScroll1")

+WheelUp::WheelLeft
+WheelDown::WheelRight

#HotIf

/* global variant disabled
+WheelUp::SendMessage 0x0114, 0, 0, ControlGetFocus("A")        ; scroll left - 0x114 is WM_HSCROLL, 0 is SB_LINERIGHT
+WheelDown::SendMessage 0x0114, 1, 0, ControlGetFocus("A")      ; scroll right - 1 is SB_LINELEFT
*/

ListLines output -
Spoiler

Example #2 - fails when global variant enabled

Code: Select all

GroupAdd "HorizontalScroll1", "ahk_class MozillaWindowClass"           ; Firefox
GroupAdd "HorizontalScroll1", "ahk_class other"                     ; other

#HotIf WinActive("ahk_group HorizontalScroll1")

+WheelUp::WheelLeft
+WheelDown::WheelRight

#HotIf

+WheelUp::SendMessage 0x0114, 0, 0, ControlGetFocus("A")        ; scroll left - 0x114 is WM_HSCROLL, 0 is SB_LINERIGHT
+WheelDown::SendMessage 0x0114, 1, 0, ControlGetFocus("A")      ; scroll right - 1 is SB_LINELEFT

Listlines output -
Spoiler

Error pop-up -
Spoiler
niCode
Posts: 320
Joined: 17 Oct 2022, 22:09

Re: #HotIf fails to activate when global variant is present  Topic is solved

15 Dec 2023, 04:50

Experiencing the same issue. I wonder if this is a bug :think:

Changing the #HotIf portion to this seems to work:

Code: Select all

#HotIf WinActive("ahk_group HorizontalScroll1")

+WheelUp::Send('{WheelLeft}')
+WheelDown::Send('{WheelRight}')

#HotIf
User avatar
xypha
Posts: 24
Joined: 24 Apr 2020, 04:14

Re: #HotIf fails to activate when global variant is present

15 Dec 2023, 05:31

@niCode
This worked. Thank you.
Last edited by xypha on 17 Dec 2023, 07:52, edited 1 time in total.
User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: #HotIf fails to activate when global variant is present

15 Dec 2023, 08:27

There’s a section of this forum titled Bug Reports.
User avatar
xypha
Posts: 24
Joined: 24 Apr 2020, 04:14

Re: #HotIf fails to activate when global variant is present

15 Dec 2023, 12:16

boiler wrote:
15 Dec 2023, 08:27
There’s a section of this forum titled Bug Reports.
Thanks. I will post a new topic there.
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: #HotIf fails to activate when global variant is present

16 Dec 2023, 02:50

It is not a bug. +WheelUp::WheelLeft is a remapping, not a hotkey. A remapping consists of two wildcard hotkeys. It can be activated by any combination of modifiers that includes Shift (such as Shift+Alt), whereas +WheelUp::SendMessage ... is a hotkey without the wildcard, and therefore cannot be activated if any modifier other than Shift is pressed.

#HotIf is only used to select which variant of the same hotkey activates. You could use +WheelUp::WheelLeft and +WheelUp::SendMessage ... together even without #HotIf, because the differing modifier-key requirements cause them to be treated as separate hotkeys. When a key combination corresponds to multiple hotkeys, generally the more specific hotkey should take precedence. That's the one which doesn't permit modifiers other than Shift.

I deleted the Bug Reports topic.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: big-jg, Descolada, Rohwedder, zizanie13 and 38 guests