예제 #1
0
        public string GetCurrentTrack()
        {
            //Retrieves the length, in characters, of the specified window's title bar text
            int           length = DLL_Methods.GetWindowTextLength(psi.getSpotifyWindowHandle());
            StringBuilder sb     = new StringBuilder(length + 1);

            //Copies the text of the specified window's title bar (if it has one) into a buffer
            DLL_Methods.GetWindowText(psi.getSpotifyWindowHandle(), sb, sb.Capacity);

            return(sb.ToString().Replace("Spotify", "").TrimStart(' ', '-').Trim());
        }
예제 #2
0
    private static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint
                                     dwEventThread, uint dwmsEventTime)
    {
        if ((idObject != 0) || (idChild != 0))
        {
            return;
        }
        if (!psi.isSpotifyAvailable() || hwnd.ToInt32() != psi.getSpotifyWindowHandle().ToInt32())
        {
            return;
        }
        string track  = tmd.getTrack();
        string artist = tmd.getArtist();

        if (track != null || artist != null)
        {
            //Console.WriteLine(artist + " - " + track);
            notify.showViaToast(myForm, track, artist);
            //Console.WriteLine("Finished Showing");
        }
    }