Class: RAutomation::Adapter::MsUia::UiaDll::SearchCriteria

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/rautomation/adapter/ms_uia/uia_dll.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_locator(parent, locator)



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 24

def self.from_locator(parent, locator)
  info = SearchCriteria.new
  info.parent_window = parent
  info.index = locator[:index] || 0
  info.children_only = locator[:children_only]

  case
    when locator[:hwnd]
      info.how = :hwnd
      info.data = locator[:hwnd]
    when locator[:id]
      info.how = :id
      info.data = locator[:id]
    when locator[:value]
      info.how = :value
      info.data = locator[:value]
    when locator[:point]
      info.how = :point
      info.data = locator[:point]
    when locator[:focus]
      info.how = :focus
  end
  info
end

Instance Method Details

#children_only=(yes_or_no)



69
70
71
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 69

def children_only=(yes_or_no)
  self[:children_only] = yes_or_no
end

#children_only?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 65

def children_only?
  self[:children_only]
end

#data



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 81

def data
  case how
    when :hwnd
      return self[:data][:int_data]
    when :id, :value
      return self[:data][:string_data].to_ptr.read_string
    when :point
      return self[:data][:point_data].to_ptr.read_array_of_int(2)
    else
      return nil
  end
end

#data=(value)



94
95
96
97
98
99
100
101
102
103
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 94

def data=(value)
  case how
    when :hwnd
      self[:data][:int_data] = value || 0 # cannot accept nil
    when :id, :value
      self[:data][:string_data] = value
    when :point
      self[:data][:point_data].to_ptr.write_array_of_int(value)
  end
end

#how



49
50
51
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 49

def how
  self[:how]
end

#how=(value)



53
54
55
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 53

def how=(value)
  self[:how] = value
end

#index



57
58
59
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 57

def index
  self[:index]
end

#index=(value)



61
62
63
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 61

def index=(value)
  self[:index] = value
end

#parent_window



73
74
75
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 73

def parent_window
  self[:hwnd]
end

#parent_window=(parent)



77
78
79
# File 'lib/rautomation/adapter/ms_uia/uia_dll.rb', line 77

def parent_window=(parent)
  self[:hwnd] = parent
end