Class: RAutomation::Adapter::WinFfi::ListBox
Instance Method Summary
collapse
Methods inherited from Control
#assert_enabled, #click, #disabled?, #enabled?, #has_focus?, #initialize, #matches_type, #set_focus, #uia_control
Instance Method Details
#count
9
10
11
|
# File 'lib/rautomation/adapter/win_ffi/list_box.rb', line 9
def count
UiaDll::find_children(uia_control(@locators[:id]), nil)
end
|
#exist? ⇒ Boolean
Also known as:
exists?
25
26
27
|
# File 'lib/rautomation/adapter/win_ffi/list_box.rb', line 25
def exist?
@locators[:id].nil? ? super : super && matches_type(Constants::UIA_LIST_CONTROL_TYPE)
end
|
#items
Also known as:
strings
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/rautomation/adapter/win_ffi/list_box.rb', line 13
def items
list_items = []
children = FFI::MemoryPointer.new :pointer, self.count
length = UiaDll::find_children(uia_control(@locators[:id]), children)
children.read_array_of_pointer(length).each do |child|
child_name = FFI::MemoryPointer.new :char, UiaDll::get_name(child, nil) + 1
UiaDll::get_name(child, child_name)
list_items.push child_name.read_string
end
list_items
end
|
#select(index)
44
45
46
47
48
49
50
51
|
# File 'lib/rautomation/adapter/win_ffi/list_box.rb', line 44
def select(index)
children = FFI::MemoryPointer.new :pointer, self.count
length = UiaDll::find_children(uia_control(@locators[:id]), children)
target_element = children.read_array_of_pointer(length)[index]
UiaDll::select(target_element)
end
|
#selected?(index) ⇒ Boolean
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rautomation/adapter/win_ffi/list_box.rb', line 31
def selected?(index)
children = FFI::MemoryPointer.new :pointer, self.count
length = UiaDll::find_children(uia_control(@locators[:id]), children)
target_element = children.read_array_of_pointer(length)[index]
is_selected = FFI::MemoryPointer.new :int, 1
if UiaDll::get_is_selected(target_element, is_selected) == 1
return is_selected.read_int == 1
else
return false
end
end
|