Skip to content

Instantly share code, notes, and snippets.

@chrisk
Created August 5, 2008 17:28

Revisions

  1. chrisk created this gist Aug 5, 2008.
    19 changes: 19 additions & 0 deletions gistfile1.rbx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/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