Applescript 应用程序描述显示首选项窗格

Applescript 应用程序描述显示首选项窗格,applescript,Applescript,我正在尝试编写一个简单的脚本来更改显示器的颜色配置文件。我已经打开了Displays pref窗格并选择了Color选项卡,但随后遇到了实际问题。遗憾的是,我的GUI脚本缺乏,我不知道如何选择显示配置文件。滚动窗口中仅显示两个配置文件(“iMac”和“my Calibration 10-14”)。理想情况下,我希望脚本在每次运行时在两个概要文件之间切换。以下是我目前掌握的情况: tell application "System Preferences" activate set

我正在尝试编写一个简单的脚本来更改显示器的颜色配置文件。我已经打开了Displays pref窗格并选择了Color选项卡,但随后遇到了实际问题。遗憾的是,我的GUI脚本缺乏,我不知道如何选择显示配置文件。滚动窗口中仅显示两个配置文件(“iMac”和“my Calibration 10-14”)。理想情况下,我希望脚本在每次运行时在两个概要文件之间切换。以下是我目前掌握的情况:

tell application "System Preferences"
    activate
    set current pane to pane id "com.apple.preference.displays"
    reveal (first anchor of current pane whose name is "displaysColorTab")
end tell

任何帮助或建议都将不胜感激。我正在运行OS 10.11.5

这个良好的开端离你还不远。然后,脚本应该找到哪一行包含概要文件1(iMac),哪一行包含概要文件2(您的概要文件)。 如果选择了包含纵断面1的行,请选择包含纵断面2的行

这就是贝娄的剧本。您必须在Prof1和Prof2中调整两个配置文件。该脚本使用“contains”,因此您不必设置prof1/2的完整值,只需其中的一部分就足够了

我还查找两个概要文件中有一个不存在的情况(然后脚本什么也不做)


非常感谢@pbell,不幸的是这不起作用。以下是我在运行脚本时得到的结果:错误“System Events got a error:Can't get tab group 1 of window 1 of application process \“System Preferences\”。索引无效。应用程序进程“System Preferences”窗口1选项卡组1的编号-1719正在我的系统imac27(10.11.5)上工作。如果你有相同的版本,你应该有相同的接口。我想可能是你的硬件延迟了。尝试在“设置Prof1”之前添加一行“delay 1”。。。这将为你的Mac电脑留出一些时间来打开pref窗格。它现在工作得很好!我所做的唯一更改是在“告诉前窗口选项卡组1的滚动区域1的表格”行之前添加一个“延迟0.5”,感谢您的帮助!!!
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.displays"
reveal (first anchor of current pane whose name is "displaysColorTab")
end tell

set Prof1 to "iMac" -- define the profile 1
set Prof2 to "ACES CG Linear" -- define the profile 2
set {Row1, Row2, Sel1} to {0, 0, false} -- init values

tell application "System Events"
tell application process "System Preferences"
    tell table of scroll area 1 of tab group 1 of front window
        -- search the 2 profiles in the list of rows
        repeat with I from 1 to (count of rows)
            set N to (value of static text of row I) as string
            if N contains Prof1 then
                set Row1 to I
                set Sel1 to selected of row I
            end if
            if N contains Prof2 then set Row2 to I
        end repeat
        -- make the toggle !
        if Sel1 then -- profile 1 selected, then select profile 2, if found
            if Row2 > 0 then set selected of row Row2 to true
        else -- profile 1 not yet selected, : select profile 1 if found
            if Row1 > 0 then set selected of row Row1 to true
        end if
    end tell -- table
end tell --process Sys Pref 
end tell -- System Events