Code should be working only in a window with a specific title Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
whats_up
Posts: 89
Joined: 29 Apr 2018, 05:09

Code should be working only in a window with a specific title

Post by whats_up » 03 May 2024, 17:47

What should I write a beginning of the code lines, for code to be running only in a window with a specific title which may contain some specific words?

In v1 we had #IfWinActive , and it's been working great.

Now, in v2 it's disabled.

gregster
Posts: 9079
Joined: 30 Sep 2013, 06:48

Re: Code should be working only in a window with a specific title  Topic is solved

Post by gregster » 03 May 2024, 17:53

It's similar to #If in AHK v1 - but it's now renamed to #HotIf.
See #HotIf and WinActive().
Also https://www.autohotkey.com/docs/v2/Tutorial.htm#s22

User avatar
whats_up
Posts: 89
Joined: 29 Apr 2018, 05:09

Re: Code should be working only in a window with a specific title

Post by whats_up » 03 May 2024, 18:08

Thanks, it works fine.

As I understood, for some specific hotkeys like "Reload" and some others - I should simply write right before them a simple #HotIf without anything else.

gregster
Posts: 9079
Joined: 30 Sep 2013, 06:48

Re: Code should be working only in a window with a specific title

Post by gregster » 03 May 2024, 18:25

No, not really for specific but for general hotkeys, in order to end a section in which you defined contex-sensitive hotkeys or hotstrings.
To turn off context sensitivity, specify #HotIf without any expression.
That's the same like using a simple #IfWinActive or #If without anything else in v1 - in v2, it also works positional.

I could imagine that Reload could be used in both general and context-sensitve hotkeys... it depends on your goal and use case, imo.

Post Reply

Return to “Ask for Help (v2)”