AppleScript 打开终端设置的特定部分

问题描述 投票:0回答:1

我正在尝试打开终端设置的“配置文件”部分(图片)。

Terminal settings

这是我的脚本:

tell application "Terminal"
    activate
    delay 1
    tell application "System Events"
        keystroke "," using command down
        delay 1
        tell process "Terminal"
            click menu item "Profils" of menu "Terminal" of menu bar item "Terminal" of menu bar 1
        end tell
    end tell
end tell

但是脚本只打开设置窗口,而不是我想要的部分。

macos terminal applescript settings
1个回答
0
投票

打开终端首选项后,请尝试以下操作:

tell application "Terminal"
    tell application "System Events" to tell process "Terminal"
        set w to window 1
        set bp to button "Profiles" of toolbar 1 of w
        perform action "AXPress" of bp
    end tell
end tell

您可能需要将按钮字符串更改为“Profils”。

我是如何到达那里的。请注意,下面的每个命令都会返回一堆项目。如果您浏览这些项目,您可能会找出下一个项目来获取其元素。

        set w to window 1
        
        UI elements of w
        --> toolbar 1 of window "General"

        UI elements of toolbar 1 of w
        --> button "Profiles" of toolbar 1 of window "General" 

此外,您还可以使用

click
命令

        click at {80, 80}
        --> button "Profiles" of toolbar 1 of window "General" of application process "Terminal" of application "System Events"     
© www.soinside.com 2019 - 2024. All rights reserved.