Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I need help with extension writing in Applescript for Alfred.
- This following script works, it sets the mouse sensitivity to 5.
- ////////////////////////////////////////////////////////////////////
- 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
- if application "System Preferences" is running then
- tell application "System Preferences" to quit
- end if
- ////////////////////////////////////////////////////////////////////////////////////////
- I want to make an extension for Alfred which does the same thing but the user can specify the value.
- What's wrong with this? i don't know much about Applescript and thought you might be able to help me. Thanks in advance anyway.
- ///////////////////////////////////////////////////////////////////////////////////////
- on alfred_script(q)
- set trackingValue to q
- --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
- if application "System Preferences" is running then
- tell application "System Preferences" to quit
- end if
- end alfred_script
- ////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement