且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#如何访问Windows的当前播放

更新时间:2023-12-03 23:36:28

对不起,请问我,但是如果我正确的话,此小部件是Spotify的弹出窗口,不是吗?在这种情况下,您只需要检查spotify进程的 MainWindowsTitle .

Excuse me for my ignorance, but if I am correct, this widget is a pop up of Spotify, isn't this? In that case, you only have to check the MainWindowsTitle of spotify process.

        var spotify = Process.GetProcessesByName("Spotify");
        foreach (var song in spotify)
        {
            Console.WriteLine(song.MainWindowTitle);
        }

        Console.ReadLine();

不要忘记使用using System.Diagnostics;.您将必须检查是否听不到任何歌曲.

Don't forget use using System.Diagnostics;. You will have to check if you don't get any song.

我正在检查此方法是否仍然有效:)

I was checking if this method works yet :)