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);
    }
 //Create object.
 public static void create_object()
 {
     PSI = new ProcessInformation();
     TMD = new TrackMetadata();
     notify = new Notify();
     notify.createGrowlObject();
 }
Пример #3
0
    //Constructor for NameChangeTracker
    public NameChangeTracker(ToastForm myForm)
    {
        NameChangeTracker.myForm = myForm;
        psi = new ProcessInformation();
        tmd = new TrackMetadata();
        notify = new Notify();
        //Console.WriteLine(psi.getSpotifyPID());

        // Listen for name change changes for spotify(check pid!=0).
        hWinEventHook = SetWinEventHook(0x0800c, 0x800c, IntPtr.Zero, procDelegate, Convert.ToUInt32(psi.getSpotifyPID()), 0, 0);
        // Listen for create window event across all processes/threads on current desktop.(check pid=0)
        hWinEventHook_start = SetWinEventHook(0x00008000, 0x00008000, IntPtr.Zero, procDelegate_start, 0, 0, 0);
    }
 //Constructor
 public TrackMetadata()
 {
     PSI = new ProcessInformation();
                 hWnd = PSI.getSpotify();
                 processid = PSI.getProcessId(hWnd);
 }
    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);
    }