Sha256: aba84f88390d71a418e330e261a2d2a0337b73b7c106965ecfd340ae05655ddb

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

module RAutomation
  module Adapter
    module MsUia

      class ListBox < Control
        include WaitHelper
        include Locators

        def count
          UiaDll::select_list_count search_information
        end

        def items
          UiaDll::find_table_values(search_information).map do |list_item|
            @window.list_item(:value => list_item)
          end
        end

        def strings
          items.collect { |item| item.value}
        end

        def value
          UiaDll::selection search_information
        end

        def exist?
          super && matches_type?(Constants::UIA_LIST_CONTROL_TYPE)
        end

        alias_method :exists?, :exist?

        def selected?(index)
          if items[index]
            return items[index].selected?
          end

          false
        end

        def select(index)
          UiaDll::select_list_select_index search_information, index
        end

        def list_boundary
          boundary = FFI::MemoryPointer.new :long, 4

          Functions.send_message(hwnd, Constants::LB_GETITEMRECT, 0 ,boundary)

          boundary.read_array_of_long(4)
        end

        def get_top_index
          Functions.send_message(hwnd, Constants::LB_GETTOPINDEX, 0 ,nil)
        end

        def list_item_height
          Functions.send_message(hwnd, Constants::LB_GETITEMHEIGHT, 0 ,nil)
        end

        def scroll_to_item(row)
          Functions.send_message(hwnd, Constants::LB_SETTOPINDEX, row ,nil)
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rautomation-0.9.0 lib/rautomation/adapter/ms_uia/list_box.rb