9
votes

I would like to add partial window title matching to #IfWinActive. For example to match any notepad window, regardless wether the title is "Untitled - Notepad" or "MyFile - Notepad"

This should be very simple. My attemtps:

SetTitleMatchMode, Regex
SetTitleMatchMode, Slow

#IfWinActive *.Notepad
+n::b
#IfWinActive

second attempt matchmode 2 should match anywhere

SetTitleMatchMode, 2
#IfWinActive Notepad
+n::b
#IfWinActive

A test with using the full title Untitled - Notepad confirms that the code +n::b does substute Shift-n for Shift-b

NOTE: ahk_class is not an option as the class is different on every machine for the target programme TeXnicCenter

1
Nino, Is this all you have in your script, or is there more. I am asking because your second example is spot-on and exactly the way I use it too. (personally, I like to add a comma between IfWinActive and Notepad, like this: IfWinActive, Notepad). I assume that you did put SetTitleMatchMode, 2 at the top of your script. If this line is being placed below the first Return, the line will not be read and implemented unless it is part of a script.Robert Ilbrink
*.Notepad isn't a valid regular expression. You mean .*Notepad, i.e., 0 or more characters followed by "Notepad".Brigand

1 Answers

9
votes

As Robert Ilbrink said, my second example actually works, and the problem was that I did not place SetTitleMatchMode at the very top of my script.

The default example script for ^!n was in effect and interfered. Not exactly sure why it does that, but placing SetTitleMatchMode at the top solved my problem.