我一直在使用pynput。
大家好,我是9岁的库尔特·李(Kurt Lee),我想问一下如何使用pynput键盘设法修复此音量栏。
from pynput.keyboard import Key, Listener
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
def volume_controller(control): #
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
vol = volume.SetMasterVolumeLevel(control, None)
return vol
# Volume Bar
VolumeMax = "▁ ▂ ▃ ▄ ▅ ▆ █ 100%" + str(volume_controller(-0))
# Volume86 = "▁ ▂ ▃ ▄ ▅ ▆ 86%" + str(volume_controller(-2.3))
# Volume72 = "▁ ▂ ▃ ▄ ▅ 72%" + str(volume_controller(-5))
# Volume58 = "▁ ▂ ▃ ▄ 58%" + str(volume_controller(-8))
# Volume44 = "▁ ▂ ▃ 44%" + str(volume_controller(-12.2))
# Volume30 = "▁ ▂ 30%" + str(volume_controller(-17.9))
# Volume16 = "▁ 16%" + str(volume_controller(-26.5))
VolumeZero = "Muted" + str(volume_controller(-60))
def check_key(key):
keyword = key
if keyword is Key.up:
print('UP')
print(VolumeMax)
elif keyword is Key.down:
print("Down")
VolumeZero
# Collect events until released
with Listener(on_press=check_key) as l:
l.join()
我一直在修复一个星期时遇到困难,我非常需要帮助。例如,我目前的音量是100%,即最大音量,我想通过单击下降来将其降低到86%,然后下一个是将其提高到100%或更低至72%。
Good day everyone, I am Kurt lee, 9 years old and I would like to ask how can I manage to fix this volume bar using pynput keyboard.
from pynput.keyboard import Key, Listener
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
def volume_controller(control): #
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
vol = volume.SetMasterVolumeLevel(control, None)
return vol
# Volume Bar
VolumeMax = "▁ ▂ ▃ ▄ ▅ ▆ █ 100%" + str(volume_controller(-0))
# Volume86 = "▁ ▂ ▃ ▄ ▅ ▆ 86%" + str(volume_controller(-2.3))
# Volume72 = "▁ ▂ ▃ ▄ ▅ 72%" + str(volume_controller(-5))
# Volume58 = "▁ ▂ ▃ ▄ 58%" + str(volume_controller(-8))
# Volume44 = "▁ ▂ ▃ 44%" + str(volume_controller(-12.2))
# Volume30 = "▁ ▂ 30%" + str(volume_controller(-17.9))
# Volume16 = "▁ 16%" + str(volume_controller(-26.5))
VolumeZero = "Muted" + str(volume_controller(-60))
def check_key(key):
keyword = key
if keyword is Key.up:
print('UP')
print(VolumeMax)
elif keyword is Key.down:
print("Down")
VolumeZero
# Collect events until released
with Listener(on_press=check_key) as l:
l.join()
I've been having trouble fixing this for a week and I badly need help please. For example, my current volume is 100% which is the Volume max, and I would like to lower it to 86% by clicking down then the next one is to go up to 100% or lower to 72%.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论