Skip to content

Instantly share code, notes, and snippets.

@b-
Created October 30, 2017 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b-/3dfa5191d94bfc88f7c11a611731afd0 to your computer and use it in GitHub Desktop.
Save b-/3dfa5191d94bfc88f7c11a611731afd0 to your computer and use it in GitHub Desktop.
Increment/Decrement Mouse speed
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set trackingDelta to -1 --decrease
--Open and activate System Preferences
tell application "System Preferences" to activate
--Attempt to change settings using System Events
tell application "System Events"
tell process "System Preferences"
--Open the "Keyboard & Mouse" pane
set clicked to false
repeat while clicked is false
try
set clicked to false
click menu item "Mouse" of menu "View" of menu bar 1
set clicked to true
on error
set clicked to false
end try
end repeat
--adjust mouse speed by trackingDelta
set adjusted to false
repeat while adjusted is false
try
set oldTrackingValue to (get value of slider "Tracking Speed" of window "Mouse")
set newTrackingValue to (oldTrackingValue + trackingDelta)
set value of slider "Tracking Speed" of window "Mouse" to newTrackingValue
set adjusted to true
on error
set adjusted to false
end try
end repeat
--end tell
end tell
end tell
tell application "System Preferences" to quit
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set trackingDelta to +1 --increase
--Open and activate System Preferences
tell application "System Preferences" to activate
--Attempt to change settings using System Events
tell application "System Events"
tell process "System Preferences"
--Open the "Keyboard & Mouse" pane
set clicked to false
repeat while clicked is false
try
set clicked to false
click menu item "Mouse" of menu "View" of menu bar 1
set clicked to true
on error
set clicked to false
end try
end repeat
--adjust mouse speed by trackingDelta
set adjusted to false
repeat while adjusted is false
try
set oldTrackingValue to (get value of slider "Tracking Speed" of window "Mouse")
set newTrackingValue to (oldTrackingValue + trackingDelta)
set value of slider "Tracking Speed" of window "Mouse" to newTrackingValue
set adjusted to true
on error
set adjusted to false
end try
end repeat
--end tell
end tell
end tell
tell application "System Preferences" to quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment