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

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

      1. <tfoot id='CsJGr'></tfoot>

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

        How can I get the title of the currently playing media in windows 10 with python(如何使用 python 在 Windows 10 中获取当前正在播放的媒体的标题)
      2. <tfoot id='Tsz0B'></tfoot>
      3. <small id='Tsz0B'></small><noframes id='Tsz0B'>

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

            <legend id='Tsz0B'><style id='Tsz0B'><dir id='Tsz0B'><q id='Tsz0B'></q></dir></style></legend>

              <bdo id='Tsz0B'></bdo><ul id='Tsz0B'></ul>
                  <tbody id='Tsz0B'></tbody>

                  本文介绍了如何使用 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 中获取当前正在播放的媒体的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                  Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                  How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                  Centering an object in Kivy(在 Kivy 中将对象居中)
                  How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                  Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)
                  • <bdo id='oNoKG'></bdo><ul id='oNoKG'></ul>

                      <tfoot id='oNoKG'></tfoot>
                        <tbody id='oNoKG'></tbody>

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

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