In AutoIt, we use the same function to resize windows, as we do to move windows. When resizing windows with AutoIt, there are at least a few functions that are useful to know about. The WinWait, WinActivate and the WinMove functions.
The WinWait function will first wait for the window to appear, after which we can do whatever else we want with it.
$hWnd = WinWait("[CLASS:SpotifyMainWindow]", "", 10)
Note that we also created a window handle ($hWnd) in the script, this allows us to easily work with the window later, without having to repeat the title of the window throughout the script. The added benefit of doing this, is that if the application is updated by the creators, and the title changes, you will only have to change it one place in your script.
Before we can move a window, we will also need to activate it, this can be done using the WinActivate function, and the handle we created ealier.
And now, finally we may resize and move the window using WinMove.
$hWnd = WinWait("[CLASS:SpotifyMainWindow]", "", 10) WinActivate($hWnd) WinMove("[CLASS:SpotifyMainWindow]", "", 0, 0, 200, 200)
Avoiding that the window moves when resizing
Because we are using the same function to resize windows, that we also use to move windows, we may want to avoid moving the window. Using the Default keyword in place of the x and y coordinates, will effectively resize the window without moving it from its original position.
WinMove("[CLASS:SpotifyMainWindow]", "", Default, Default, 200, 200)