Skip to content

Instantly share code, notes, and snippets.

@denisenepraunig
Last active September 11, 2019 07:40
Show Gist options
  • Save denisenepraunig/ccea0887135509d3cb23304875a3831a to your computer and use it in GitHub Desktop.
Save denisenepraunig/ccea0887135509d3cb23304875a3831a to your computer and use it in GitHub Desktop.
swap right and left mouse button apple magic mouse macOS Mojave
# https://apple.stackexchange.com/questions/89721/swap-mouse-button-using-applescript
# this is my first script - so maybe some things are not the best way to do it 🙈
# I didn't use defaults -currentHost write .GlobalPreferences com.apple.mouse.swapLeftRightButton -bool false
# because you need to logout and login again
# ATTENTION: sometimes it works, sometimes it doesn't - I don't know why
# Hints would be really appreciated ;-)
# error "System Events got an error: Can’t get tab group 1 of window 1 of application process \"System Preferences\". Invalid index." number -1719 from tab group 1 of window 1 of application process "System Preferences"
activate application "System Preferences"
tell application "System Preferences"
reveal pane "com.apple.preference.mouse"
tell application "System Events"
tell application process "System Preferences"
tell window 1
tell tab group 1
click menu button 1
if title of menu button 1 contains "right" then
pick menu item 2 of menu 1 of menu button 1
else
pick menu item 1 of menu 1 of menu button 1
end if
end tell
end tell
end tell
end tell
delay 1
quit
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment