Part of the script is not active when HotIf is used

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
emzet
Posts: 2
Joined: 22 Mar 2023, 09:20

Part of the script is not active when HotIf is used

Post by emzet » 22 Mar 2023, 09:31

Hello,
the problematic script consists of two parts:
A. script for eliminating mouse double clicks
B. key mappings for some apps

Code: Select all

;---A---
*LButton::
{
	if (A_PriorHotkey = A_ThisHotkey && A_TimeSincePriorHotkey < 100) {
		return
	}
	Send "{Blind}{LButton down}"
	KeyWait "Lbutton"
	Send "{Blind}{LButton up}"
}

;---B---

#HotIf WinActive("ahk_class Chrome_WidgetWin_1") 
or WinActive("ahk_class MozillaWindowClass")
or WinActive("ahk_class PX_WINDOW_CLASS")
or WinActive("ahk_class #32770")
	<!g::
	<!q:: Send "^+{Tab}"
	<!e::
	<!h:: Send "^{Tab}"
	<!w:: Send "^w"
	<!d:: Send "^t"
	<!r:: Send "^r"
	<!s:: Send "{F6}"
	<!a:: Send "{Enter}"
	<!Lbutton:: Mbutton
#HotIf
When A is used alone it works just fine, but when B is added at the end of the script, A does not work anymore.
(e.g. double clicking a folder in a windows explorer does not work)

What can be the issue here? :|
I use latest version of AHK 2 on Windows 11.

User avatar
mikeyww
Posts: 26862
Joined: 09 Sep 2014, 18:38

Re: Part of the script is not active when HotIf is used

Post by mikeyww » 22 Mar 2023, 10:42

Welcome to this AutoHotkey forum!

Double-clicking a folder doesn't work, because your first hotkey blocks it. None of the conditions in section B match Windows File Explorer. In addition, none of the hotkeys there would match a left button click.

emzet
Posts: 2
Joined: 22 Mar 2023, 09:20

Re: Part of the script is not active when HotIf is used

Post by emzet » 22 Mar 2023, 12:21

Thank you for a quick response! :)

The goal I'm trying to acomplish here is to have A to work globally across the system but B to work only in certain aps.
I've played around a little bit and marked the line that is causing problems:

Code: Select all

;---A---
*LButton::
{
	if (A_PriorHotkey = A_ThisHotkey && A_TimeSincePriorHotkey < 100) {
		return
	}
	Send "{Blind}{LButton down}"
	KeyWait "Lbutton"
	Send "{Blind}{LButton up}"
}

;---B---
#HotIf WinActive("ahk_class Chrome_WidgetWin_1") 
	<!Lbutton:: Mbutton    ;<----this line is causing A to stop working
#HotIf
Why is this line interfering with windows explorer even though it should only apply to Chrome? :|
Should I use different directive to acomplish the goal?

User avatar
mikeyww
Posts: 26862
Joined: 09 Sep 2014, 18:38

Re: Part of the script is not active when HotIf is used

Post by mikeyww » 22 Mar 2023, 19:55

You are mistaken. There is no interference.

100 ms is very short for your first hotkey. I recommend increasing the value.

Post Reply

Return to “Ask for Help (v2)”