如何打开滚动和缩放并更改自然滚动? [AppleScript]

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

我正在尝试编写一个简单的苹果脚本来更改自然滚动。

我编写了一个可以从系统设置打开触控板的代码,但不知道如何选择滚动和缩放以及十个更改自然滚动...

你能帮我吗?另外,也许我可以在终端中做?我试过:

$ defaults write -g com.apple.swipescrolldirection -bool false 
但它不起作用...

这是我已经写过的:

tell application "System Settings"
    activate
end tell
tell application "System Events"
    tell process "System Settings"
        click menu item "Trackpad" of menu "View" of menu bar 1
    end tell
end tell

并且工作正常(系统设置中的触控板显示)

谢谢!

ios applescript
1个回答
0
投票
tell application "System Settings"
    activate
    delay 1
    set current pane to pane id "com.apple.Trackpad-Settings.extension"
    delay 1
end tell

tell application "System Events"
    tell process "System Settings"
        tell window "Trackpad"
            tell group 1 of group 2 of splitter group 1 of group 1
                click (radio buttons of tab group 1 where description is "Scroll & Zoom")
                delay 1
                click checkbox "Natural scrolling" of group 1 of scroll area 1
            end tell
        end tell
    end tell
end tell

请注意,下次 Apple 在这些地方更改系统设置 UI 时,这将会中断。

此外,

delay 1
非常慷慨,您可能会接受
delay 0.5
,具体取决于您的系统速度。当然
delay
是一种懒惰的出路,更好的方法是
repeat until ...
并等待 UI 实际更改,而不是等待任意一段时间。

您可以通过插入

return UI elements of THING
return properties of THING
来使用 Apple 脚本,并查看脚本编辑器的结果框。

© www.soinside.com 2019 - 2024. All rights reserved.