AppleScript UI-scripting - conditional
I want to click a radio-button in System Preferences if another radio-button is selected, like this:
tell application "System Preferences"
activate
end tell
tell application "System Events"
tell process "System Preferences"
click menu item "Mouse" of menu "View" of menu bar 1
if radio button "Right" is selected <-- pseudo-code
tell window "Mouse"
tell radio group 1
click radio button "Left"
end tell
end tell
end if
if radio button "Left" is selected <-- pseudo-code
tell window "Mouse"
tell radio group 1
click radio button "Right"
开发者_如何学Go end tell
end tell
end if
end tell
end tell
anyone know how to do this?
The following script will revert the primary button to "Left" if it is currently set to "Right":
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.mouse"
end tell
tell application "System Events"
tell process "System Preferences"
tell radio group "Primary mouse button:" of window "Mouse"
if value of radio button "Right" is 1 then
click radio button "Left"
end if
end tell
end tell
end tell
Setting the primary button to "Right" will confuse the hell out of most users.
精彩评论