private void PerformActionAsAppCommandMessage() { // TODO: Provide this Action with a dependency to fetch a stored Spotify's process id, instead of having it search for it every time // We need Spotify's main window handle Process process = Spotify.FindSpotifyProcess(); if (process == null) { this.RaiseActionFailed(this, new ActionFailedEventArgs("Couldn't find Spotify's process.")); } else { IntPtr hWnd = Spotify.GetMainWindowHandle(unchecked ((uint)process.Id)); if (hWnd == IntPtr.Zero) { this.RaiseActionFailed(this, new ActionFailedEventArgs("Couldn't find Spotify's main window handle.")); } else { if (Windows.SendAppCommandMessage(hWnd, (IntPtr)this.AppCommandCode, true)) { this.RaiseActionPerformed(this); } else { this.RaiseActionFailed(this, new ActionFailedEventArgs($"PostMessage failed with error code {Marshal.GetLastWin32Error()}")); } } } }
private static void LogSystemInfo() { // Get .NET Framework version string netVersion = null; try { netVersion = ToastifyAPI.Helpers.System.GetNetFramework45PlusVersion(); } catch { // ignore } // Get Spotify version string spotifyVersion = null; try { spotifyVersion = Spotify.GetSpotifyVersion(); } catch { // ignore } logger.Info($"Architecture: IntPtr = {IntPtr.Size * 8}bit, Is64BitProcess = {Environment.Is64BitProcess}, Is64BitOS = {Environment.Is64BitOperatingSystem}"); logger.Info($"OS: Version = {ToastifyAPI.Helpers.System.GetOSVersion()}, Friendly Name = \"{ToastifyAPI.Helpers.System.GetFriendlyOSVersion()}\""); logger.Info($".NET: CLR Version = {Environment.Version}{(netVersion != null ? $", Framework Version = {netVersion}" : string.Empty)}"); logger.Info($"Toastify Version = {App.CurrentVersion}{(spotifyVersion != null ? $", Spotify Version = {spotifyVersion}" : string.Empty)}"); }
private static void LogSystemInfo() { // Get .NET Framework version string netVersion = null; try { netVersion = ToastifyAPI.Helpers.System.GetNetFramework45PlusVersion(); } catch { // ignore } // Get Spotify version string spotifyVersion = null; try { spotifyVersion = Spotify.GetSpotifyVersion(); } catch { // ignore } var info = new LinkedList <string>(new List <string> { $"[Architecture] IntPtr: {IntPtr.Size * 8}bit, Is64BitProcess: {Environment.Is64BitProcess}, Is64BitOS: {Environment.Is64BitOperatingSystem}", $"[OS] Version: {ToastifyAPI.Helpers.System.GetOSVersion()}, Friendly Name: \"{ToastifyAPI.Helpers.System.GetFriendlyOSVersion()}\"", $"[.NET] CLR Version: {Environment.Version}{(netVersion != null ? $", Framework Version: {netVersion}" : string.Empty)}", $"[Toastify] Version: {App.CurrentVersion}{(spotifyVersion != null ? $", [Spotify] Version: {spotifyVersion}" : string.Empty)}" }); int len = info.Max(s => s.Length); string line = new StringBuilder(len).Append('=', len).ToString(); info.AddFirst(line); info.AddLast(line); foreach (string s in info) { logger.Info($":: {new StringBuilder(len).Append(s).Append(' ', len - s.Length)} ::"); } }