AutoIt's WinActivate function is used to activate a window, or change the focus to another window, so one can interact with it. A window which is in focus, might still be covered by a window that is set to always on top – so be careful.
If you want to check if a window is active, use AutoIt's WinActive function instead.
To get the title info from the window you want to activate, use the AutoIt Window Info Tool. You will find the info you need in the window tab.
|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.|
Sometimes you may need to wait for the window to appear, before you attempt to activate it, and that's where the WinWait function comes into play. The WinWait function will pause the script, until a specified window appears. In this case it will wait for 10 seconds, if the window doesn't appear inside of those ten seconds, it will exit the script.
$hWnd = WinWait("[CLASS:SpotifyMainWindow]", "", 10) WinActivate($hWnd)
If you don't want it to exit, you can just remove the optional timeout parameter.
$hWnd = WinWait("[CLASS:SpotifyMainWindow]") WinActivate($hWnd)