gpt4 book ai didi

list - 在 Applescript 中实现键盘音量控制按钮 - 在循环内设置音量不起作用

转载 作者:行者123 更新时间:2023-12-04 17:28:52 25 4
gpt4 key购买 nike

背景

我有一个 MacAlly IceKey 键盘。此键盘具有需要驱动程序才能运行的音量按钮。这个驱动程序自 2006 年以来就没有更新过,我怀疑它是我最近在 Mac OS X 10.6.1 下遇到的反复出现的内核 panic 的根源。所以,它出去了;但我想要我的音量键回来!

用妙ControllerMate ,我可以对这些键进行编程以执行任何操作,包括运行 applescript 脚本。所以,我正在尝试实现该功能。

set volume 命令(Standard Additions 的一部分)允许您将音量设置为 0 到 100 之间的任何值。Apple 键盘音量键允许选择总共 17 个音量设置(包括 0)。我认为复制此行为的最简单方法是保留允许的音量设置列表,并从中获取下一个最大(或最小)的设置。

问题

它不起作用。以下脚本:

set volumesList to {0, 6, 12, 18, 25, 31, 37, 43, 50, 56, 62, 68, 75, 81, 87, 93, 100}
set sysVolume to get volume settings

repeat with curVolume in volumesList
if (curVolume > (output volume of sysVolume)) then
set volume output volume (contents of curVolume)
exit repeat
end if
end repeat

get volume settings

...仅当系统音量小于 43 时才有效。系统似乎将“50”解释为“49”;这与我的脚本的音量一样高。如果音量开始高于 50,则我的脚本无效。踢球者?如果删除“退出重复”语句,系统音量将设置为 100 - 正如您所期望的那样。

(很遗憾,AppleScript 有时很奇怪。)

有任何想法吗?

积分奖励

让它也显示音量叠加会非常棒。有谁知道如何做到这一点?它甚至不需要通过 AppleScript;如果需要的话,我很高兴在命令行工具中粘贴一些 Cocoa 代码。

最佳答案

我不知道如何让半透明覆盖显示出来,但这至少会在调高音量的同时播放系统提示音:

set currentVolume to output volume of (get volume settings)
set newVolume to (currentVolume + (100 / 17)) as integer
set volume output volume newVolume
beep

更换 +-在您的音量降低脚本中。
set volume output似乎会自动调整 (0, 100) 限制之外的值。

更新:您可以使用 Growl's AppleScript support显示某种叠加:
tell application "GrowlHelperApp"

register as application "Volume Change" ¬
all notifications {"Volume Change"} ¬
default notifications {"Volume Change"} ¬
icon of application "Script Editor"

notify with name "Volume Change" ¬
title "Volume Up" ¬
description "Volume is now " & output volume of (get volume settings) ¬
application name "Volume Change"

end tell

关于list - 在 Applescript 中实现键盘音量控制按钮 - 在循环内设置音量不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1449543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com