In the question AutoHotkey choking on same-line curly brace for compound if statements, the author included the following code-block to demonstrate their issue.
^!p::
IfWinExist ahk_class QWidget, ,qutIM{ ;if there is a qutIM-window other than the buddy-list...
IfWinNotActive ahk_class QWidget, ,qutIM{ ;ans it is not active...
WinActivate
}else{ ;the closing bracket in front of the else here puts AHK off...
WinMinimize
}
}else{ ;do some stuff with the buddy-list
; [...]
}
return
The accepted answer confirms that this issue was caused by the use of same-line brackets with the compound if-statements IfWinExist
and IfWinNotActive
.
Having faced this problem myself, I believe the issue could be demonstrated with a simpler example.
^!p::
IfWinNotActive ahk_class QWidget, ,qutIM {
WinActivate
} else { ;the closing bracket in front of the else here puts AHK off...
WinMinimize
}
return
While I think this simplified example would make the question more readable, (as per the often cited How to create a Minimal, Complete, and Verifiable example), I'm hesitant to make such a drastic change to the author's code.
My first thought was to leave a comment asking the question author if this change would be acceptable, but the user's account was deleted quite some time ago.
Is it acceptable to simplify code with a minimal, verifiable example if it doesn't change the question's intent?