Open Spotify to tray on start up

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fish21
Posts: 1
Joined: 26 Sep 2021, 15:20

Open Spotify to tray on start up

26 Sep 2021, 15:27

Hi,

Can anyone help me with a script for Spotify please?

When the option 'open minimized' is selected in the settings of the app, it still opens op on windows boot in a minimized windows.

I would like it to boot into tray only.

I have the script below but this does not work (entirely). It does prevent the window from opening but the app still pops up as an opened application on the taskbar.

if WinExist("Spotify Premium") WinClose ; Use the window found by WinExist.

Anyone could help me with this?

Thank you
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Open Spotify to tray on start up

26 Sep 2021, 17:48

Code: Select all

runApp("Spotify")
WinWait, ahk_exe Spotify.exe,, 30
If ErrorLevel
 Return
Sleep, 500
PostMessage, WM_SYSCOMMAND := 0x0112, SC_CLOSE := 0xF060

runApp(family, appID := "") {
 Loop, Files, % StrReplace(A_AppData, "Roaming", "Local\Packages\*" family "*"), D
  RunWait, % "explorer shell:appsFolder\" A_LoopFileName "!" (appID = "" ? family : appID)
}
An alternative function is below.

Code: Select all

runApp(appName) { ; Run a Windows Store app
 ; https://www.autohotkey.com/boards/viewtopic.php?p=422260#p422260
 pkgExisted := FileExist(out := A_MyDocuments "\packages.txt")
 Loop, 2 {
  If !FileExist(out)
   RunWait, powershell -NoProfile -Command & {get-appxpackage > %out%},, Hide ; Create file about packages
  FileRead, packages, %out%                                                   ; Info about Windows packages
  RegExMatch(packages, "InstallLocation   : \K.*?" appName ".*", dir)         ; App's directory
  If !(dirExist := FileExist(dir)) && A_Index = 1 && pkgExisted               ; If file existed & no dir
   FileRecycle, %out%                                                         ;  recycle file, & try again
 } Until !pkgExisted || dirExist                                              ; Stop if dir found or no pkg
 If !dirExist
  Return
 RegExMatch(packages, "PackageFamilyName : \K.*?" appName ".*", family)       ; App's family name
 FileRead, appInfo, %dir%\AppxManifest.xml                                    ; Info about the app
 RegExMatch(appInfo, "Application Id=""\K\w+", appID)                         ; Application ID
 RunWait, explorer shell:appsFolder\%family%!%appID%                          ; Run the app
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 255 guests