在我的 Windows 7 计算机上以编程方式调整音量 [英] Programmatically adjust the volume on my Windows 7 computer

查看:35
本文介绍了在我的 Windows 7 计算机上以编程方式调整音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能使 Tkinter 比例与计算机的体积相对应.就是说,把比例尺往上拉,电脑的音量会不会变大?这只是我草拟的一些随机代码.我运行的是 64 位 Windows 7 操作系统.

I was wondering if it was possible to make a Tkinter scale correspond with the volume of the computer. In other words, by dragging the scale up, could the volume of the computer increase? Here is just some random code I drew up. I am running a a 64-Bit Windows 7 operating system.

1    from Tkinter import *
2
3    def sel():
4       selection = "Value = " + str(var.get())
5       label.config(text = selection)
6
7    root = Tk()
8    var = DoubleVar()
9    scale = Scale( root, variable = var )
10   scale.pack(anchor=CENTER)
11
12   button = Button(root, text="Get Scale Value", command=sel)
13   button.pack(anchor=CENTER)
14
15   label = Label(root)
16   label.pack()
17
18   root.mainloop()

老实说,我不在乎它是否无法完成.我只是想知道这是否可能.感谢大家的帮助!

Honestly I do not care if it can't be done. I was just wondering if it was possible. Thanks for all the help!

推荐答案

我知道这是一个老问题,但最佳答案超出了大多数人的能力范围.我用 python 编写是为了避免使用 C,而不是拥抱它.

I know that this is an old question, but the top answer is out of the scope of most people's abilities. I write in python to avoid C, not to embrace it.

现实的最佳答案是为命令行安装一些东西(例如 Nircmd) 然后使用 subprocess(预安装)来调用它,例如 subprocess.getoutput("nircmd setsysvolume 0") 希望这能帮助其他找到它的人.

The realistic best answer is to install something for the command line (e.g. Nircmd) and then to use subprocess (preinstalled) to call it e.g.subprocess.getoutput("nircmd setsysvolume 0") Hope this helps anyone else who finds it.

这篇关于在我的 Windows 7 计算机上以编程方式调整音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆