Skip to content

Instantly share code, notes, and snippets.

@chrisk
Created August 5, 2008 17:28
Show Gist options
  • Save chrisk/4100 to your computer and use it in GitHub Desktop.
Save chrisk/4100 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'rbosa'
sp = OSA.app 'System Preferences'
se = OSA.app 'System Events'
sp.current_pane = sp.panes.detect { |p| p.properties[:id] == 'com.apple.preference.keyboard' }
sp_process = se.application_processes.detect { |p| p.name == 'System Preferences' }
window = sp_process.windows.detect { |w| w.name == 'Keyboard & Mouse' }
# switch to 'mouse' tab
window.tab_groups[0].radio_buttons[2].actions.detect { |a| a.name == 'AXPress' }.perform
# click on 'right' for primary mouse button
window.tab_groups[0].radio_groups.first.radio_buttons[0].actions.first.perform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment