def click(opts={})
      control = child(opts)
      if control
        left, top, right, bottom = control.get_window_rect

        where = opts[:point] || opts[:where] || opts[:position]
        point = case where
                  when Array
                    where # Explicit screen coords
                  when :random
                    [left + rand(right - left), top + rand(bottom - top)] # Random point within control window
                  else
                    [(left + right) / 2, (top + bottom) / 2] # Center of a control window
                end

        WinGui.set_cursor_pos *point

        button = opts[:mouse_button] || opts[:mouse] || opts[:which]
        down, up = (button == :right) ?
            [WinGui::MOUSEEVENTF_RIGHTDOWN, WinGui::MOUSEEVENTF_RIGHTUP] :
            [WinGui::MOUSEEVENTF_LEFTDOWN, WinGui::MOUSEEVENTF_LEFTUP]

        WinGui.mouse_event down, 0, 0, 0, 0
        WinGui.mouse_event up, 0, 0, 0, 0
        point
      else
        nil
      end
    end
def click(opts={})
      control = child(opts)
      if control
        left, top, right, bottom = control.get_window_rect

        where = opts[:point] || opts[:where] || opts[:position]
        point = case where
                  when Array
                    where # Explicit screen coords
                  when :random
                    [left + rand(right - left), top + rand(bottom - top)] # Random point within control window
                  else
                    [(left + right) / 2, (top + bottom) / 2] # Center of a control window
                end

        WinGui.set_cursor_pos *point

        button = opts[:mouse_button] || opts[:mouse] || opts[:which]
        down, up = (button == :right) ?
            [WinGui::MOUSEEVENTF_RIGHTDOWN, WinGui::MOUSEEVENTF_RIGHTUP] :
            [WinGui::MOUSEEVENTF_LEFTDOWN, WinGui::MOUSEEVENTF_LEFTUP]

        WinGui.mouse_event down, 0, 0, 0, 0
        WinGui.mouse_event up, 0, 0, 0, 0
        point
      else
        nil
      end
    end
Emulates click of the control identified by opts (:id, :title, :class).
 Beware of keyboard shortcuts in button titles! So, use "&Yes" instead of just "Yes".
 Returns screen coordinates of click point if successful, nil if control was not found
 :id:: integer control id (such as IDOK, IDCANCEL, etc)
 :title:: window title
 :class:: window class
 :raise:: raise this exception instead of returning nil if nothing found
 :position/point/where:: location where the click is to be applied - default :center
 :mouse_button/button/which:: mouse button which to click - default :right