automation - 苹果脚本旋转显示

标签 automation rotation applescript display

您好,我正在尝试编写一个 Apple 脚本来在 macOS 12.3 中旋转显示器

我已经查看了以下内容,但苹果更改了显示菜单

https://apple.stackexchange.com/questions/319938/keyboard-shortcut-flip-screen

我在选择外部显示器的单元格菜单项时遇到问题

我尝试过使用辅助功能检查器,但我不知道如何让它发挥作用

display menu

Accessibility Inspector

    if running of application "System Preferences" then
    quit application "System Preferences"
    delay 1
end if

tell application "System Preferences"
    reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
    delay 1
    tell application "System Events"
        tell process "System Preferences"
            tell window 1
                click button "Display Settings…"
                tell cell of outline row of outline 1 of scroll area 1 of sheet 1 of window 1
                     set selected to false
                end tell
                
                
                
                --tell pop up button "Rotation:" of tab group 1 of (first window whose name is "LG HDR 4K") of application process "System Preferences"
                --  if (value) contains "Standard" then
                --          click
                --          click menu item "90°" of menu 1
                --          my clickConfirmButton()
                --      else
                --          click
                --          click menu item "Standard" of menu 1
                --      end if
                --  end tell
            end tell
        end tell
    end tell
end tell

最佳答案

由 oluckyman 对 this gist 的评论提供

            tell sheet 1
                select row 2 of outline 1 of scroll area 1 -- the row with external monitor
                tell pop up button "Rotation:"
                    set theRotation to value of it
                    click
                    tell menu "Rotation:"
                        if theRotation = "Standard" then
                            click menu item "90°" -- your preferred rotation 
                        else
                            click menu item "Standard"
                        end if
                    end tell
                end tell
                delay 1
                if exists of button "Confirm" of sheet 1 then
                    click button "Confirm" of sheet 1
                end if
                click button "Done"
            end tell

https://gist.github.com/v1c77/96affa87de94045d29cdc5f9cb8c1847

关于automation - 苹果脚本旋转显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71527649/

相关文章:

Perl:Win32::OLE 和 Microsoft Outlook - 有效地遍历电子邮件附件

java - 自动(半)创建单元测试?

java - 绘制旋转三角形

javascript - 将 html 代码结果保存为 .gif 或其他视频

python - 如何为 pygame.transform.rotate() 设置枢轴点(旋转中心)?

macos - 你如何在 mac preview 10.7 中重新加载文件?

google-chrome - 用于触发 Google Chrome 语音搜索键盘快捷键的 OSX 脚本

用于查看文件是否在今天创建的 Python 脚本,发送包含结果的电子邮件

linux - 使用 Applescript 或 Linux 从文件名中删除字符串

c# - 如何在 C# (MVC 3) 中自动运行带有 3 个参数的批处理命令?