如何创建菜单栏图标来切换麦克风静音按钮?
我应该使用AppleScript还是Objective-C?我应该在Xcode中创建什么样的项目(如果这是我应该使用的IDE )。感谢您的帮助或指导。
发布于 2011-07-28 23:04:26
试试这个。
property toggled : 0 --0 means the mic is off, 1 means the mic is on
if toggled is 0 then
set volume input volume 100
set toggled to 1
else
set volume input volume 0
set toggled to 0
end if
将其另存为本地Library
文件夹的Scripts
文件夹中的常规脚本文件。
如果您的菜单栏中有一个看起来像滚动的小图标(以前称为Script Menu
),则脚本应该出现在该菜单中的某个位置。如果没有看到图标,请运行AppleScript Utility
(位于/Applications/AppleScript/AppleScript Utility
)并选中Show Script Menu in menu bar
复选框。
现在,要运行它,您只需打开脚本菜单,找到您的脚本,然后单击它一次。有问题吗?问。:)
发布于 2011-07-28 23:10:26
这里有一个简单的方法,因为我们可以直接获取或设置音量的输出静音属性……
set isMuted to output muted of (get volume settings)
if isMuted then
set volume without output muted
else
set volume with output muted
end if
就设置菜单栏切换而言,请按照fireshadow52的建议进行操作。在applescript编辑器的首选项中启用AppleScript菜单,然后将此applescript放在~/库/脚本文件夹中(如果该文件夹不存在,请创建该文件夹)。
编辑:对不起,我看你是想让麦克风静音,而不是把音量调低!是我的错。
https://stackoverflow.com/questions/6864590
复制相似问题