Class: RAutomation::Adapter::MsUia::Table

Inherits:
Control
  • Object
show all
Includes:
Locators, WaitHelper
Defined in:
lib/rautomation/adapter/ms_uia/table.rb

Instance Method Summary collapse

Methods inherited from Control

#assert_enabled, #bounding_rectangle, #click, #control_class, #control_name, #disabled?, #enabled?, #get_current_control_type, #has_focus?, #hwnd, #initialize, #matches_type?, #new_pid, #set_focus, #uia_element, #visible?

Constructor Details

This class inherits a constructor from RAutomation::Adapter::MsUia::Control

Instance Method Details

#exist?Boolean Also known as: exists?

Returns:

  • (Boolean)


71
72
73
# File 'lib/rautomation/adapter/ms_uia/table.rb', line 71

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

#row_count



67
68
69
# File 'lib/rautomation/adapter/ms_uia/table.rb', line 67

def row_count
  UiaDll::find_children(uia_element, nil)
end

#select(index)

def select(row)

  Functions.select_table_row(Window.oleacc_module_handle, Functions.control_hwnd(@window.hwnd, @locators), row)
end


51
52
53
54
55
56
57
58
59
# File 'lib/rautomation/adapter/ms_uia/table.rb', line 51

def select(index)
  children = FFI::MemoryPointer.new :pointer, row_count

  length = UiaDll::find_children(uia_element, children)

  target_element = children.read_array_of_pointer(length)[index]

  UiaDll::select(target_element)
end

#selected?(row) ⇒ Boolean

todo - replace with UIA version

Returns:

  • (Boolean)


62
63
64
65
# File 'lib/rautomation/adapter/ms_uia/table.rb', line 62

def selected?(row)
  state = Functions.get_table_row_state(Window.oleacc_module_handle, Functions.control_hwnd(@window.hwnd, @locators), row)
  state & Constants::STATE_SYSTEM_SELECTED != 0
end

#strings



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rautomation/adapter/ms_uia/table.rb', line 8

def strings
  rows = []
  header_columns = []

  raise "Not a list control" unless UiaDll::current_control_type(uia_element) == Constants::UIA_LIST_CONTROL_TYPE


  children_count = count_children(uia_element)

  children = FFI::MemoryPointer.new :pointer, children_count
  UiaDll::find_children(uia_element, children)


  children.read_array_of_pointer(children_count).each do |child|
    grandchildren_count = count_children(child)

    if grandchildren_count > 0

      grandchildren = FFI::MemoryPointer.new :pointer, grandchildren_count
      UiaDll::find_children(child, grandchildren)

      grandchildren.read_array_of_pointer(grandchildren_count).each do |grandchild|
        grandchild_name = FFI::MemoryPointer.new :char, UiaDll::get_name(grandchild, nil) + 1
        UiaDll::get_name(grandchild, grandchild_name)
        header_columns.push grandchild_name.read_string
      end
    else
      grandchild_name = FFI::MemoryPointer.new :char, UiaDll::get_name(child, nil) + 1
      UiaDll::get_name(child, grandchild_name)
      header_columns = grandchild_name.read_string
    end

    rows.push header_columns
    header_columns = []
  end

  rows
end