I like to use the Natural scroll direction when using a trackpad, but the normal scroll direction when using a mouse.
I work with a dock at home with a full mouse and keyboard setup, but frequently take my MacBook out into the world with me. I found it super frustrating to have to manually change the scroll direction every single time I did this and I wanted to share it - this is by far my most used Macro.
The Macro is triggered with a Hotkey that I have bound to ⌥S
I have edited another Macro that was similar to this that I found on here awhile ago and just cannot locate to give credit. That went through the mouse system preference to change the direction, but that wouldn't work if you didn't have a mouse connected. If you do know where it came from, please let me know and I'll link it.
I guess Bluetooth devices will not work with USB trigger.
The device name shows under system devices for bluetooth, so I wonder if there is a way to get this working.
I end up with a more complex macro, which is still based on your AppleScript. I check for KBM engine start, unlock event, mouse connect/disconnect. It was a bit tricky because it looks like if you have 2 profiles and toggle between them, variables may conflict with each other
Anyway here is my take if anyone want to try (macro is disabled by default)
So the upgrade to Ventura looks like it's broken this. I've managed to figure out how to open and find the trackpad pane, but It's throwing an invalid index error. Here is the script that I have so far:
tell application "System Settings"
open "x-apple.systempreferences:com.apple.Trackpad-Settings.extension"
end tell
tell application "System Events" to tell process "System Settings"
click radio button 2 of tab group 1 of window 1
click checkbox 1 of tab group 1 of window 1
end tell
quit application "System Settings"
but it is throwing the following error: error "System Events got an error: Can’t get tab group 1 of window 1 of process "System Settings". Invalid index." number -1719 from tab group 1 ofwindow 1 ofprocess "System Settings"
I've been able to partially fix the applescript, although I don't like it as much since it brings the system settings panel to the front to execute the script. Any help in keeping the process in the background like it used to be would be appreciated. Here's the Script
tell application "System Settings"
activate
end tell
open location "x-apple.systempreferences:com.apple.Trackpad-Settings.extension"
delay 0.5
tell application "System Events" to tell process "System Settings"
click radio button 2 of tab group 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Trackpad"
click checkbox 0 of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Trackpad"
end tell
quit application "System Settings"
I'm still on Mojave, so you'll need to change “System Preferences” to “System Settings” in the script.
I won't guarantee the object hierarchies are correct for your version of macOS either, but they will possibly work as is and should otherwise be amenable to adjustment.
This script does not require the app to activate and become visible.
A lot of people think one-line System Events references are cool, and a structured tree is gross – but I'll tell you what – when you need to make changes the tree is way easier to work with.
-Chris
--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2023/01/26 18:05
# dMod: 2023/01/26 18:05
# Appl: System Events, System Preferences
# Task: Toggle “Natural” Scroll Direction in System Preferences
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @System_Preferences
# Test: macOS 10.14.6 Mojave
# Vers: 1.0
--------------------------------------------------------
set |timeOut| to 5
set _cntr to 0
tell application "System Preferences"
if not running then run
reveal pane id "com.apple.preference.trackpad"
repeat until window "Trackpad" exists
set _cntr to _cntr + 0.25
if _cntr > |timeOut| then error "Script has timed-out!"
delay 0.25
end repeat
end tell
tell application "System Events"
tell application process "System Preferences"
tell window "Trackpad"
tell tab group 1
tell radio button "Scroll & Zoom"
perform action "AXPress"
end tell
tell checkbox 1
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
tell application "System Events" to quit
--------------------------------------------------------
Run, don’t walk over to Late Night Software and download Script Debugger. Even if you don’t buy a copy and instead use the freeware “Lite” version it is far, far superior to Apple’s painfully decrepit and neglected Script Editor.
Regex find/replace support.
Step through your code line by line (commercial only).
This app does the trick, and I am DELIGHTED. The amount of time I wasted trying to figure out which mode I like best vs the name on the screen, only to find out that when I switched one, I was switching the other, is insane...