0
votes

Can anybody explain the difference between IfWinActive and If WinActive()? I'm really wondering, but Google and official AutoHotkey docs says nothing about.

1
Please read this very section: autohotkey.com/docs/Tutorial.htm#s5 . if winactive (without (), thus two commands in a row), is no allowed syntax.phil294

1 Answers

1
votes

If IfWinActive evaluates to True, the next line of code (or brace-bracketed code block) is performed, or if False, it is skipped. All it does is evaluate to True or False.

The function WinActive() returns the Unique ID (HWND) of the active window if it matches the specified criteria. If it does not, the function returns 0. Since all non-zero numbers are seen as "true", the statement If WinActive("WinTitle") is true whenever "WinTitle" is active, and then acts just like IfWinActive WinTitle. Note the quotes in the function, but not the directive.