private static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime) { if ((idObject == 0) && (idChild == 0)) { //Method call to get current playing track and artist as //soon as EVENT_OBJECT_NAMECHANGE occured. get_Track_and_Artist(); //Making sure no internal name change event get caught. if (hwnd.ToInt32() == hwnd_spotify.ToInt32()) { //for .NET Version < 4.0 beacuse no inbuilt IsNullOrWhiteSpace method. if ((!NameChangeTracker.IsNullOrWhiteSpace(track) && track != oldTrack) || (!NameChangeTracker.IsNullOrWhiteSpace(artist) && artist != oldArtist)) //if((!String.IsNullOrWhiteSpace(track) && track != oldTrack) || (!String.IsNullOrWhiteSpace(artist) && artist != oldArtist)) { notify.sendNotification(track, artist); Console.WriteLine(track); Console.WriteLine(artist); oldTrack = track; oldArtist = artist; } } } }
public ToastForm() { InitializeComponent(); // Create rounded corners this.Region = System.Drawing.Region.FromHrgn(createRoundRectRgn(0, 0, Width, Height, 20, 20)); // Initialize user options and settings myOptions = new Options(); // Initialize our form's appearance from user settings initializeFromSettings(); // Create overlay so that our text isn't transparent and difficult to read initializeOverlay(); // Create tray icon createTrayIconAndMenu(); // Create and run timer for animation timer = new Timer { Interval = myOptions.ToastMovementSpeed }; timer.Tick += new EventHandler(timerTick); // Now let's setup our Spotify Window tracker nct = new NameChangeTracker(this); }
public static void Main() { ProcessInformation PSI = new ProcessInformation(); //Checking spotify available. if (PSI.isAvailable()) { NameChangeTracker.create_object(); //Method call to create objects. NameChangeTracker NCT = new NameChangeTracker(); //constructor call; IntPtr hWnd = NameChangeTracker.hwnd_spotify; int pid = NameChangeTracker.processid; // Listen for name change changes for spotify(check pid!=0). IntPtr hWinEventHook = SetWinEventHook(0x0800c, 0x800c, IntPtr.Zero, procDelegate, Convert.ToUInt32(pid), 0, 0); // Listen for create window event across all processes/threads on current desktop.(check pid=0) IntPtr hWinEventHook_start = SetWinEventHook(0x00008000, 0x00008000, IntPtr.Zero, procDelegate_start, 0, 0, 0); Message msg = new Message(); //GetMessage provides the necessary mesage loop that SetWinEventHook requires. while (GetMessage(ref msg, hWnd, 0, 0)) { UnhookWinEvent(hWinEventHook); UnhookWinEvent(hWinEventHook_start); } } else { //Executed if spotify not running. MessageBox.Show("check spotify running or not", "Spotify Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public ToastForm() { InitializeComponent(); // Create rounded corners this.Region = System.Drawing.Region.FromHrgn(createRoundRectRgn(0, 0, Width, Height, 20, 20)); // Initialize user options and settings myOptions = new Options(); // Initialize our form's appearance from user settings initializeFromSettings(); // Create overlay so that our text isn't transparent and difficult to read initializeOverlay(); // Create tray icon createTrayIconAndMenu(); // Create and run timer for animation timer = new Timer(); timer.Interval = myOptions.ToastMovementSpeed; timer.Tick += new EventHandler(timerTick); // Now let's setup our Spotify Window tracker nct = new NameChangeTracker(this); }
public static void Main(string[] args) { Console.Title = "SpotifyNotifier"; //Thanks to Matthew Javellana @ [email protected] for (int i = 0; i < args.Length; i++) { if (args[i].StartsWith("-w")) { IntPtr hWnd = FindWindow(null, Console.Title); if (hWnd != IntPtr.Zero) { ShowWindow(hWnd, 0); } } } ProcessInformation PSI = new ProcessInformation(); //Checking spotify available. if (PSI.isAvailable()) { NameChangeTracker.create_object(); //Method call to create objects. NameChangeTracker NCT = new NameChangeTracker(); //constructor call; IntPtr hWnd = NameChangeTracker.hwnd_spotify; int pid = NameChangeTracker.processid; // Listen for name change changes for spotify(check pid!=0). IntPtr hWinEventHook = SetWinEventHook(0x0800c, 0x800c, IntPtr.Zero, procDelegate, Convert.ToUInt32(pid), 0, 0); // Listen for create window event across all processes/threads on current desktop.(check pid=0) IntPtr hWinEventHook_start = SetWinEventHook(0x00008000, 0x00008000, IntPtr.Zero, procDelegate_start, 0, 0, 0); Message msg = new Message(); //GetMessage provides the necessary mesage loop that SetWinEventHook requires. while (GetMessage(ref msg, hWnd, 0, 0)) { UnhookWinEvent(hWinEventHook); UnhookWinEvent(hWinEventHook_start); } } else { //Executed if spotify not running. MessageBox.Show("check spotify running or not", "Spotify Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public static void Main() { ProcessInformation PSI = new ProcessInformation(); //Checking spotify available. if(PSI.isAvailable()) { NameChangeTracker.create_object(); //Method call to create objects. NameChangeTracker NCT = new NameChangeTracker();//constructor call; //NameChangeTracker.nameChanger(); IntPtr hWnd = NameChangeTracker.hwnd_spotify; int pid = NameChangeTracker.processid; // Listen for name change changes for spotify(check pid!=0). IntPtr hWinEventHook = SetWinEventHook(0x0800c, 0x800c, IntPtr.Zero, procDelegate, Convert.ToUInt32(pid), 0, 0); // Listen for create window event across all processes/threads on current desktop.(check pid=0) IntPtr hWinEventHook_start = SetWinEventHook(0x00008000,0x00008000,IntPtr.Zero, procDelegate_start, 0, 0, 0); //MessageBox.Show("Tracking name changes on HWNDs, close message box to exit."); Message msg = new Message(); //GetMessage provides the necessary mesage loop that SetWinEventHook requires. while(GetMessage(ref msg,hWnd,0,0)) { UnhookWinEvent(hWinEventHook); UnhookWinEvent(hWinEventHook_start); } } else //Executed if spotify not running. MessageBox.Show("check spotify running or not","Spotify Not Found",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); }
public static void Main(string[] args) { Console.Title = "SpotifyNotifier"; //Thanks to Matthew Javellana @ [email protected] for( int i = 0; i < args.Length; i ++) { if(args[i].StartsWith("-w")) { IntPtr hWnd = FindWindow(null, Console.Title); if(hWnd != IntPtr.Zero) { ShowWindow(hWnd, 0); } } } ProcessInformation PSI = new ProcessInformation(); //Checking spotify available. if(PSI.isAvailable()) { NameChangeTracker.create_object(); //Method call to create objects. NameChangeTracker NCT = new NameChangeTracker();//constructor call; IntPtr hWnd = NameChangeTracker.hwnd_spotify; int pid = NameChangeTracker.processid; // Listen for name change changes for spotify(check pid!=0). IntPtr hWinEventHook = SetWinEventHook(0x0800c, 0x800c, IntPtr.Zero, procDelegate, Convert.ToUInt32(pid), 0, 0); // Listen for create window event across all processes/threads on current desktop.(check pid=0) IntPtr hWinEventHook_start = SetWinEventHook(0x00008000,0x00008000,IntPtr.Zero, procDelegate_start, 0, 0, 0); Message msg = new Message(); //GetMessage provides the necessary mesage loop that SetWinEventHook requires. while(GetMessage(ref msg,hWnd,0,0)) { UnhookWinEvent(hWinEventHook); UnhookWinEvent(hWinEventHook_start); } } else //Executed if spotify not running. MessageBox.Show("check spotify running or not","Spotify Not Found",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); }