如何在 Mac OSX Lion 中创建菜单栏切换?

发布于 2024-11-27 00:09:14 字数 121 浏览 0 评论 0原文

我将如何创建一个菜单栏图标来切换麦克风静音按钮?

我会使用 AppleScript 还是 Objective-C?我应该在 Xcode 中创建什么样的项目(如果那是我应该使用的 IDE)。感谢您的任何帮助或指导。

How would I go about creating a menu bar icon to toggle the microphone mute button?

Would I use AppleScript or Objective-C? What kind of project do I create in Xcode (if that's the IDE I should use). Thanks for any help or direction.

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

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

发布评论

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

评论(2

薄情伤 2024-12-04 00:09:14

试试这个...

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 文件夹中的常规脚本文件。

如果菜单栏中有一个看起来像卷轴的小图标(以前称为“脚本菜单”),则脚本应该出现在该菜单中的某个位置。如果您没有看到该图标,请运行 AppleScript Utility(位于 /Applications/AppleScript/AppleScript Utility)并选中在菜单栏中显示脚本菜单< /代码> 复选框。

现在,运行它所需要做的就是打开脚本菜单,找到您的脚本,然后单击它一次。问题?问。 :)

Try this...

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

Save this as a regular script file in the Scripts folder of the local Library folder.

If you have a little icon in your menubar that looks like a scroll (formerly known as the Script Menu), the script should appear somewhere in that menu. If you don't see the icon, run AppleScript Utility (located at /Applications/AppleScript/AppleScript Utility) and check the Show Script Menu in menu bar checkbox.

Now, all you have to do to run it is open up the Script Menu, find your script, and just click on it once. Questions? Ask. :)

甜柠檬 2024-12-04 00:09:14

这是一个简单的方法,因为我们可以直接获取或设置音量的输出静音属性...

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 放入 ~/Library/Scripts 文件夹中(如果该文件夹不存在,则创建该文件夹)。

编辑:抱歉,我看到您希望麦克风静音而不是音量!我的错误。

Here's a simple way because we can get or set the output muted property of the volume directly...

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

As far as setting a menubar toggle, do as fireshadow52 suggested. Enable the applescript menu from the preferences in AppleScript Editor then place this applescript in the ~/Library/Scripts folder (create the folder if it doesn't exist).

EDIT: Sorry, I see you want the microphone muted not the volume! My mistake.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文