private static void ShowSpotify() { if (Spotify.IsRunning()) { var hWnd = Spotify.GetSpotify(); // check Spotify's current window state var placement = new Win32.WINDOWPLACEMENT(); Win32.GetWindowPlacement(hWnd, ref placement); int showCommand = Win32.Constants.SW_SHOW; // if Spotify is minimzed we need to send a restore so that the window // will come back exactly like it was before being minimized (i.e. maximized // or otherwise) otherwise if we call SW_RESTORE on a currently maximized window // then instead of staying maximized it will return to normal size. if (placement.showCmd == Win32.Constants.SW_SHOWMINIMIZED) { showCommand = Win32.Constants.SW_RESTORE; } Win32.ShowWindow(hWnd, showCommand); Win32.SetForegroundWindow(hWnd); Win32.SetFocus(hWnd); } }
private static void ShowSpotifyWithNoActivate() { var hWnd = Spotify.GetSpotify(); // check Spotify's current window state var placement = new Win32.WINDOWPLACEMENT(); Win32.GetWindowPlacement(hWnd, ref placement); var flags = Win32.SetWindowPosFlags.DoNotActivate | Win32.SetWindowPosFlags.DoNotChangeOwnerZOrder | Win32.SetWindowPosFlags.ShowWindow; Win32.SetWindowPos(hWnd, (IntPtr)0, placement.rcNormalPosition.Left, placement.rcNormalPosition.Top, 0, 0, flags); }
private static bool IsMinimized() { if (!Spotify.IsRunning()) { return(false); } var hWnd = Spotify.GetSpotify(); // check Spotify's current window state var placement = new Win32.WINDOWPLACEMENT(); Win32.GetWindowPlacement(hWnd, ref placement); return(placement.showCmd == Win32.Constants.SW_SHOWMINIMIZED); }