• <legend id='ZYtq0'><style id='ZYtq0'><dir id='ZYtq0'><q id='ZYtq0'></q></dir></style></legend>

    <tfoot id='ZYtq0'></tfoot>
      <bdo id='ZYtq0'></bdo><ul id='ZYtq0'></ul>

    1. <small id='ZYtq0'></small><noframes id='ZYtq0'>

      1. <i id='ZYtq0'><tr id='ZYtq0'><dt id='ZYtq0'><q id='ZYtq0'><span id='ZYtq0'><b id='ZYtq0'><form id='ZYtq0'><ins id='ZYtq0'></ins><ul id='ZYtq0'></ul><sub id='ZYtq0'></sub></form><legend id='ZYtq0'></legend><bdo id='ZYtq0'><pre id='ZYtq0'><center id='ZYtq0'></center></pre></bdo></b><th id='ZYtq0'></th></span></q></dt></tr></i><div id='ZYtq0'><tfoot id='ZYtq0'></tfoot><dl id='ZYtq0'><fieldset id='ZYtq0'></fieldset></dl></div>

        如何使用 python 在 Windows 10 中获取当前正在播放的

        时间:2023-10-08

              <tfoot id='Rd3mX'></tfoot>

                <small id='Rd3mX'></small><noframes id='Rd3mX'>

                <i id='Rd3mX'><tr id='Rd3mX'><dt id='Rd3mX'><q id='Rd3mX'><span id='Rd3mX'><b id='Rd3mX'><form id='Rd3mX'><ins id='Rd3mX'></ins><ul id='Rd3mX'></ul><sub id='Rd3mX'></sub></form><legend id='Rd3mX'></legend><bdo id='Rd3mX'><pre id='Rd3mX'><center id='Rd3mX'></center></pre></bdo></b><th id='Rd3mX'></th></span></q></dt></tr></i><div id='Rd3mX'><tfoot id='Rd3mX'></tfoot><dl id='Rd3mX'><fieldset id='Rd3mX'></fieldset></dl></div>

                  <tbody id='Rd3mX'></tbody>
                <legend id='Rd3mX'><style id='Rd3mX'><dir id='Rd3mX'><q id='Rd3mX'></q></dir></style></legend>
                • <bdo id='Rd3mX'></bdo><ul id='Rd3mX'></ul>

                  本文介绍了如何使用 python 在 Windows 10 中获取当前正在播放的媒体的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  无论何时在 Windows 10 中播放音频,无论是来自 Spotify、Firefox 还是游戏.当你打开音量时,windows 的角落里会显示歌曲艺术家、标题以及正在播放的应用程序,如下图所示(有时它只显示游戏正在播放声音时哪个应用程序正在播放声音)

                  Whenever audio is playing in windows 10, whether it is from Spotify, Firefox, or a game. When you turn the volume, windows has a thing in the corner that says the song artist, title, and what app is playing like the photo below (sometimes it only says what app is playing sound if a game is playing the sound)

                  我想以某种方式使用 python 获取这些数据.我的最终目标是,如果应用程序正在播放我不喜欢的内容(例如广告),则将其静音.

                  I want to somehow get that data with python. My end goal, is to mute an application if it is playing something I don't like, such as an advertisement.

                  推荐答案

                  我正在获取windows的标题来获取歌曲信息.通常,应用程序名称显示在标题中,但在播放歌曲时,会显示歌曲名称.这是一个返回所有窗口标题列表的函数.

                  I am getting the titles of the windows to get the song information. Usually, the application name is displayed in the title, but when it is playing a song, the song name is shown. Here is a function that returns a list of all the window titles.

                  from __future__ import print_function
                  import ctypes
                  def get_titles(): 
                      EnumWindows = ctypes.windll.user32.EnumWindows
                      EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
                      GetWindowText = ctypes.windll.user32.GetWindowTextW
                      GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
                      IsWindowVisible = ctypes.windll.user32.IsWindowVisible
                      
                      titles = []
                      def foreach_window(hwnd, lParam):
                          if IsWindowVisible(hwnd):
                              length = GetWindowTextLength(hwnd)
                              buff = ctypes.create_unicode_buffer(length + 1)
                              GetWindowText(hwnd, buff, length + 1)
                              titles.append(buff.value)
                          return True
                      EnumWindows(EnumWindowsProc(foreach_window), 0)
                      return titles
                  

                  这篇关于如何使用 python 在 Windows 10 中获取当前正在播放的媒体的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:弃用警告:在 Windows 10 系统上通过 Selenium 使用 C 下一篇:Spark 安装 - 错误:无法找到或加载主类 org.apache.

                  相关文章

                  最新文章

                • <legend id='rSd4Z'><style id='rSd4Z'><dir id='rSd4Z'><q id='rSd4Z'></q></dir></style></legend>
                • <i id='rSd4Z'><tr id='rSd4Z'><dt id='rSd4Z'><q id='rSd4Z'><span id='rSd4Z'><b id='rSd4Z'><form id='rSd4Z'><ins id='rSd4Z'></ins><ul id='rSd4Z'></ul><sub id='rSd4Z'></sub></form><legend id='rSd4Z'></legend><bdo id='rSd4Z'><pre id='rSd4Z'><center id='rSd4Z'></center></pre></bdo></b><th id='rSd4Z'></th></span></q></dt></tr></i><div id='rSd4Z'><tfoot id='rSd4Z'></tfoot><dl id='rSd4Z'><fieldset id='rSd4Z'></fieldset></dl></div>
                    • <bdo id='rSd4Z'></bdo><ul id='rSd4Z'></ul>

                    <tfoot id='rSd4Z'></tfoot>

                  1. <small id='rSd4Z'></small><noframes id='rSd4Z'>