phil294 / AHK_X11

AutoHotkey for Linux (X11-based systems)
GNU General Public License v2.0
815 stars 15 forks source link

WinGetClass problem with simple string comparison #56

Closed comsyspro closed 1 year ago

comsyspro commented 1 year ago

here is a code snippet which dosen't work. when the file explorer nautilus is active the string comparison with the class name (also other class names) dosen't work. is this a bug?

^y::
WinGetClass, window_class, A
MsgBox %window_class%

if (window_class = "Org.gnome.Nautilus")
{
    MsgBox Nautilus is the active window
}
return
phil294 commented 1 year ago

That's because if ( ... ) with braces is "expression" syntax which isn't supported by ahkx11 right now. You'll have to resort back to the classic

if window_class = Org.gnome.Nautilus
{

instead.

There's a section in the readme about syntax differences https://github.com/phil294/AHK_X11#migrating-a-modern-windows-ahk-v11-script, but a basic if statement is missing so I'll add such one now.

comsyspro commented 1 year ago

thanks for you quick reply. now it works. the problem was also the string which have to be without quotation marks.