Created
October 30, 2017 18:41
-
-
Save b-/3dfa5191d94bfc88f7c11a611731afd0 to your computer and use it in GitHub Desktop.
Increment/Decrement Mouse speed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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