使用Apple脚本的Pivot监视器。错误:' t Get Button'

发布于 2025-01-17 20:56:50 字数 1272 浏览 2 评论 0原文

在此处输入图像描述在此处输入图像描述

tell application "System Preferences"activateend tell

tell application "System Events"

set _0 to "Standard"
set _90 to "90°"
set _180 to "180°"
set _270 to "270°"

set preference to application process "System Preferences"
click UI element "Displays" of scroll area 1 of window "System Preferences" of preference

delay 1

click button "Display Settings..." of window "Displays" of preference


set monitor to window "LG 4K HDR" of preference
click monitor
set options to pop up button 1 of tab group 1 of monitor
set portrait to value of options is _270

click options
if portrait then
    --switch to landscape mode
    click menu item _0 of menu 1 of options
else
    --switch to portrait mode
    click menu item _270 of menu 1 of options
    delay 5
    click UI element "Confirm" of sheet 1 of monitor
end if

end tell

tell application "System Preferences"quitend tell

结果:错误“系统事件发生错误:无法获取应用程序进程“系统偏好设置”窗口“显示”的按钮“显示设置...”。”编号-1728,来自应用程序进程“系统偏好设置”窗口“显示”的“显示设置...”按钮

上面的代码是一个自动化脚本,可将我的显示器工作到Mojave。我的 mac 更新后就不行了。 其实我对Apple Script了解不多。我从“单击首选项窗口“显示”的“显示设置...”按钮'收到错误。我试图将“按钮”更改为“UI 元素”、索引和系统语言。这不起作用。

enter image description hereenter image description here

tell application "System Preferences"activateend tell

tell application "System Events"

set _0 to "Standard"
set _90 to "90°"
set _180 to "180°"
set _270 to "270°"

set preference to application process "System Preferences"
click UI element "Displays" of scroll area 1 of window "System Preferences" of preference

delay 1

click button "Display Settings..." of window "Displays" of preference


set monitor to window "LG 4K HDR" of preference
click monitor
set options to pop up button 1 of tab group 1 of monitor
set portrait to value of options is _270

click options
if portrait then
    --switch to landscape mode
    click menu item _0 of menu 1 of options
else
    --switch to portrait mode
    click menu item _270 of menu 1 of options
    delay 5
    click UI element "Confirm" of sheet 1 of monitor
end if

end tell

tell application "System Preferences"quitend tell

Result: error "System Events got an error: Can’t get button "Display Settings..." of window "Displays" of application process "System Preferences"." number -1728 from the button "Display Settings..." of window "Displays" of application process "System Preferences"

The above code is an automator script that pivots my monitor works until Mojave. After I update my mac, it doesn't work.
I actually don't know much about Apple Script. I got an error from 'click button "Display Settings..." of window "Displays" of preference'. I was trying to change 'button' as 'UI element', index, and system language. It doesn't work.

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

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

发布评论

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

评论(1

口干舌燥 2025-01-24 20:56:50

我认为错误是因为按钮名称是一个省略号的字符,而不是三重点...

您能否尝试用这一行替换该行(Monterey):

click (first button of window "Displays" of preference whose title starts with "Display Settings")

I think the error is because the button name is an ellipsis character and not triple dots ...

Can you try replacing that line with this instead (Monterey):

click (first button of window "Displays" of preference whose title starts with "Display Settings")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文