在applescript中将音量增加1

时间:2013-08-11 05:24:14

标签: applescript volume

我正在尝试复制音量键的功能,但是在AppleScript中。我不能让它工作。增加音量按钮将音量设置为最大,减小音量按钮设置为相同。谁知道我做错了什么?继承我的代码:

-- increase volume

on increaseVolumeHandler_(sender)
    tell application "finder"
    set theOutput to output volume of (get volume settings)
    set volume output volume (theOutput + 6.25)
    end tell
    do shell script "afplay /System/Library/Sounds/Pop.aiff"
end increaseVolumeHandler_

-- decrease volume

on decreaseVolumeHandler_(sender)
    tell application "finder"
    set theOutput to output volume of (get volume settings)
    set volume output volume (theOutput - 6.25)
    end tell
    do shell script "afplay /System/Library/Sounds/Pop.aiff"
end decreaseVolumeHandler_

1 个答案:

答案 0 :(得分:1)

这些功能在10.7.5上适用于我,你在试用什么OSX版本?

您还可以删除sender参数和tell finder块的冗余代码,例如

on increaseVolumeHandler_()
    set theOutput to output volume of (get volume settings)
    set volume output volume (theOutput + 6.25)
    do shell script "afplay /System/Library/Sounds/Pop.aiff"
end increaseVolumeHandler_