AppleScript 如何处理颜色?

How is color handled in AppleScript?

我正在尝试使用 AppleScript 更改 Finder 的背景颜色 window 并遇到了这段代码片段,它似乎有效...但是,我不确定颜色数组...

tell the icon view options of the front Finder window
    set the background color to {52942, 54484, 31097}
end tell

{52942, 54484, 31097} AppleScript 魔法指的是什么?它看起来不像 RGB 对我来说......我如何才能得到特定的东西,比如红色 (#ff0000 | 255, 0, 0),或者更好的是,霓虹青色 (#00f6ff | 0, 246, 255)?

RGB 颜色有四种不同的数字表示。

Notation -- RGB triplet (红色)

1- 算术 -- (1.0, 0.0, 0.0)

2- 百分比 -- (100%, 0%, 0%)

3- 每个通道 8 位数字 -- (255, 0, 0) 或有时 #FF0000(十六进制)

4- 每通道数字 16 位 -- (65535, 0, 0)

组件值通常存储为 0 到 255 范围内的整数,这是单个 8 位字节可以提供的范围。这些通常表示为十进制或十六进制数。

将整数 (standard RGB value) 乘以 257 得到每个通道数字 16 位的值 (AppleScript )

您不必将颜色用作数字。有一个显示系统颜色选择器的选择颜色命令。

tell application "Finder"
    activate
    tell the icon view options of the front window
        set the background color to choose color
    end tell
end tell

... 但出于某种原因,在 运行 此脚本之后,您将必须关闭然后重新打开 Finder window 才能看到颜色变化。