Exemple #1
0
    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);
        }
    }
Exemple #2
0
    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);
        }
    }