uia 0.0.7.2 → 0.0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5 -0
- data/ext/UiaDll/UIA.Helper/Element.cs +5 -0
- data/ext/UiaDll/UiaDll.Test/ElementStub.h +7 -0
- data/ext/UiaDll/UiaDll/ElementStructures.h +2 -0
- data/ext/UiaDll/UiaDll/PatternInformationStructures.h +19 -1
- data/ext/UiaDll/UiaDll/RangeValueMethods.cpp +25 -0
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj +1 -0
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +3 -0
- data/lib/uia/element.rb +4 -1
- data/lib/uia/library.rb +5 -0
- data/lib/uia/library/element_attributes.rb +9 -0
- data/lib/uia/library/element_structs.rb +8 -24
- data/lib/uia/library/pattern_info_attributes.rb +11 -0
- data/lib/uia/library/pattern_structs.rb +31 -44
- data/lib/uia/library/struct_attributes.rb +12 -0
- data/lib/uia/patterns/range_value.rb +19 -0
- data/lib/uia/version.rb +1 -1
- data/spec/uia/element_spec.rb +6 -0
- data/spec/uia/patterns/range_value_spec.rb +19 -0
- metadata +9 -3
data/ChangeLog
CHANGED
@@ -47,6 +47,11 @@ namespace UIA.Helper
|
|
47
47
|
get { return _element.Current.IsEnabled; }
|
48
48
|
}
|
49
49
|
|
50
|
+
public virtual bool IsVisible
|
51
|
+
{
|
52
|
+
get { return _element.Current.IsOffscreen == false; }
|
53
|
+
}
|
54
|
+
|
50
55
|
public virtual int NativeWindowHandle
|
51
56
|
{
|
52
57
|
get { return _element.Current.NativeWindowHandle; }
|
@@ -34,6 +34,12 @@ public:
|
|
34
34
|
void set(bool value) { _isEnabled = value; }
|
35
35
|
}
|
36
36
|
|
37
|
+
virtual property bool IsVisible
|
38
|
+
{
|
39
|
+
bool get() override { return _isVisible; }
|
40
|
+
void set(bool value) { _isVisible = value; }
|
41
|
+
}
|
42
|
+
|
37
43
|
virtual property array<int>^ RuntimeId
|
38
44
|
{
|
39
45
|
array<int>^ get() override { return _runtimeIds; }
|
@@ -70,4 +76,5 @@ private:
|
|
70
76
|
int _nativeWindowHandle;
|
71
77
|
int _controlTypeId;
|
72
78
|
bool _isEnabled;
|
79
|
+
bool _isVisible;
|
73
80
|
};
|
@@ -14,6 +14,7 @@ typedef struct _ElementInformation {
|
|
14
14
|
char* id;
|
15
15
|
|
16
16
|
bool isEnabled;
|
17
|
+
bool isVisible;
|
17
18
|
|
18
19
|
_ElementInformation() : name(NULL), nativeWindowHandle(0), runtimeId(NULL), patterns(NULL), id(NULL), className(NULL) {}
|
19
20
|
|
@@ -50,6 +51,7 @@ typedef struct _ElementInformation {
|
|
50
51
|
patternsLength = element->SupportedPatternIds->Length;
|
51
52
|
|
52
53
|
isEnabled = element->IsEnabled;
|
54
|
+
isVisible = element->IsVisible;
|
53
55
|
}
|
54
56
|
|
55
57
|
~_ElementInformation() {
|
@@ -163,4 +163,22 @@ typedef struct _TableItemInformation {
|
|
163
163
|
Row = tableItemInfo->Row;
|
164
164
|
}
|
165
165
|
|
166
|
-
} TableItemInformation, *TableItemInformationPtr;
|
166
|
+
} TableItemInformation, *TableItemInformationPtr;
|
167
|
+
|
168
|
+
typedef struct _RangeValueInformation {
|
169
|
+
double Value;
|
170
|
+
double Minimum;
|
171
|
+
double Maximum;
|
172
|
+
double SmallChange;
|
173
|
+
double LargeChange;
|
174
|
+
bool IsReadOnly;
|
175
|
+
|
176
|
+
_RangeValueInformation(RangeValuePattern::RangeValuePatternInformation^ rangeValueInfo) {
|
177
|
+
Value = rangeValueInfo->Value;
|
178
|
+
Minimum = rangeValueInfo->Minimum;
|
179
|
+
Maximum = rangeValueInfo->Maximum;
|
180
|
+
SmallChange = rangeValueInfo->SmallChange;
|
181
|
+
LargeChange = rangeValueInfo->LargeChange;
|
182
|
+
IsReadOnly = rangeValueInfo->IsReadOnly;
|
183
|
+
}
|
184
|
+
} RangeValueInformation, *RangeValueInformationPtr;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#include "Stdafx.h"
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
__declspec(dllexport) void RangeValue_Release(RangeValueInformationPtr rangeValueInfo) {
|
5
|
+
delete rangeValueInfo;
|
6
|
+
}
|
7
|
+
|
8
|
+
__declspec(dllexport) RangeValueInformationPtr RangeValue_Information(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
9
|
+
try {
|
10
|
+
return new RangeValueInformation(Find(element)->As<RangeValuePattern^>(RangeValuePattern::Pattern)->Current);
|
11
|
+
} catch(Exception^ e) {
|
12
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
13
|
+
return NULL;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
__declspec(dllexport) void RangeValue_SetValue(ElementInformationPtr element, double value, char* errorInfo, const int errorInfoLength) {
|
18
|
+
try {
|
19
|
+
return Find(element)->As<RangeValuePattern^>(RangeValuePattern::Pattern)->SetValue(value);
|
20
|
+
} catch(Exception^ e) {
|
21
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
}
|
@@ -92,6 +92,7 @@
|
|
92
92
|
<ClCompile Include="ElementMethods.cpp" />
|
93
93
|
<ClCompile Include="ExpandCollapseMethods.cpp" />
|
94
94
|
<ClCompile Include="InvokePatternMethods.cpp" />
|
95
|
+
<ClCompile Include="RangeValueMethods.cpp" />
|
95
96
|
<ClCompile Include="SelectionItemMethods.cpp" />
|
96
97
|
<ClCompile Include="SelectionMethods.cpp" />
|
97
98
|
<ClCompile Include="Stdafx.cpp">
|
data/lib/uia/element.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'uia/library/element_attributes'
|
2
|
+
require 'uia/library/pattern_info_attributes'
|
2
3
|
|
3
4
|
module Uia
|
4
5
|
class UnsupportedPattern < StandardError
|
@@ -15,7 +16,9 @@ module Uia
|
|
15
16
|
@default = lambda { [:unknown] }
|
16
17
|
end
|
17
18
|
|
18
|
-
element_attr :id, :name, :handle, :runtime_id,
|
19
|
+
element_attr :id, :name, :handle, :runtime_id,
|
20
|
+
:class_name, :children, :descendants
|
21
|
+
refreshed_element_attr :enabled?, :visible?
|
19
22
|
|
20
23
|
def control_type
|
21
24
|
Library::Constants::ControlTypes.find(@default) { |_, v| v == @element.control_type_id }.first
|
data/lib/uia/library.rb
CHANGED
@@ -49,6 +49,7 @@ module Uia
|
|
49
49
|
attach_function :release_table_info, :Table_Release, [:pointer], :void
|
50
50
|
attach_function :release_table_item_info, :TableItem_Release, [:pointer], :void
|
51
51
|
attach_function :release_expand_collapse_info, :ExpandCollapse_Release, [:pointer], :void
|
52
|
+
attach_function :release_range_value_info, :RangeValue_Release, [:pointer], :void
|
52
53
|
|
53
54
|
# root methods
|
54
55
|
elements_from :root_children, :Root_Children, []
|
@@ -103,6 +104,10 @@ module Uia
|
|
103
104
|
# TableItemPattern methods
|
104
105
|
attach_throwable_function :table_item_info, :TableItem_Information, [:pointer], TableItemInformation.by_ref
|
105
106
|
|
107
|
+
# RangeValuePattern methods
|
108
|
+
attach_throwable_function :range_value_info, :RangeValue_Information, [:pointer], RangeValueInformation.by_ref
|
109
|
+
attach_throwable_function :set_range_value, :RangeValue_SetValue, [:pointer, :double], :void
|
110
|
+
|
106
111
|
def self.find_by_runtime_id(id)
|
107
112
|
p = FFI::MemoryPointer.new :int, id.count
|
108
113
|
p.write_array_of_int(id)
|
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'ffi'
|
2
2
|
|
3
|
+
require 'uia/library/struct_attributes'
|
4
|
+
|
3
5
|
module Uia
|
4
6
|
module Library
|
5
7
|
module ElementLayout
|
6
8
|
def self.included(base)
|
7
9
|
base.class_eval do
|
10
|
+
extend StructAttributes
|
11
|
+
|
8
12
|
layout :handle, :int,
|
9
13
|
:runtime_id, :pointer,
|
10
14
|
:number_of_ids, :int,
|
@@ -14,28 +18,16 @@ module Uia
|
|
14
18
|
:patterns, :pointer,
|
15
19
|
:patterns_length, :int,
|
16
20
|
:id, :string,
|
17
|
-
:is_enabled, :bool
|
18
|
-
|
19
|
-
def id
|
20
|
-
self[:id]
|
21
|
-
end
|
21
|
+
:is_enabled, :bool,
|
22
|
+
:is_visible, :bool
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def handle
|
28
|
-
self[:handle]
|
29
|
-
end
|
24
|
+
struct_attr :id, :name, :handle, :control_type_id, :class_name,
|
25
|
+
[:enabled?, :is_enabled], [:visible?, :is_visible]
|
30
26
|
|
31
27
|
def runtime_id
|
32
28
|
self[:runtime_id].read_array_of_int(number_of_ids)
|
33
29
|
end
|
34
30
|
|
35
|
-
def control_type_id
|
36
|
-
self[:control_type_id]
|
37
|
-
end
|
38
|
-
|
39
31
|
def pattern_ids
|
40
32
|
self[:patterns].read_array_of_int(self[:patterns_length])
|
41
33
|
end
|
@@ -52,14 +44,6 @@ module Uia
|
|
52
44
|
to_ptr.address == 0
|
53
45
|
end
|
54
46
|
|
55
|
-
def enabled?
|
56
|
-
self[:is_enabled]
|
57
|
-
end
|
58
|
-
|
59
|
-
def class_name
|
60
|
-
self[:class_name]
|
61
|
-
end
|
62
|
-
|
63
47
|
private
|
64
48
|
def number_of_ids
|
65
49
|
self[:number_of_ids]
|
@@ -1,16 +1,14 @@
|
|
1
|
+
require 'uia/library/struct_attributes'
|
2
|
+
|
1
3
|
module Uia
|
2
4
|
module Library
|
3
5
|
class ValueInformation < FFI::ManagedStruct
|
6
|
+
extend StructAttributes
|
7
|
+
|
4
8
|
layout :is_read_only, :bool,
|
5
9
|
:value, :string
|
6
10
|
|
7
|
-
|
8
|
-
self[:is_read_only]
|
9
|
-
end
|
10
|
-
|
11
|
-
def value
|
12
|
-
self[:value]
|
13
|
-
end
|
11
|
+
struct_attr [:read_only?, :is_read_only], :value
|
14
12
|
|
15
13
|
def self.release(pointer)
|
16
14
|
Library.release_value_info(pointer)
|
@@ -76,6 +74,8 @@ module Uia
|
|
76
74
|
end
|
77
75
|
|
78
76
|
class WindowInformation < FFI::ManagedStruct
|
77
|
+
extend StructAttributes
|
78
|
+
|
79
79
|
layout :visual_state, :string,
|
80
80
|
:interaction_state, :string,
|
81
81
|
:can_minimize, :bool,
|
@@ -83,29 +83,8 @@ module Uia
|
|
83
83
|
:is_modal, :bool,
|
84
84
|
:is_topmost, :bool
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
def can_minimize?
|
91
|
-
self[:can_minimize]
|
92
|
-
end
|
93
|
-
|
94
|
-
def can_maximize?
|
95
|
-
self[:can_maximize]
|
96
|
-
end
|
97
|
-
|
98
|
-
def modal?
|
99
|
-
self[:is_modal]
|
100
|
-
end
|
101
|
-
|
102
|
-
def topmost?
|
103
|
-
self[:is_topmost]
|
104
|
-
end
|
105
|
-
|
106
|
-
def interaction_state
|
107
|
-
self[:interaction_state]
|
108
|
-
end
|
86
|
+
struct_attr :visual_state, [:can_minimize?, :can_minimize], [:can_maximize?, :can_maximize],
|
87
|
+
[:modal?, :is_modal], [:topmost?, :is_topmost], :interaction_state
|
109
88
|
|
110
89
|
def self.release(pointer)
|
111
90
|
Library.release_window_info(pointer)
|
@@ -113,17 +92,13 @@ module Uia
|
|
113
92
|
end
|
114
93
|
|
115
94
|
class TableInformation < FFI::ManagedStruct
|
95
|
+
extend StructAttributes
|
96
|
+
|
116
97
|
layout :row_count, :int,
|
117
98
|
:column_count, :int,
|
118
99
|
:headers, Elements.ptr
|
119
100
|
|
120
|
-
|
121
|
-
self[:row_count]
|
122
|
-
end
|
123
|
-
|
124
|
-
def column_count
|
125
|
-
self[:column_count]
|
126
|
-
end
|
101
|
+
struct_attr :row_count, :column_count
|
127
102
|
|
128
103
|
def headers
|
129
104
|
self[:headers].children
|
@@ -135,21 +110,33 @@ module Uia
|
|
135
110
|
end
|
136
111
|
|
137
112
|
class TableItemInformation < FFI::ManagedStruct
|
113
|
+
extend StructAttributes
|
114
|
+
|
138
115
|
layout :column, :int,
|
139
116
|
:row, :int
|
140
117
|
|
141
|
-
|
142
|
-
self[:column]
|
143
|
-
end
|
144
|
-
|
145
|
-
def row
|
146
|
-
self[:row]
|
147
|
-
end
|
118
|
+
struct_attr :column, :row
|
148
119
|
|
149
120
|
def self.release(pointer)
|
150
121
|
Library.release_table_item_info(pointer)
|
151
122
|
end
|
152
123
|
end
|
153
124
|
|
125
|
+
class RangeValueInformation < FFI::ManagedStruct
|
126
|
+
extend StructAttributes
|
127
|
+
|
128
|
+
layout :value, :double,
|
129
|
+
:minimum, :double,
|
130
|
+
:maximum, :double,
|
131
|
+
:small_change, :double,
|
132
|
+
:large_change, :double,
|
133
|
+
:is_read_only, :bool
|
134
|
+
|
135
|
+
struct_attr :value, :minimum, :maximum, :small_change, :large_change, [:read_only?, :is_read_only]
|
136
|
+
|
137
|
+
def self.release(pointer)
|
138
|
+
Library.release_range_value_info(pointer)
|
139
|
+
end
|
140
|
+
end
|
154
141
|
end
|
155
142
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Uia
|
2
|
+
module Patterns
|
3
|
+
module RangeValue
|
4
|
+
extend PatternInfoAttributes
|
5
|
+
|
6
|
+
pattern_attr :value, :minimum, :maximum,
|
7
|
+
:small_change, :large_change, :read_only?
|
8
|
+
|
9
|
+
def value=(num)
|
10
|
+
Library.set_range_value @element, num
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def pattern_info
|
15
|
+
Library.range_value_info @element
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/uia/version.rb
CHANGED
data/spec/uia/element_spec.rb
CHANGED
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Uia::Element do
|
4
4
|
Given(:element) { Uia.find_element(id: 'MainFormWindow') }
|
5
5
|
Given(:about_box) { Uia.find_element(id: 'AboutBox') }
|
6
|
+
Given { element.as(:window).visual_state = :normal }
|
6
7
|
|
7
8
|
context 'properties' do
|
8
9
|
let(:raw_element) { element.instance_variable_get(:@element) }
|
@@ -12,6 +13,11 @@ describe Uia::Element do
|
|
12
13
|
Then { element.class_name =~ /Forms.*app/i }
|
13
14
|
Then { expect(element.find(id: 'textField')).to be_enabled }
|
14
15
|
|
16
|
+
context 'visibility' do
|
17
|
+
When { element.as(:window).visual_state = :minimized }
|
18
|
+
Then { element.visible? == false }
|
19
|
+
end
|
20
|
+
|
15
21
|
context '#control_type' do
|
16
22
|
Then { element.control_type == :window }
|
17
23
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Uia::Patterns::RangeValue do
|
4
|
+
Given(:range_value) { Uia.find_element(id: /MainForm/).find(id: 'numericUpDown1').as :range_value }
|
5
|
+
|
6
|
+
context 'properties' do
|
7
|
+
Then { range_value.value == 0.0 }
|
8
|
+
Then { range_value.minimum == 0.0 }
|
9
|
+
Then { range_value.maximum == 100.0 }
|
10
|
+
Then { range_value.small_change == 1.0 }
|
11
|
+
Then { range_value.large_change == 0.0 }
|
12
|
+
Then { range_value.read_only? == false }
|
13
|
+
end
|
14
|
+
|
15
|
+
context '#value=' do
|
16
|
+
When { range_value.value = 37.3 }
|
17
|
+
Then { range_value.value == 37.3 }
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.7.
|
4
|
+
version: 0.0.7.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- ext/UiaDll/UiaDll/ExpandCollapseMethods.cpp
|
171
171
|
- ext/UiaDll/UiaDll/InvokePatternMethods.cpp
|
172
172
|
- ext/UiaDll/UiaDll/PatternInformationStructures.h
|
173
|
+
- ext/UiaDll/UiaDll/RangeValueMethods.cpp
|
173
174
|
- ext/UiaDll/UiaDll/ReadMe.txt
|
174
175
|
- ext/UiaDll/UiaDll/SelectionItemMethods.cpp
|
175
176
|
- ext/UiaDll/UiaDll/SelectionMethods.cpp
|
@@ -195,9 +196,12 @@ files:
|
|
195
196
|
- lib/uia/library/constants.rb
|
196
197
|
- lib/uia/library/element_attributes.rb
|
197
198
|
- lib/uia/library/element_structs.rb
|
199
|
+
- lib/uia/library/pattern_info_attributes.rb
|
198
200
|
- lib/uia/library/pattern_structs.rb
|
201
|
+
- lib/uia/library/struct_attributes.rb
|
199
202
|
- lib/uia/patterns/expand_collapse.rb
|
200
203
|
- lib/uia/patterns/invoke.rb
|
204
|
+
- lib/uia/patterns/range_value.rb
|
201
205
|
- lib/uia/patterns/selection.rb
|
202
206
|
- lib/uia/patterns/selection_item.rb
|
203
207
|
- lib/uia/patterns/table.rb
|
@@ -213,6 +217,7 @@ files:
|
|
213
217
|
- spec/uia/element_spec.rb
|
214
218
|
- spec/uia/patterns/expand_collapse_spec.rb
|
215
219
|
- spec/uia/patterns/invoke_spec.rb
|
220
|
+
- spec/uia/patterns/range_value_spec.rb
|
216
221
|
- spec/uia/patterns/selection_item_spec.rb
|
217
222
|
- spec/uia/patterns/selection_spec.rb
|
218
223
|
- spec/uia/patterns/table_item_spec.rb
|
@@ -239,7 +244,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
244
|
version: '0'
|
240
245
|
segments:
|
241
246
|
- 0
|
242
|
-
hash:
|
247
|
+
hash: 100309903
|
243
248
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
249
|
none: false
|
245
250
|
requirements:
|
@@ -248,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
253
|
version: '0'
|
249
254
|
segments:
|
250
255
|
- 0
|
251
|
-
hash:
|
256
|
+
hash: 100309903
|
252
257
|
requirements: []
|
253
258
|
rubyforge_project:
|
254
259
|
rubygems_version: 1.8.24
|
@@ -263,6 +268,7 @@ test_files:
|
|
263
268
|
- spec/uia/element_spec.rb
|
264
269
|
- spec/uia/patterns/expand_collapse_spec.rb
|
265
270
|
- spec/uia/patterns/invoke_spec.rb
|
271
|
+
- spec/uia/patterns/range_value_spec.rb
|
266
272
|
- spec/uia/patterns/selection_item_spec.rb
|
267
273
|
- spec/uia/patterns/selection_spec.rb
|
268
274
|
- spec/uia/patterns/table_item_spec.rb
|