The AutoIt WinActive function is used to check if a window is currently active. If are looking for a way to activate a window, look up WinActivate instead.
Checking if a window is active can be useful to avoid bogus clicks and key sends. Before input is send you would usually make sure, that the right application window is active.
Use this function in combination with conditional checks, to make your script do whatever you want, depending on the response from WinActive.
To fetch the information you need to identify the right application window, use the AutoIt window info tool that came with AutoIt. Activate the application window, and you'll be able to read the info from the WI tool. See screenshot below:
|Window||Title, hWnd or class of the window to check.|
|Text||The text of the window to check. Default is an empty string.|
|Success||The handle of the window.|
; Coordinated to click on screen $y = 100 $x = 100 If WinActive("[CLASS:SpotifyMainWindow]") Then MouseClick("left", $x, $y, 1) EndIf
And checking by window title. The following is not the best example, since the title text of the window in Spotify, includes the title of the song you are currently playing, making it unreliable – but it clearly shows the point.
If WinActive("Spotify - some artist – some track name") Then MouseClick("left", $x, $y, 1) EndIf