Class: RAutomation::Adapter::Autoit::Button

Inherits:
Object
  • Object
show all
Includes:
WaitHelper
Defined in:
lib/rautomation/adapter/autoit/button.rb

Constant Summary collapse

DEFAULT_LOCATORS =

Default locators used for searching buttons.

{:class => /button/i}

Instance Method Summary collapse

Constructor Details

#initialize(window, locators) ⇒ Button

Note:

this method is not meant to be accessed directly, but only through Window#button!

Creates the button object.

Parameters:

  • window (RAutomation::Window)

    this button belongs to.

  • locators (Hash)

    for searching the button.

Options Hash (locators):

  • :value (String, Regexp)

    Value (text) of the button

  • :class (String, Regexp)

    Internal class name of the button

  • :id (String, Fixnum)

    Internal ID of the button

  • :index (String, Fixnum)

    0-based index to specify n-th button if all other criteria match

See Also:



28
29
30
31
# File 'lib/rautomation/adapter/autoit/button.rb', line 28

def initialize(window, locators)
  @window = window
  extract(locators)
end

Instance Method Details

#click

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rautomation/adapter/autoit/button.rb', line 34

def click
  clicked = false
  wait_until do
    @window.activate
    @window.active? &&
            Window.autoit.ControlFocus(@window.locator_hwnd, "", @autoit_locators) == 1 &&
            Window.autoit.ControlClick(@window.locator_hwnd, "", @autoit_locators) == 1 &&
            clicked = true # is clicked at least once

    block_given? ? yield : clicked && !exists?
  end
end

#exists?Boolean

Returns:

  • (Boolean)

See Also:



53
54
55
# File 'lib/rautomation/adapter/autoit/button.rb', line 53

def exists?
  not Window.autoit.ControlGetHandle(@window.locator_hwnd, "", @autoit_locators).empty?
end

#value

See Also:



48
49
50
# File 'lib/rautomation/adapter/autoit/button.rb', line 48

def value
  Window.autoit.ControlGetText(@window.locator_hwnd, "", @autoit_locators)
end