class RAutomation::Adapter::Win32::Control

Public Class Methods

new(window, locators) click to toggle source

Creates the control object. @note this method is not meant to be accessed directly @param [RAutomation::Window] window this button belongs to. @param [Hash] locators for searching the button. @option locators [String, Regexp] :value Value (text) of the button @option locators [String, Regexp] :class Internal class name of the button @option locators [String, Integer] :id Internal ID of the button @option locators [String, Integer] :index 0-based index to specify n-th button if all other criteria match @see RAutomation::Window#button

# File lib/rautomation/adapter/win_32/control.rb, line 17
def initialize(window, locators)
  @window = window
  extract(locators)
end

Public Instance Methods

class_name() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 26
def class_name
  Functions.control_class(hwnd)
end
click() { |: clicked && !exist?| ... } click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 30
def click
  assert_enabled
  clicked = false
  wait_until do
    @window.activate
    @window.active? &&
        focus &&
        Functions.control_click(hwnd) &&
        clicked = true # is clicked at least once

    block_given? ? yield : clicked && !exist?
  end
end
disabled?() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 60
def disabled?
  Functions.unavailable? hwnd
end
enabled?() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 56
def enabled?
  !disabled?
end
exist?() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 48
def exist?
  !!hwnd
rescue UnknownElementException
  false
end
Also aliased as: exists?
exists?()
Alias for: exist?
focus() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 64
def focus
  assert_enabled
  @window.activate
  Functions.set_control_focus hwnd
end
focused?() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 70
def focused?
  Functions.has_focus?(hwnd)
end
hwnd() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 22
def hwnd
  Functions.control_hwnd(@window.hwnd, @locators)
end
value() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 74
def value
  Functions.control_value(hwnd)
end

Private Instance Methods

assert_enabled() click to toggle source
# File lib/rautomation/adapter/win_32/control.rb, line 80
def assert_enabled
  raise "Cannot interact with disabled control #{@locators.inspect} on window #{@window.locators.inspect}!" if disabled?
end