My hotkey does not work Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Loop
Posts: 155
Joined: 07 Jan 2019, 14:51

My hotkey does not work

Post by Loop » 25 Sep 2022, 17:00

HI
My script looks something like this. but it doesn't work, I think -SetTitleMatchMode has no effect.

Code: Select all

SetTitleMatchMode, 1
#if WinActive("ahk_class Notepad")
^+l::MsgBox, notepad
Return
#if

SetTitleMatchMode, 2
#If WinActive(" - AutoHotkey Community -")
^+l::MsgBox, chrome or firefox
Return
#If

What am I doing wrong
Thanks

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: My hotkey does not work  Topic is solved

Post by boiler » 25 Sep 2022, 17:17

You can’t set title match modes separately for different hotkeys that way. The second one where you set it to 2 never executes because it appears after a hotkey, thus is not inside the auto-execute section or in a labeled subroutine or function that gets called. Even if it were executed, it would just override the other one and apply to both.

But you don’t need one set to 1 anyway. Just set the first one to 2 and it will work for both. There is nothing about the first one where having it set to 1 helps it or restricts other windows from being identified.

Loop
Posts: 155
Joined: 07 Jan 2019, 14:51

Re: My hotkey does not work

Post by Loop » 26 Sep 2022, 08:57

Thank you! I have not really thought about it.

Post Reply

Return to “Ask for Help (v1)”