6697

Spotify Now Playing for IRC

Dec 15th, 2019
78
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Spotify Now Playing by Mr. Ree <MrRee@6697.co.uk>
  3.  * Support @ irc.6697.co.uk #6697
  4.  * This will build an executable that outputs the title of the now playing track in your Windows Spotify player.
  5.  * It can be used with just about any IRC client by using `/exec -o C:\path\to\SpotifyNowPlaying.exe`
  6.  */
  7.  
  8. using System;
  9. using System.Diagnostics;
  10. namespace SpotifyNowPlaying
  11. {
  12.     class Program
  13.     {
  14.         static void Main( string[] args )
  15.         {
  16.             Process[] processlist = Process.GetProcesses();
  17.             foreach ( Process process in processlist )
  18.             {
  19.                 if ( !String.IsNullOrEmpty( process.MainWindowTitle ) )
  20.                 {
  21.                     if( process.ProcessName == "Spotify" )
  22.                     {
  23.                         string title = process.MainWindowTitle;
  24.                         Console.WriteLine( "NP: " + title );
  25.                     }
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
RAW Paste Data