Toggle Spotify window

Post your working scripts, libraries and tools for AHK v1.1 and older
DRocks
Posts: 565
Joined: 08 May 2018, 10:20

Toggle Spotify window

Post by DRocks » 26 Sep 2021, 09:23

Very basic function to open, activate or minimize the Spotify Window.

With Hotkey Ctrl + Alt + M :
- When app is not running, open it.
- When app window is minimized, restore and activate it.
- When app window is activated, minimize it.

Code: Select all

^!m::toggleSpotifyMusic()

toggleSpotifyMusic() {
	spotityWinTitle := "ahk_exe Spotify.exe"
	if (WinExist(spotityWinTitle)) {
		if (WinActive(spotityWinTitle)) {
			WinMinimize
		} else {
			WinRestore
			WinActivate
		}
	} else {
		Run, %A_AppData%\Spotify\Spotify.exe
	}
}

Return to “Scripts and Functions (v1)”