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 sl开发者_如何学Goowly with some python code like this:
set_volume(0)
for i in range(50):
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)
...
>>>
精彩评论