Setting mouse tracking speed with applescript

I am trying to get an apple script to set the mouse tracking speed in OS X 10.6, in particular using the new Magic Mouse.

I found the following:

set trackingValue to 5

--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"
        try
            --Open the "Keyboard & Mouse" pane
            click menu item "Mouse" of menu "View" of menu bar 1
            delay 2
            set value of slider 1 to trackingValue
            --end tell
        on error theError
            --An error occured
            display dialog ("Sorry, an error occured while altering Keyboard and Mouse settings:" & return & theError) buttons "OK" default button "OK"
        end try
    end tell
end tell

But it looks like it's built on 10.5 when I get an error when I try to set the value of the slider 1 to track the Value

2 questions ...

  • How can I make this work with combo 10.6 / Magic Mouse?
  • How would I like to get the name of the slider in the control panel or any other control, if necessary, for use in AppleScript?
+3
source share
6 answers

- -, "Enable access for assistive devices" System Preferences / Universal Access / Mouse & Trackpad. , , script , , , .

-, , , , AppleScript, , . , script :

set value of slider "Tracking Speed" of window "Mouse" to trackingValue

, , , AppleScript, , . Snow Leopard " 1" " " . , , , . ? , , . , .

, script :

set trackingValue to 5

--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"
        try
            --Open the "Keyboard & Mouse" pane
            click menu item "Mouse" of menu "View" of menu bar 1
            delay 2
            set value of slider "Tracking Speed" of window "Mouse" to trackingValue
            --end tell
        on error theError
            --An error occured
            display dialog ("Sorry, an error occured while altering Keyboard and Mouse settings:" & return & theError) buttons "OK" default button "OK"
        end try
    end tell
end tell
+3

Mavericks 10.9, , script :

set trackingValue to 8

--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"
        try
            --Open the "Keyboard & Mouse" pane
            click menu item "Mouse" of menu "View" of menu bar 1
            delay 2

            tell tab group 1 of window "Mouse"
                set value of slider "Tracking" to trackingValue
            end tell
            --end tell
        on error theError
            --An error occured
            display dialog ("Sorry, an error occured while altering Keyboard and Mouse settings:" & return & theError) buttons "OK" default button "OK"
        end try
    end tell
end tell
+1

script - OS X Lion 10.7. , :

        set value of slider "Tracking Speed" of window "Mouse" to trackingValue
        tell application "System Preferences" to quit
        --end tell

, , .

0

, , 10.8. "Tracking Speed" "Tracking", .

, .

0

Sierra OS X. , script, .

set trackingValue to 8

--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"
        try
            delay 1
            --Open the "Mouse" pane
            click menu item "Mouse" of menu "View" of menu bar 1
            delay 0.5
            tell window "Mouse"
                set value of slider "Tracking speed" to trackingValue
            end tell
        on error theError
            --An error occured
            display dialog ("Sorry, an error occured while altering Mouse settings:" & return & theError) buttons "OK" default button "OK"
        end try
    end tell
end tell

tell application "System Preferences" to quit
0
source

For some reason, these scripts did not work on OS X 10.10. It is necessary to correct a little, but now it works.

set trackingValue to 9

--Open and activate System Preferences
tell application "System Preferences" to activate
tell application "System Preferences"
    reveal pane "com.apple.preference.mouse"
end tell
--Attempt to change settings using System Events
tell application "System Events"
    tell process "System Preferences"
        tell tab group 1 of window "Mouse"
            set value of slider "Tracking" to trackingValue
        end tell
    end tell
end tell
tell application "System Preferences" to quit

Enjoy.

-1
source

Source: https://habr.com/ru/post/1721990/