uia 0.0.5.1 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +17 -2
- data/Gemfile +1 -0
- data/Rakefile +13 -0
- data/ext/UiaDll/UIA.Helper/{AutomationProperty.cs → AutomationPropertyCondition.cs} +1 -1
- data/ext/UiaDll/UIA.Helper/Element.cs +46 -6
- data/ext/UiaDll/UIA.Helper/Extensions.cs +13 -0
- data/ext/UiaDll/UIA.Helper/UIA.Helper.csproj +1 -1
- data/ext/UiaDll/UiaDll.Test/ElementInformationTest.cpp +20 -4
- data/ext/UiaDll/UiaDll.Test/ElementStub.h +16 -2
- data/ext/UiaDll/UiaDll.Test/PatternInformationTest.cpp +35 -0
- data/ext/UiaDll/UiaDll.Test/UiaDll.Test.vcxproj +6 -4
- data/ext/UiaDll/UiaDll.Test/UiaDll.Test.vcxproj.filters +3 -0
- data/ext/UiaDll/UiaDll/ElementMethods.cpp +62 -17
- data/ext/UiaDll/UiaDll/ElementStructures.h +19 -9
- data/ext/UiaDll/UiaDll/ExpandCollapseMethods.cpp +33 -0
- data/ext/UiaDll/UiaDll/InvokePatternMethods.cpp +11 -0
- data/ext/UiaDll/UiaDll/PatternInformationStructures.h +90 -0
- data/ext/UiaDll/UiaDll/SelectionItemMethods.cpp +40 -0
- data/ext/UiaDll/UiaDll/SelectionMethods.cpp +16 -0
- data/ext/UiaDll/UiaDll/Stdafx.h +3 -0
- data/ext/UiaDll/UiaDll/ToggleMethods.cpp +25 -0
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj +9 -0
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +24 -0
- data/ext/UiaDll/UiaDll/ValuePatternMethods.cpp +25 -0
- data/lib/uia.rb +14 -6
- data/lib/uia/element.rb +35 -11
- data/lib/uia/finder.rb +33 -0
- data/lib/uia/library.rb +48 -6
- data/lib/uia/library/element_attributes.rb +11 -0
- data/lib/uia/library/structs.rb +93 -5
- data/lib/uia/patterns/expand_collapse.rb +17 -0
- data/lib/uia/patterns/invoke.rb +9 -0
- data/lib/uia/patterns/selection.rb +17 -0
- data/lib/uia/patterns/selection_item.rb +25 -0
- data/lib/uia/patterns/toggle.rb +17 -0
- data/lib/uia/patterns/value.rb +22 -0
- data/lib/uia/version.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- data/spec/uia/element_spec.rb +35 -8
- data/spec/uia/patterns/expand_collapse_spec.rb +24 -0
- data/spec/uia/patterns/invoke_spec.rb +15 -0
- data/spec/uia/patterns/selection_item_spec.rb +55 -0
- data/spec/uia/patterns/selection_spec.rb +30 -0
- data/spec/uia/patterns/toggle_spec.rb +41 -0
- data/spec/uia/patterns/value_spec.rb +16 -0
- data/spec/uia_spec.rb +26 -7
- metadata +37 -4
@@ -7,27 +7,37 @@ typedef struct _ElementInformation {
|
|
7
7
|
int* runtimeId;
|
8
8
|
int runtimeIdLength;
|
9
9
|
char* name;
|
10
|
+
char* className;
|
10
11
|
int controlTypeId;
|
11
12
|
int* patterns;
|
12
13
|
int patternsLength;
|
13
14
|
char* id;
|
14
15
|
|
15
|
-
|
16
|
+
bool isEnabled;
|
16
17
|
|
17
|
-
_ElementInformation(
|
18
|
-
|
18
|
+
_ElementInformation() : name(NULL), nativeWindowHandle(0), runtimeId(NULL), patterns(NULL), id(NULL), className(NULL) {}
|
19
|
+
|
20
|
+
_ElementInformation(Element^ element) : name(NULL), nativeWindowHandle(0), runtimeId(NULL), patterns(NULL), id(NULL), className(NULL) {
|
21
|
+
Refresh(element);
|
22
|
+
}
|
23
|
+
|
24
|
+
static _ElementInformation* From(Element^ element) {
|
25
|
+
return nullptr != element ? new _ElementInformation(element) : NULL;
|
19
26
|
}
|
20
27
|
|
21
|
-
void
|
28
|
+
void Refresh(Element^ element) {
|
22
29
|
Reset();
|
23
30
|
id = StringHelper::ToUnmanaged(element->Id);
|
24
31
|
name = StringHelper::ToUnmanaged(element->Name);
|
32
|
+
className = StringHelper::ToUnmanaged(element->ClassName);
|
25
33
|
nativeWindowHandle = element->NativeWindowHandle;
|
26
34
|
runtimeId = ArrayHelper::FromArray(element->RuntimeId);
|
27
35
|
runtimeIdLength = element->RuntimeId->Length;
|
28
36
|
controlTypeId = element->ControlTypeId;
|
29
37
|
patterns = ArrayHelper::FromArray(element->SupportedPatternIds);
|
30
38
|
patternsLength = element->SupportedPatternIds->Length;
|
39
|
+
|
40
|
+
isEnabled = element->IsEnabled;
|
31
41
|
}
|
32
42
|
|
33
43
|
~_ElementInformation() {
|
@@ -36,11 +46,11 @@ typedef struct _ElementInformation {
|
|
36
46
|
|
37
47
|
private:
|
38
48
|
void Reset() {
|
39
|
-
delete[] name; delete[] runtimeId; delete[] patterns; delete[] id;
|
40
|
-
name = NULL; runtimeId = NULL; patterns = NULL; id = NULL;
|
49
|
+
delete[] name; delete[] runtimeId; delete[] patterns; delete[] id; delete[] className;
|
50
|
+
name = NULL; runtimeId = NULL; patterns = NULL; id = NULL; className = NULL;
|
41
51
|
}
|
42
52
|
|
43
|
-
} ElementInformation, *
|
53
|
+
} ElementInformation, *ElementInformationPtr;
|
44
54
|
|
45
55
|
typedef struct _Elements {
|
46
56
|
int length;
|
@@ -54,11 +64,11 @@ typedef struct _Elements {
|
|
54
64
|
|
55
65
|
auto index = 0;
|
56
66
|
for each(auto element in elements) {
|
57
|
-
this->elements[index++].
|
67
|
+
this->elements[index++].Refresh(element);
|
58
68
|
}
|
59
69
|
}
|
60
70
|
|
61
71
|
~_Elements() {
|
62
72
|
delete[] elements;
|
63
73
|
}
|
64
|
-
} Elements, *
|
74
|
+
} Elements, *ElementsPtr;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#include "Stdafx.h"
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
__declspec(dllexport) void ExpandCollapse_Release(ExpandCollapseInfoPtr expandCollapseInfo) {
|
5
|
+
delete expandCollapseInfo;
|
6
|
+
}
|
7
|
+
|
8
|
+
__declspec(dllexport) ExpandCollapseInfoPtr ExpandCollapse_Information(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
9
|
+
try {
|
10
|
+
auto info = Find(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Current;
|
11
|
+
return new ExpandCollapseInfo(info.ExpandCollapseState.ToString());
|
12
|
+
} catch(Exception^ e) {
|
13
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
14
|
+
return NULL;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
__declspec(dllexport) void ExpandCollapse_Expand(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
19
|
+
try {
|
20
|
+
Find(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Expand();
|
21
|
+
} catch(Exception^ e) {
|
22
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
__declspec(dllexport) void ExpandCollapse_Collapse(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
27
|
+
try {
|
28
|
+
Find(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Collapse();
|
29
|
+
} catch(Exception^ e) {
|
30
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "Stdafx.h"
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
__declspec(dllexport) void Invoke(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
5
|
+
try {
|
6
|
+
Find(element)->As<InvokePattern^>(InvokePattern::Pattern)->Invoke();
|
7
|
+
} catch(Exception^ e) {
|
8
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
9
|
+
}
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "StringHelper.h"
|
4
|
+
#include "ElementStructures.h"
|
5
|
+
|
6
|
+
using namespace System::Windows::Automation;
|
7
|
+
|
8
|
+
typedef struct _ValuePatternInformation {
|
9
|
+
bool IsReadOnly;
|
10
|
+
char* Value;
|
11
|
+
|
12
|
+
_ValuePatternInformation(String^ value, bool IsReadOnly) {
|
13
|
+
init(value, IsReadOnly);
|
14
|
+
}
|
15
|
+
|
16
|
+
_ValuePatternInformation(ValuePattern::ValuePatternInformation^ info) {
|
17
|
+
init(info->Value, info->IsReadOnly);
|
18
|
+
}
|
19
|
+
|
20
|
+
~_ValuePatternInformation() {
|
21
|
+
delete[] Value;
|
22
|
+
}
|
23
|
+
|
24
|
+
private:
|
25
|
+
void init(String^ value, bool IsReadOnly) {
|
26
|
+
this->IsReadOnly = IsReadOnly;
|
27
|
+
Value = StringHelper::ToUnmanaged(value);
|
28
|
+
}
|
29
|
+
|
30
|
+
} ValuePatternInformation, *ValuePatternInformationPtr;
|
31
|
+
|
32
|
+
typedef struct _ToggleInformation {
|
33
|
+
char* ToggleState;
|
34
|
+
|
35
|
+
_ToggleInformation(String^ toggleState) {
|
36
|
+
ToggleState = StringHelper::ToUnmanaged(toggleState);
|
37
|
+
}
|
38
|
+
|
39
|
+
~_ToggleInformation() {
|
40
|
+
delete[] ToggleState;
|
41
|
+
}
|
42
|
+
|
43
|
+
} ToggleInformation, *ToggleInformationPtr;
|
44
|
+
|
45
|
+
typedef struct _SelectionInformation {
|
46
|
+
bool CanSelectMultiple;
|
47
|
+
bool IsSelectionRequired;
|
48
|
+
|
49
|
+
_SelectionInformation(SelectionPattern::SelectionPatternInformation^ info) {
|
50
|
+
CanSelectMultiple = info->CanSelectMultiple;
|
51
|
+
IsSelectionRequired = info->IsSelectionRequired;
|
52
|
+
}
|
53
|
+
} SelectionInformation, *SelectionInformationPtr;
|
54
|
+
|
55
|
+
typedef struct _SelectionItemInformation {
|
56
|
+
bool IsSelected;
|
57
|
+
ElementInformationPtr Container;
|
58
|
+
|
59
|
+
_SelectionItemInformation(SelectionItemPattern::SelectionItemPatternInformation^ info) {
|
60
|
+
init(info->IsSelected, Element::From(info->SelectionContainer));
|
61
|
+
}
|
62
|
+
|
63
|
+
_SelectionItemInformation(bool isSelected, Element^ selectionContainer) { // for testing
|
64
|
+
init(isSelected, selectionContainer);
|
65
|
+
}
|
66
|
+
|
67
|
+
~_SelectionItemInformation() {
|
68
|
+
delete Container;
|
69
|
+
}
|
70
|
+
|
71
|
+
private:
|
72
|
+
void init(bool isSelected, Element^ selectionContainer) {
|
73
|
+
IsSelected = isSelected;
|
74
|
+
Container = new ElementInformation(selectionContainer);
|
75
|
+
}
|
76
|
+
|
77
|
+
} SelectionItemInformation, *SelectionItemInformationPtr;
|
78
|
+
|
79
|
+
|
80
|
+
typedef struct _ExpandCollapseInfo {
|
81
|
+
char* ExpandCollapseState;
|
82
|
+
|
83
|
+
_ExpandCollapseInfo(String^ expandCollapseState) {
|
84
|
+
ExpandCollapseState = StringHelper::ToUnmanaged(expandCollapseState);
|
85
|
+
}
|
86
|
+
|
87
|
+
~_ExpandCollapseInfo() {
|
88
|
+
delete[] ExpandCollapseState;
|
89
|
+
}
|
90
|
+
} ExpandCollapseInfo, *ExpandCollapseInfoPtr;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#include "Stdafx.h"
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
__declspec(dllexport) void SelectionItem_Release(SelectionItemInformationPtr selectionItemInfo) {
|
5
|
+
delete selectionItemInfo;
|
6
|
+
}
|
7
|
+
|
8
|
+
__declspec(dllexport) SelectionItemInformationPtr SelectionItem_Information(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
9
|
+
try {
|
10
|
+
auto info = Find(element)->As<SelectionItemPattern^>(SelectionItemPattern::Pattern)->Current;
|
11
|
+
return new SelectionItemInformation(info);
|
12
|
+
} catch(Exception^ e) {
|
13
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
__declspec(dllexport) void SelectionItem_Select(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
18
|
+
try {
|
19
|
+
Find(element)->As<SelectionItemPattern^>(SelectionItemPattern::Pattern)->Select();
|
20
|
+
} catch(Exception^ e) {
|
21
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
__declspec(dllexport) void SelectionItem_AddToSelection(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
26
|
+
try {
|
27
|
+
Find(element)->As<SelectionItemPattern^>(SelectionItemPattern::Pattern)->AddToSelection();
|
28
|
+
} catch(Exception^ e) {
|
29
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
__declspec(dllexport) void SelectionItem_RemoveFromSelection(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
34
|
+
try {
|
35
|
+
Find(element)->As<SelectionItemPattern^>(SelectionItemPattern::Pattern)->RemoveFromSelection();
|
36
|
+
} catch(Exception^ e) {
|
37
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#include "Stdafx.h"
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
__declspec(dllexport) void Selection_Release(SelectionInformationPtr selectionInfo) {
|
5
|
+
delete selectionInfo;
|
6
|
+
}
|
7
|
+
|
8
|
+
__declspec(dllexport) SelectionInformationPtr Selection_Information(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
9
|
+
try {
|
10
|
+
return new SelectionInformation(Find(element)->As<SelectionPattern^>(SelectionPattern::Pattern)->Current);
|
11
|
+
} catch(Exception^ e) {
|
12
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
13
|
+
return NULL;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
data/ext/UiaDll/UiaDll/Stdafx.h
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
#include "Stdafx.h"
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
__declspec(dllexport) void Toggle_Release(ToggleInformationPtr toggleInfo) {
|
5
|
+
delete toggleInfo;
|
6
|
+
}
|
7
|
+
|
8
|
+
__declspec(dllexport) ToggleInformationPtr Toggle_Information(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
9
|
+
try {
|
10
|
+
auto info = Find(element)->As<TogglePattern^>(TogglePattern::Pattern)->Current;
|
11
|
+
return new ToggleInformation(info.ToggleState.ToString());
|
12
|
+
} catch(Exception^ e) {
|
13
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
14
|
+
return NULL;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
__declspec(dllexport) void Toggle(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
19
|
+
try {
|
20
|
+
Find(element)->As<TogglePattern^>(TogglePattern::Pattern)->Toggle();
|
21
|
+
} catch(Exception^ e) {
|
22
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
@@ -74,11 +74,14 @@
|
|
74
74
|
<Reference Include="System" />
|
75
75
|
<Reference Include="System.Data" />
|
76
76
|
<Reference Include="System.Xml" />
|
77
|
+
<Reference Include="UIAutomationClient" />
|
78
|
+
<Reference Include="UIAutomationTypes" />
|
77
79
|
</ItemGroup>
|
78
80
|
<ItemGroup>
|
79
81
|
<ClInclude Include="ArrayHelper.h" />
|
80
82
|
<ClInclude Include="DynamicAssemblyResolver.h" />
|
81
83
|
<ClInclude Include="ElementStructures.h" />
|
84
|
+
<ClInclude Include="PatternInformationStructures.h" />
|
82
85
|
<ClInclude Include="Stdafx.h" />
|
83
86
|
<ClInclude Include="StringHelper.h" />
|
84
87
|
</ItemGroup>
|
@@ -86,11 +89,17 @@
|
|
86
89
|
<ClCompile Include="AssemblyInfo.cpp" />
|
87
90
|
<ClCompile Include="DynamicAssemblyResolver.cpp" />
|
88
91
|
<ClCompile Include="ElementMethods.cpp" />
|
92
|
+
<ClCompile Include="ExpandCollapseMethods.cpp" />
|
93
|
+
<ClCompile Include="InvokePatternMethods.cpp" />
|
94
|
+
<ClCompile Include="SelectionItemMethods.cpp" />
|
95
|
+
<ClCompile Include="SelectionMethods.cpp" />
|
89
96
|
<ClCompile Include="Stdafx.cpp">
|
90
97
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
91
98
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
92
99
|
</ClCompile>
|
100
|
+
<ClCompile Include="ToggleMethods.cpp" />
|
93
101
|
<ClCompile Include="UiaDll.cpp" />
|
102
|
+
<ClCompile Include="ValuePatternMethods.cpp" />
|
94
103
|
</ItemGroup>
|
95
104
|
<ItemGroup>
|
96
105
|
<ProjectReference Include="..\UIA.Helper\UIA.Helper.csproj">
|
@@ -13,6 +13,9 @@
|
|
13
13
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
14
14
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
15
15
|
</Filter>
|
16
|
+
<Filter Include="Source Files\Patterns">
|
17
|
+
<UniqueIdentifier>{a1dddb33-e832-4b83-b6d7-46462084fad2}</UniqueIdentifier>
|
18
|
+
</Filter>
|
16
19
|
</ItemGroup>
|
17
20
|
<ItemGroup>
|
18
21
|
<ClInclude Include="Stdafx.h">
|
@@ -30,6 +33,9 @@
|
|
30
33
|
<ClInclude Include="ElementStructures.h">
|
31
34
|
<Filter>Header Files</Filter>
|
32
35
|
</ClInclude>
|
36
|
+
<ClInclude Include="PatternInformationStructures.h">
|
37
|
+
<Filter>Header Files</Filter>
|
38
|
+
</ClInclude>
|
33
39
|
</ItemGroup>
|
34
40
|
<ItemGroup>
|
35
41
|
<ClCompile Include="UiaDll.cpp">
|
@@ -47,5 +53,23 @@
|
|
47
53
|
<ClCompile Include="ElementMethods.cpp">
|
48
54
|
<Filter>Source Files</Filter>
|
49
55
|
</ClCompile>
|
56
|
+
<ClCompile Include="ValuePatternMethods.cpp">
|
57
|
+
<Filter>Source Files\Patterns</Filter>
|
58
|
+
</ClCompile>
|
59
|
+
<ClCompile Include="InvokePatternMethods.cpp">
|
60
|
+
<Filter>Source Files\Patterns</Filter>
|
61
|
+
</ClCompile>
|
62
|
+
<ClCompile Include="ToggleMethods.cpp">
|
63
|
+
<Filter>Source Files\Patterns</Filter>
|
64
|
+
</ClCompile>
|
65
|
+
<ClCompile Include="SelectionItemMethods.cpp">
|
66
|
+
<Filter>Source Files\Patterns</Filter>
|
67
|
+
</ClCompile>
|
68
|
+
<ClCompile Include="SelectionMethods.cpp">
|
69
|
+
<Filter>Source Files\Patterns</Filter>
|
70
|
+
</ClCompile>
|
71
|
+
<ClCompile Include="ExpandCollapseMethods.cpp">
|
72
|
+
<Filter>Source Files\Patterns</Filter>
|
73
|
+
</ClCompile>
|
50
74
|
</ItemGroup>
|
51
75
|
</Project>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#include "Stdafx.h"
|
2
|
+
|
3
|
+
extern "C" {
|
4
|
+
__declspec(dllexport) void Value_Release(ValuePatternInformationPtr valueInformation) {
|
5
|
+
delete valueInformation;
|
6
|
+
}
|
7
|
+
|
8
|
+
__declspec(dllexport) void Value_Set(ElementInformationPtr element, const char* value, char* errorInfo, const int errorInfoLength) {
|
9
|
+
try {
|
10
|
+
Find(element)->As<ValuePattern^>(ValuePattern::Pattern)->SetValue(gcnew String(value));
|
11
|
+
} catch(Exception^ e) {
|
12
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
__declspec(dllexport) ValuePatternInformationPtr Value_Information(ElementInformationPtr element, char* errorInfo, const int errorInfoLength) {
|
17
|
+
try {
|
18
|
+
auto valuePattern = Find(element)->As<ValuePattern^>(ValuePattern::Pattern);
|
19
|
+
return new ValuePatternInformation(valuePattern->Current);
|
20
|
+
} catch(Exception^ e) {
|
21
|
+
StringHelper::CopyToUnmanagedString(e->Message, errorInfo, errorInfoLength);
|
22
|
+
return NULL;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
data/lib/uia.rb
CHANGED
@@ -1,21 +1,29 @@
|
|
1
1
|
require 'uia/version'
|
2
2
|
require 'uia/library'
|
3
|
-
require 'uia/element'
|
4
3
|
require 'uia/library/constants'
|
4
|
+
require 'uia/element'
|
5
|
+
require 'uia/finder'
|
5
6
|
|
6
7
|
module Uia
|
7
8
|
class BadLocator < StandardError; end
|
9
|
+
extend Finder
|
10
|
+
|
11
|
+
def self.children
|
12
|
+
Library.root_children.children
|
13
|
+
end
|
8
14
|
|
9
|
-
def find_element(how)
|
15
|
+
def self.find_element(how)
|
10
16
|
case
|
11
17
|
when how[:id]
|
12
|
-
|
18
|
+
find_by_id how[:id]
|
19
|
+
when how[:name]
|
20
|
+
find_by_name how[:name]
|
13
21
|
when how[:pid]
|
14
|
-
|
22
|
+
find_by_pid how[:pid]
|
15
23
|
when how[:runtime_id]
|
16
|
-
|
24
|
+
find_by_runtime_id how[:runtime_id]
|
17
25
|
when how[:handle]
|
18
|
-
|
26
|
+
find_by_handle how[:handle]
|
19
27
|
else
|
20
28
|
raise BadLocator, "#{how} is not a valid locator"
|
21
29
|
end
|
data/lib/uia/element.rb
CHANGED
@@ -1,20 +1,51 @@
|
|
1
|
+
require 'uia/patterns/expand_collapse'
|
2
|
+
require 'uia/patterns/invoke'
|
3
|
+
require 'uia/patterns/selection'
|
4
|
+
require 'uia/patterns/selection_item'
|
5
|
+
require 'uia/patterns/toggle'
|
6
|
+
require 'uia/patterns/value'
|
7
|
+
require 'uia/library/element_attributes'
|
8
|
+
|
1
9
|
module Uia
|
2
10
|
class Element
|
11
|
+
extend ElementAttributes
|
12
|
+
|
3
13
|
def initialize(element)
|
4
14
|
@element = element
|
5
15
|
@default = lambda { [:unknown] }
|
6
16
|
end
|
7
17
|
|
18
|
+
element_attr :id, :name, :handle, :runtime_id, :enabled?, :class_name
|
19
|
+
|
8
20
|
def control_type
|
9
|
-
Library::Constants::ControlTypes.find(@default) { |_, v| v == control_type_id }.first
|
21
|
+
Library::Constants::ControlTypes.find(@default) { |_, v| v == @element.control_type_id }.first
|
10
22
|
end
|
11
23
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
24
|
+
def refresh
|
25
|
+
Library.refresh @element
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def find(locator)
|
30
|
+
case
|
31
|
+
when locator[:id]
|
32
|
+
Library::find_child_by_id(@element, locator[:id])
|
33
|
+
when locator[:name]
|
34
|
+
Library::find_child_by_name(@element, locator[:name])
|
15
35
|
end
|
16
36
|
end
|
17
37
|
|
38
|
+
def as(pattern)
|
39
|
+
which = "Uia::Patterns::#{pattern.to_s.capitalize}".split('::').reduce(Object) do |m, current|
|
40
|
+
m.const_get current.split('_').map(&:capitalize).join
|
41
|
+
end
|
42
|
+
extend which
|
43
|
+
end
|
44
|
+
|
45
|
+
def patterns
|
46
|
+
@element.pattern_ids.map {|id| Library::Constants::Patterns.find(@default) { |_, v| v == id }.first }
|
47
|
+
end
|
48
|
+
|
18
49
|
def children
|
19
50
|
@element.children.map { |c| Element.new c }
|
20
51
|
end
|
@@ -27,12 +58,5 @@ module Uia
|
|
27
58
|
Library.click(@element)
|
28
59
|
true
|
29
60
|
end
|
30
|
-
|
31
|
-
def method_missing(meth, *args, &block)
|
32
|
-
if @element.respond_to? meth
|
33
|
-
return @element.send(meth, *args, &block)
|
34
|
-
end
|
35
|
-
super
|
36
|
-
end
|
37
61
|
end
|
38
62
|
end
|