Sha256: b50a25a8af05569eaec30b9d57fc0213914d8812f4747387ab79d9c440f687a8

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

module RAutomation
  module Adapter
    module Ffi
      class Button
        include WaitHelper
        include Locators

        # Possible locators are :value, :id, :class and :index.
        def initialize(window, locators)
          @window = window
          extract(locators)
        end

        def click #:nodoc:
          clicked = false
          wait_until do
            hwnd = Functions.control_hwnd(@window.hwnd, @locators)
            @window.activate
            @window.active? &&
                    Functions.set_control_focus(hwnd) &&
                    Functions.control_click(hwnd) &&
                    clicked = true # is clicked at least once
            clicked && !exists?
          end
        end

        def value #:nodoc:
          Functions.control_value(Functions.control_hwnd(@window.hwnd, @locators))
        end

        def exists? #:nodoc:
          !!Functions.control_hwnd(@window.hwnd, @locators)
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rautomation-0.1.0 lib/rautomation/adapter/ffi/button.rb