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

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

    2. <legend id='hVclI'><style id='hVclI'><dir id='hVclI'><q id='hVclI'></q></dir></style></legend>
    3. 在 Windows 7 上以编程方式更改系统范围的扬声器平衡

      Programmatically changing system-wide speaker balance on Windows 7(在 Windows 7 上以编程方式更改系统范围的扬声器平衡)
        <legend id='JwUc4'><style id='JwUc4'><dir id='JwUc4'><q id='JwUc4'></q></dir></style></legend>

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

          2. <tfoot id='JwUc4'></tfoot>
                <bdo id='JwUc4'></bdo><ul id='JwUc4'></ul>

                  <tbody id='JwUc4'></tbody>
              • <small id='JwUc4'></small><noframes id='JwUc4'>

              • 本文介绍了在 Windows 7 上以编程方式更改系统范围的扬声器平衡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何在 Windows 7 上以编程方式更改系统范围的扬声器平衡?

                How can I programmatically change system-wide speaker balance on Windows 7?

                (我只能用 Python 和 AHK 编程.)

                (I can only program in Python and AHK.)

                推荐答案

                快捷方式(由@AndreMiras 创建)-->使用 Pycaw ,Pycaw的用法可以参考这里

                Shortcut(created by @AndreMiras) --> use Pycaw , usage of Pycaw can be find here

                详细方法-->首先通过

                Detailed way -- > First install python package Comtypes either by

                1. 使用 pip install comtypes

                从 https://pypi.python.org/pypi/comtypes 下载然后解压下载文件夹.在提取的文件夹中找到 setup.py.打开cmd进入setup.py的路径,然后运行命令python setup.py install

                download from https://pypi.python.org/pypi/comtypes and then extract the download folder. Find setup.py in extracted folder . Open cmd go to the path of setup.py and then run the command python setup.py install

                现在只需运行 code.py 文件,您可以通过更改函数的第一个参数来调整音量 SetMasterVolumeLevel(-25, None) 第一个参数必须是在 -65 到 0 之间.我已经在 Windows 8 中尝试过此代码,希望它可以在 Windows 7 上运行.

                Now just run the code.py file and you can adjust the volume by changing the first argument of function SetMasterVolumeLevel(-25, None) the first argument must be in between -65 to 0. I have tried this code in windows 8 hopefully it will work on windows 7.

                查看最后几行代码以找到 volume.SetMasterVolumeLevel(-25, None) 并调整 PC 的音量

                See at the last lines of code to find the volume.SetMasterVolumeLevel(-25, None) and to adust the volume of PC

                代码.py

                from comtypes import *
                import comtypes.client
                from ctypes import POINTER
                from ctypes.wintypes import DWORD, BOOL
                
                MMDeviceApiLib = 
                    GUID('{2FDAAFA3-7523-4F66-9957-9D5E7FE698F6}')
                IID_IMMDevice = 
                    GUID('{D666063F-1587-4E43-81F1-B948E807363F}')
                IID_IMMDeviceEnumerator = 
                    GUID('{A95664D2-9614-4F35-A746-DE8DB63617E6}')
                CLSID_MMDeviceEnumerator = 
                    GUID('{BCDE0395-E52F-467C-8E3D-C4579291692E}')
                IID_IMMDeviceCollection = 
                    GUID('{0BD7A1BE-7A1A-44DB-8397-CC5392387B5E}')
                IID_IAudioEndpointVolume = 
                    GUID('{5CDF2C82-841E-4546-9722-0CF74078229A}')
                
                class IMMDeviceCollection(IUnknown):
                    _iid_ = GUID('{0BD7A1BE-7A1A-44DB-8397-CC5392387B5E}')
                    pass
                
                class IAudioEndpointVolume(IUnknown):
                    _iid_ = GUID('{5CDF2C82-841E-4546-9722-0CF74078229A}')
                    _methods_ = [
                        STDMETHOD(HRESULT, 'RegisterControlChangeNotify', []),
                        STDMETHOD(HRESULT, 'UnregisterControlChangeNotify', []),
                        STDMETHOD(HRESULT, 'GetChannelCount', []),
                        COMMETHOD([], HRESULT, 'SetMasterVolumeLevel',
                            (['in'], c_float, 'fLevelDB'),
                            (['in'], POINTER(GUID), 'pguidEventContext')
                        ),
                        COMMETHOD([], HRESULT, 'SetMasterVolumeLevelScalar',
                            (['in'], c_float, 'fLevelDB'),
                            (['in'], POINTER(GUID), 'pguidEventContext')
                        ),
                        COMMETHOD([], HRESULT, 'GetMasterVolumeLevel',
                            (['out','retval'], POINTER(c_float), 'pfLevelDB')
                        ),
                        COMMETHOD([], HRESULT, 'GetMasterVolumeLevelScalar',
                            (['out','retval'], POINTER(c_float), 'pfLevelDB')
                        ),
                        COMMETHOD([], HRESULT, 'SetChannelVolumeLevel',
                            (['in'], DWORD, 'nChannel'),
                            (['in'], c_float, 'fLevelDB'),
                            (['in'], POINTER(GUID), 'pguidEventContext')
                        ),
                        COMMETHOD([], HRESULT, 'SetChannelVolumeLevelScalar',
                            (['in'], DWORD, 'nChannel'),
                            (['in'], c_float, 'fLevelDB'),
                            (['in'], POINTER(GUID), 'pguidEventContext')
                        ),
                        COMMETHOD([], HRESULT, 'GetChannelVolumeLevel',
                            (['in'], DWORD, 'nChannel'),
                            (['out','retval'], POINTER(c_float), 'pfLevelDB')
                        ),
                        COMMETHOD([], HRESULT, 'GetChannelVolumeLevelScalar',
                            (['in'], DWORD, 'nChannel'),
                            (['out','retval'], POINTER(c_float), 'pfLevelDB')
                        ),
                        COMMETHOD([], HRESULT, 'SetMute',
                            (['in'], BOOL, 'bMute'),
                            (['in'], POINTER(GUID), 'pguidEventContext')
                        ),
                        COMMETHOD([], HRESULT, 'GetMute',
                            (['out','retval'], POINTER(BOOL), 'pbMute')
                        ),
                        COMMETHOD([], HRESULT, 'GetVolumeStepInfo',
                            (['out','retval'], POINTER(c_float), 'pnStep'),
                            (['out','retval'], POINTER(c_float), 'pnStepCount'),
                        ),
                        COMMETHOD([], HRESULT, 'VolumeStepUp',
                            (['in'], POINTER(GUID), 'pguidEventContext')
                        ),
                        COMMETHOD([], HRESULT, 'VolumeStepDown',
                            (['in'], POINTER(GUID), 'pguidEventContext')
                        ),
                        COMMETHOD([], HRESULT, 'QueryHardwareSupport',
                            (['out','retval'], POINTER(DWORD), 'pdwHardwareSupportMask')
                        ),
                        COMMETHOD([], HRESULT, 'GetVolumeRange',
                            (['out','retval'], POINTER(c_float), 'pfMin'),
                            (['out','retval'], POINTER(c_float), 'pfMax'),
                            (['out','retval'], POINTER(c_float), 'pfIncr')
                        ),
                
                    ]
                
                class IMMDevice(IUnknown):
                    _iid_ = GUID('{D666063F-1587-4E43-81F1-B948E807363F}')
                    _methods_ = [
                        COMMETHOD([], HRESULT, 'Activate',
                            (['in'], POINTER(GUID), 'iid'),
                            (['in'], DWORD, 'dwClsCtx'),
                            (['in'], POINTER(DWORD), 'pActivationParans'),
                            (['out','retval'], POINTER(POINTER(IAudioEndpointVolume)), 'ppInterface')
                        ),
                        STDMETHOD(HRESULT, 'OpenPropertyStore', []),
                        STDMETHOD(HRESULT, 'GetId', []),
                        STDMETHOD(HRESULT, 'GetState', [])
                    ]
                    pass
                
                class IMMDeviceEnumerator(comtypes.IUnknown):
                    _iid_ = GUID('{A95664D2-9614-4F35-A746-DE8DB63617E6}')
                
                    _methods_ = [
                        COMMETHOD([], HRESULT, 'EnumAudioEndpoints',
                            (['in'], DWORD, 'dataFlow'),
                            (['in'], DWORD, 'dwStateMask'),
                            (['out','retval'], POINTER(POINTER(IMMDeviceCollection)), 'ppDevices')
                        ),
                        COMMETHOD([], HRESULT, 'GetDefaultAudioEndpoint',
                            (['in'], DWORD, 'dataFlow'),
                            (['in'], DWORD, 'role'),
                            (['out','retval'], POINTER(POINTER(IMMDevice)), 'ppDevices')
                        )
                    ]
                
                
                
                
                
                enumerator = comtypes.CoCreateInstance( 
                    CLSID_MMDeviceEnumerator,
                    IMMDeviceEnumerator,
                    comtypes.CLSCTX_INPROC_SERVER
                )
                
                print enumerator
                endpoint = enumerator.GetDefaultAudioEndpoint( 0, 1 )
                print endpoint
                volume = endpoint.Activate( IID_IAudioEndpointVolume, comtypes.CLSCTX_INPROC_SERVER, None )
                print volume
                print volume.GetMasterVolumeLevel()
                print volume.GetVolumeRange()
                #volume.SetMasterVolumeLevel(-65, None) uncomment for 0 volume
                #volume.SetMasterVolumeLevel(-1, None) uncomment for full volume
                volume.SetMasterVolumeLevel(-25, None) #Change the first argument for controlling the volume remember it should be -ve not less than -65
                

                这篇关于在 Windows 7 上以编程方式更改系统范围的扬声器平衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                <legend id='aYqVK'><style id='aYqVK'><dir id='aYqVK'><q id='aYqVK'></q></dir></style></legend>

                1. <tfoot id='aYqVK'></tfoot>
                  • <bdo id='aYqVK'></bdo><ul id='aYqVK'></ul>

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

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

                          <tbody id='aYqVK'></tbody>