在Python中调整OSX系统音频音量

发布于 2024-08-27 15:19:42 字数 390 浏览 2 评论 0原文

我想通过 python 脚本调整 OSX 中的系统音量。 这个关于实现键盘快捷键的问题告诉我如何在 applescript 中做到这一点,但我真的很想从我的 python 脚本中做到这一点,而不使用 os.system、popen 等。理想情况下,我想使用一些像这样的 python 代码慢慢增加音量:

set_volume(0)
for i in range(50):
  set_volume(i*2)
  time.sleep(1)

I would like to adjust the system audio volume in OSX from a python script. This question about implementing keyboard shortcuts tells me how to do it in applescript, but I'd really like to do it from my python script without using os.system, popen, etc. Ideally I'd like to ramp up the volume slowly with some python code like this:

set_volume(0)
for i in range(50):
  set_volume(i*2)
  time.sleep(1)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

儭儭莪哋寶赑 2024-09-03 15:19:42

使用 appscript 控制 StandardAdditions 脚本添加 设置音量 命令:

>>> from osax import *
>>> import time
>>> sa = OSAX()
>>> for i in range(50):
...   sa.set_volume(i*2)
...   time.sleep(1)
... 
>>> 

Use appscript to control the StandardAdditions scripting addition set volume command:

>>> from osax import *
>>> import time
>>> sa = OSAX()
>>> for i in range(50):
...   sa.set_volume(i*2)
...   time.sleep(1)
... 
>>> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文