From https://autohotkey.com/docs/misc/WinTitle.htm#ahk_class
A window class is a set of attributes that the system uses as a template to create a window. In other words, the class name of the window identifies what type of window it is.
In other words you can use it to identify windows of the same type, if you open notepad the title will be Untitled - Notepad
if you save it to temp.txt
the title will become temp - Notepad
. ahk_class
on the other hand will always remain Notepad
.
The second example will work if you replace it with #IfWinActive ahk_class MSPaintApp
because that’s the class of mspaint.
Usually you find ahk_class
using Window Spy
and then use it in your scripts. If you don’t have Window Spy
you can use the following hotkey:
#1::WinGetClass, Clipboard, A ; Will copy the ahk_class of the Active Window to clipboard
After you found it you can use it in any place you can use window title for example instead of writing WinActivate, Untitled - Notepad
you can write WinActivate, ahk_class Notepad
.