rautomation 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -8
- data/Gemfile.lock +2 -2
- data/History.rdoc +13 -0
- data/README.rdoc +3 -2
- data/Rakefile +30 -10
- data/VERSION +1 -1
- data/ext/UiaDll/Release/UiaDll.dll +0 -0
- data/ext/UiaDll/UiaDll/AssemblyInfo.cpp +40 -0
- data/ext/UiaDll/UiaDll/AutomatedComboBox.cpp +66 -0
- data/ext/UiaDll/UiaDll/AutomatedComboBox.h +32 -0
- data/ext/UiaDll/UiaDll/AutomatedTable.cpp +50 -0
- data/ext/UiaDll/UiaDll/AutomatedTable.h +22 -0
- data/ext/UiaDll/UiaDll/AutomationClicker.cpp +50 -0
- data/ext/UiaDll/UiaDll/AutomationClicker.h +24 -0
- data/ext/UiaDll/UiaDll/ExpandCollapseHelper.cpp +53 -0
- data/ext/UiaDll/UiaDll/ExpandCollapseHelper.h +22 -0
- data/ext/UiaDll/UiaDll/MenuItemSelector.cpp +75 -0
- data/ext/UiaDll/UiaDll/MenuItemSelector.h +22 -0
- data/ext/UiaDll/UiaDll/ReadMe.txt +8 -18
- data/ext/UiaDll/UiaDll/StringHelper.cpp +9 -0
- data/ext/UiaDll/UiaDll/StringHelper.h +7 -0
- data/ext/UiaDll/UiaDll/ToggleStateHelper.cpp +33 -0
- data/ext/UiaDll/UiaDll/ToggleStateHelper.h +10 -0
- data/ext/UiaDll/UiaDll/UiaDll.cpp +458 -325
- data/ext/UiaDll/UiaDll/UiaDll.h +13 -0
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj +45 -28
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +66 -7
- data/ext/UiaDll/UiaDll/app.ico +0 -0
- data/ext/UiaDll/UiaDll/app.rc +0 -0
- data/ext/UiaDll/UiaDll/dllmain.cpp +5 -23
- data/ext/UiaDll/UiaDll/resource.h +3 -0
- data/ext/UiaDll/UiaDll/stdafx.cpp +0 -3
- data/ext/UiaDll/UiaDll/stdafx.h +23 -18
- data/ext/UiaDll/UiaDll.sln +6 -6
- data/ext/WindowsForms/Release/WindowsForms.exe +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.Designer.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.resx +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.Designer.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.resx +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.Designer.cs +173 -76
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.cs +76 -77
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.resx +3 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.Designer.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.resx +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Program.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/AssemblyInfo.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Resources.Designer.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Resources.resx +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Settings.Designer.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Settings.settings +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.Designer.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.cs +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.resx +0 -0
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/WindowsForms.csproj +2 -2
- data/ext/WindowsForms/{src/WindowsForms/WindowsForms.sln → WindowsForms.sln} +0 -0
- data/lib/rautomation/adapter/ms_uia/constants.rb +1 -0
- data/lib/rautomation/adapter/ms_uia/control.rb +11 -0
- data/lib/rautomation/adapter/ms_uia/functions.rb +8 -5
- data/lib/rautomation/adapter/ms_uia/menu.rb +36 -0
- data/lib/rautomation/adapter/ms_uia/select_list.rb +4 -12
- data/lib/rautomation/adapter/ms_uia/table.rb +90 -11
- data/lib/rautomation/adapter/ms_uia/uia_dll.rb +48 -2
- data/lib/rautomation/adapter/ms_uia/window.rb +6 -1
- data/lib/rautomation/adapter/ms_uia.rb +1 -0
- data/spec/adapter/autoit/mouse_spec.rb +2 -2
- data/spec/adapter/ms_uia/functions_spec.rb +39 -0
- data/spec/adapter/ms_uia/select_list_spec.rb +26 -13
- data/spec/adapter/ms_uia/table_spec.rb +96 -2
- data/spec/adapter/ms_uia/window_spec.rb +37 -11
- data/spec/adapter/win_32/mouse_spec.rb +2 -2
- data/spec/adapter/win_32/window_spec.rb +0 -9
- data/spec/spec_helper.rb +3 -3
- data/spec/window_spec.rb +17 -6
- metadata +48 -40
- data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.cpp +0 -174
- data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj +0 -95
- data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj.filters +0 -42
- data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj.user +0 -3
- data/ext/ListViewExplorer/ListViewExplorer/ReadMe.txt +0 -40
- data/ext/ListViewExplorer/ListViewExplorer/stdafx.cpp +0 -8
- data/ext/ListViewExplorer/ListViewExplorer/stdafx.h +0 -17
- data/ext/ListViewExplorer/ListViewExplorer/table_support.cpp +0 -250
- data/ext/ListViewExplorer/ListViewExplorer/table_support.h +0 -2
- data/ext/ListViewExplorer/ListViewExplorer/targetver.h +0 -8
- data/ext/ListViewExplorer/ListViewExplorer.sln +0 -20
- data/ext/ListViewExplorer/ListViewExplorer.suo +0 -0
- data/ext/UiaDll/UiaDll.suo +0 -0
- data/ext/WindowsForms/bin/WindowsForms.exe +0 -0
- data/ext/WindowsForms/src/WindowsForms/WindowsForms.suo +0 -0
@@ -2,449 +2,582 @@
|
|
2
2
|
//
|
3
3
|
|
4
4
|
#include "stdafx.h"
|
5
|
+
#include "AutomatedComboBox.h"
|
6
|
+
#include "AutomatedTable.h"
|
7
|
+
#include "AutomationClicker.h"
|
8
|
+
#include "ExpandCollapseHelper.h"
|
9
|
+
#include "MenuItemSelector.h"
|
10
|
+
#include "ToggleStateHelper.h"
|
5
11
|
|
6
|
-
|
7
|
-
__declspec( dllexport ) IUIAutomationElement *RA_FindWindow(char *pszAutomationId) {
|
8
|
-
IUIAutomationElement *pRootElement ;
|
12
|
+
IUIAutomation* getGlobalIUIAutomation() ;
|
9
13
|
|
10
|
-
HRESULT hr = getGlobalIUIAutomation()->GetRootElement(&pRootElement) ;
|
11
|
-
if (SUCCEEDED(hr)) {
|
12
|
-
IUIAutomationCondition *pCondition ;
|
13
|
-
VARIANT varProperty ;
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
BOOL MenuItemExists(const HWND windowHandle, std::list<const char*>& menuItems);
|
16
|
+
void SelectMenuItem(const HWND windowHandle, char* errorInfo, const int errorInfoSize, std::list<const char*>& menuItems);
|
17
|
+
int McppHowManyDataItemsFor(const HWND windowHandle);
|
18
|
+
|
19
|
+
extern "C" {
|
20
|
+
__declspec( dllexport ) IUIAutomationElement *RA_FindWindow(char *pszAutomationId) {
|
21
|
+
IUIAutomationElement *pRootElement ;
|
18
22
|
|
19
|
-
hr = getGlobalIUIAutomation()->
|
23
|
+
HRESULT hr = getGlobalIUIAutomation()->GetRootElement(&pRootElement) ;
|
20
24
|
if (SUCCEEDED(hr)) {
|
21
|
-
|
25
|
+
IUIAutomationCondition *pCondition ;
|
26
|
+
VARIANT varProperty ;
|
27
|
+
|
28
|
+
VariantInit(&varProperty) ;
|
29
|
+
varProperty.vt = VT_BSTR ;
|
30
|
+
varProperty.bstrVal = _bstr_t(pszAutomationId) ;
|
22
31
|
|
23
|
-
hr =
|
32
|
+
hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_AutomationIdPropertyId, varProperty, &pCondition) ;
|
24
33
|
if (SUCCEEDED(hr)) {
|
25
|
-
|
34
|
+
IUIAutomationElement *pFound ;
|
35
|
+
|
36
|
+
hr = pRootElement->FindFirst(TreeScope_Children, pCondition, &pFound) ;
|
37
|
+
if (SUCCEEDED(hr)) {
|
38
|
+
return pFound ;
|
39
|
+
}
|
26
40
|
}
|
27
41
|
}
|
42
|
+
return NULL ;
|
28
43
|
}
|
29
|
-
return NULL ;
|
30
|
-
}
|
31
|
-
|
32
|
-
//This doesn't work
|
33
|
-
extern "C"
|
34
|
-
__declspec( dllexport ) int RA_FindWindowByPID(int processId, IUIAutomationElement *pElement) {
|
35
|
-
IUIAutomationElement *pRootElement;
|
36
|
-
|
37
|
-
HRESULT hr = getGlobalIUIAutomation()->GetRootElement(&pRootElement);
|
38
|
-
if (SUCCEEDED(hr)) {
|
39
|
-
IUIAutomationCondition *pCondition;
|
40
|
-
VARIANT varProperty;
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
//This doesn't work
|
46
|
+
__declspec( dllexport ) int RA_FindWindowByPID(int processId, IUIAutomationElement *pElement) {
|
47
|
+
IUIAutomationElement *pRootElement;
|
45
48
|
|
46
|
-
hr = getGlobalIUIAutomation()->
|
49
|
+
HRESULT hr = getGlobalIUIAutomation()->GetRootElement(&pRootElement);
|
47
50
|
if (SUCCEEDED(hr)) {
|
51
|
+
IUIAutomationCondition *pCondition;
|
52
|
+
VARIANT varProperty;
|
48
53
|
|
49
|
-
|
54
|
+
VariantInit(&varProperty);
|
55
|
+
varProperty.vt = VT_I4;
|
56
|
+
varProperty.intVal = (processId);
|
57
|
+
|
58
|
+
hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_ProcessIdPropertyId, varProperty, &pCondition);
|
50
59
|
if (SUCCEEDED(hr)) {
|
51
|
-
|
60
|
+
|
61
|
+
hr = pRootElement->FindFirst(TreeScope_Children, pCondition, &pElement);
|
62
|
+
if (SUCCEEDED(hr)) {
|
63
|
+
return 1;
|
64
|
+
}
|
52
65
|
}
|
53
66
|
}
|
67
|
+
return 0;
|
54
68
|
}
|
55
|
-
return 0;
|
56
|
-
}
|
57
69
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
pElement->get_CurrentIsOffscreen(&isOffscreen) ;
|
70
|
+
__declspec( dllexport ) BOOL RA_IsOffscreen(IUIAutomationElement *pElement) {
|
71
|
+
BOOL isOffscreen ;
|
72
|
+
pElement->get_CurrentIsOffscreen(&isOffscreen) ;
|
62
73
|
|
63
|
-
|
64
|
-
}
|
74
|
+
return isOffscreen ;
|
75
|
+
}
|
65
76
|
|
66
|
-
|
67
|
-
|
68
|
-
IUIAutomationElement *pElement ;
|
77
|
+
__declspec ( dllexport ) IUIAutomationElement *RA_ElementFromHandle(HWND hwnd) {
|
78
|
+
IUIAutomationElement *pElement ;
|
69
79
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
80
|
+
HRESULT hr = getGlobalIUIAutomation()->ElementFromHandle(hwnd, &pElement) ;
|
81
|
+
if (SUCCEEDED(hr))
|
82
|
+
return pElement ;
|
83
|
+
else {
|
84
|
+
printf("RA_ElementFromHandle: Cannot find element from handle 0x%x. HRESULT was 0x%x\r\n", hwnd, hr) ;
|
85
|
+
return NULL ;
|
86
|
+
}
|
76
87
|
}
|
77
|
-
}
|
78
88
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
89
|
+
__declspec ( dllexport ) IUIAutomationElement *RA_GetFocusedElement() {
|
90
|
+
IUIAutomationElement *pelement;
|
91
|
+
|
92
|
+
HRESULT hr = getGlobalIUIAutomation()->GetFocusedElement(&pelement);
|
93
|
+
|
94
|
+
if (SUCCEEDED(hr))
|
95
|
+
return pelement;
|
96
|
+
else {
|
97
|
+
printf("RA_GetFocusedElement: Cannot find element from focus. HRESULT was 0x%x\r\n", hr) ;
|
98
|
+
return false ;
|
99
|
+
}
|
90
100
|
}
|
91
|
-
}
|
92
101
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
POINT point;
|
102
|
+
__declspec ( dllexport ) IUIAutomationElement *RA_ElementFromPoint(int xCoord, int yCoord) {
|
103
|
+
IUIAutomationElement *pElement ;
|
104
|
+
POINT point;
|
97
105
|
|
98
|
-
|
99
|
-
|
106
|
+
point.x = xCoord;
|
107
|
+
point.y = yCoord;
|
100
108
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
109
|
+
HRESULT hr = getGlobalIUIAutomation()->ElementFromPoint(point, &pElement) ;
|
110
|
+
if (SUCCEEDED(hr))
|
111
|
+
return pElement ;
|
112
|
+
else {
|
113
|
+
printf("RA_ElementFromPoint: Cannot find element from point %d , %d. HRESULT was 0x%x\r\n", xCoord, yCoord, hr) ;
|
114
|
+
return NULL ;
|
115
|
+
}
|
107
116
|
}
|
108
|
-
}
|
109
117
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
VariantInit(&varProperty) ;
|
115
|
-
varProperty.vt = VT_BSTR ;
|
116
|
-
varProperty.bstrVal = _bstr_t(automationId) ;
|
118
|
+
__declspec ( dllexport ) IUIAutomationElement *RA_FindChildById(IUIAutomationElement *pElement, char *automationId) {
|
119
|
+
IUIAutomationCondition *pCondition ;
|
120
|
+
VARIANT varProperty ;
|
117
121
|
|
118
|
-
|
119
|
-
|
120
|
-
|
122
|
+
VariantInit(&varProperty) ;
|
123
|
+
varProperty.vt = VT_BSTR ;
|
124
|
+
varProperty.bstrVal = _bstr_t(automationId) ;
|
121
125
|
|
122
|
-
hr =
|
126
|
+
HRESULT hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_AutomationIdPropertyId, varProperty, &pCondition) ;
|
123
127
|
if (SUCCEEDED(hr)) {
|
124
|
-
|
125
|
-
|
128
|
+
IUIAutomationElement *pFound ;
|
129
|
+
|
130
|
+
hr = pElement->FindFirst(TreeScope_Descendants, pCondition, &pFound) ;
|
131
|
+
if (SUCCEEDED(hr)) {
|
132
|
+
if (pFound == NULL)
|
133
|
+
printf("RA_FindChildById: Element with automation id %s was not found\r\n", automationId) ;
|
126
134
|
|
127
|
-
|
135
|
+
return pFound ;
|
136
|
+
} else {
|
137
|
+
printf("RA_FindChildById: FindFirst for children looking for %s failed. hr = 0x%x\r\n", automationId, hr) ;
|
138
|
+
return NULL ;
|
139
|
+
}
|
128
140
|
} else {
|
129
|
-
printf("RA_FindChildById:
|
141
|
+
printf("RA_FindChildById: Cannot create search condition. hr = 0x%x\r\n", hr) ;
|
130
142
|
return NULL ;
|
131
143
|
}
|
132
|
-
} else {
|
133
|
-
printf("RA_FindChildById: Cannot create search condition. hr = 0x%x\r\n", hr) ;
|
134
|
-
return NULL ;
|
135
144
|
}
|
136
|
-
}
|
137
145
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
VariantInit(&varProperty) ;
|
143
|
-
varProperty.vt = VT_BSTR ;
|
144
|
-
varProperty.bstrVal = _bstr_t(elementName) ;
|
146
|
+
__declspec ( dllexport ) IUIAutomationElement *RA_FindChildByName(IUIAutomationElement *pElement, char *elementName) {
|
147
|
+
IUIAutomationCondition *pCondition ;
|
148
|
+
VARIANT varProperty ;
|
145
149
|
|
146
|
-
|
147
|
-
|
148
|
-
|
150
|
+
VariantInit(&varProperty) ;
|
151
|
+
varProperty.vt = VT_BSTR ;
|
152
|
+
varProperty.bstrVal = _bstr_t(elementName) ;
|
149
153
|
|
150
|
-
hr =
|
154
|
+
HRESULT hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_NamePropertyId, varProperty, &pCondition) ;
|
151
155
|
if (SUCCEEDED(hr)) {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
+
IUIAutomationElement *pFound ;
|
157
|
+
|
158
|
+
hr = pElement->FindFirst(TreeScope_Descendants, pCondition, &pFound) ;
|
159
|
+
if (SUCCEEDED(hr)) {
|
160
|
+
if (pFound == NULL)
|
161
|
+
printf("RA_FindChildByName: Element with automation name %s was not found\r\n", elementName) ;
|
162
|
+
//printf("RA_FindChildByName: success with value %s\r\n", elementName) ;
|
163
|
+
return pFound ;
|
164
|
+
} else {
|
165
|
+
printf("RA_FindChildByName: FindFirst for children looking for %s failed. hr = 0x%x\r\n", elementName, hr) ;
|
166
|
+
return NULL ;
|
167
|
+
}
|
156
168
|
} else {
|
157
|
-
printf("RA_FindChildByName:
|
169
|
+
printf("RA_FindChildByName: Cannot create search condition. hr = 0x%x\r\n", hr) ;
|
158
170
|
return NULL ;
|
159
171
|
}
|
160
|
-
} else {
|
161
|
-
printf("RA_FindChildByName: Cannot create search condition. hr = 0x%x\r\n", hr) ;
|
162
|
-
return NULL ;
|
163
172
|
}
|
164
|
-
}
|
165
173
|
|
166
|
-
|
167
|
-
|
174
|
+
__declspec ( dllexport ) HWND RA_CurrentNativeWindowHandle(IUIAutomationElement *pElement) {
|
175
|
+
UIA_HWND uia_hwnd ;
|
168
176
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
177
|
+
if (pElement == NULL) {
|
178
|
+
printf("RA_CurrentNativeWindowHandle: Cannot operate on NULL element\r\n") ;
|
179
|
+
return (HWND)0 ;
|
180
|
+
}
|
173
181
|
|
174
|
-
|
175
|
-
|
176
|
-
}
|
182
|
+
pElement->get_CurrentNativeWindowHandle(&uia_hwnd) ;
|
183
|
+
return (HWND)uia_hwnd ;
|
184
|
+
}
|
177
185
|
|
178
|
-
|
179
|
-
|
180
|
-
|
186
|
+
__declspec ( dllexport ) int RA_GetCurrentProcessId(IUIAutomationElement *pElement) {
|
187
|
+
HRESULT hr;
|
188
|
+
int process_id;
|
181
189
|
|
182
|
-
|
190
|
+
hr = pElement->get_CurrentProcessId(&process_id);
|
183
191
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
192
|
+
if (SUCCEEDED(hr)){
|
193
|
+
return process_id;
|
194
|
+
}
|
195
|
+
else {
|
196
|
+
printf("RA_GetCurrentProcessId: get_CurrentProcessId returned 0x%x\r\n", hr) ;
|
197
|
+
return 0 ;
|
198
|
+
}
|
190
199
|
}
|
191
|
-
}
|
192
200
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
201
|
+
__declspec ( dllexport ) BOOL RA_SetFocus(IUIAutomationElement *pElement) {
|
202
|
+
HRESULT hr = pElement->SetFocus() ;
|
203
|
+
if (hr != S_OK)
|
204
|
+
printf("RA_SetFocus: SetFocus on element returned 0x%x\r\n", hr) ;
|
197
205
|
|
198
|
-
|
199
|
-
}
|
206
|
+
return SUCCEEDED(hr) ;
|
207
|
+
}
|
200
208
|
|
201
|
-
|
202
|
-
|
209
|
+
__declspec ( dllexport ) int RA_GetCurrentControlType(IUIAutomationElement *pElement) {
|
210
|
+
CONTROLTYPEID control_type ;
|
203
211
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
212
|
+
HRESULT hr = pElement->get_CurrentControlType(&control_type) ;
|
213
|
+
if (SUCCEEDED(hr))
|
214
|
+
return control_type ;
|
215
|
+
else {
|
216
|
+
printf("RA_GetCurrentControlType: CurrentControlType returned 0x%x\r\n", hr) ;
|
217
|
+
return 0 ;
|
218
|
+
}
|
210
219
|
}
|
211
|
-
}
|
212
220
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
}
|
221
|
+
__declspec ( dllexport ) long RA_ClickMouse() {
|
222
|
+
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
223
|
+
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
224
|
+
return 0;
|
225
|
+
}
|
218
226
|
|
219
|
-
|
220
|
-
|
221
|
-
}
|
227
|
+
__declspec ( dllexport ) long RA_MoveMouse(int x, int y) {
|
228
|
+
return SetCursorPos(x,y);
|
229
|
+
}
|
222
230
|
|
223
|
-
|
224
|
-
|
225
|
-
}
|
231
|
+
__declspec ( dllexport ) long RA_GetDesktopHandle() {
|
232
|
+
return (long)GetDesktopWindow();
|
233
|
+
}
|
226
234
|
|
227
|
-
|
228
|
-
|
235
|
+
__declspec ( dllexport ) int RA_CurrentBoundingRectangle(IUIAutomationElement *pElement, long *rectangle) {
|
236
|
+
RECT boundary;
|
229
237
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
rectangle[0] = boundary.left;
|
234
|
-
rectangle[1] = boundary.top;
|
235
|
-
rectangle[2] = boundary.right;
|
236
|
-
rectangle[3] = boundary.bottom;
|
238
|
+
HRESULT hr = pElement->get_CurrentBoundingRectangle(&boundary) ;
|
239
|
+
if (SUCCEEDED(hr)) {
|
237
240
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
241
|
+
rectangle[0] = boundary.left;
|
242
|
+
rectangle[1] = boundary.top;
|
243
|
+
rectangle[2] = boundary.right;
|
244
|
+
rectangle[3] = boundary.bottom;
|
245
|
+
|
246
|
+
return 1;
|
247
|
+
}
|
248
|
+
else {
|
249
|
+
printf("RA_CurrentBoundingRectangle: get_CurrentBoundingRectangle failed 0x%x\r\n", hr) ;
|
250
|
+
return 0 ;
|
251
|
+
}
|
243
252
|
}
|
244
|
-
}
|
245
253
|
|
246
|
-
|
247
|
-
|
254
|
+
__declspec ( dllexport ) int RA_CurrentIsOffscreen(IUIAutomationElement *pElement, int *visible) {
|
255
|
+
BOOL offscreen;
|
248
256
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
257
|
+
HRESULT hr = pElement->get_CurrentIsOffscreen(&offscreen) ;
|
258
|
+
if (SUCCEEDED(hr)) {
|
259
|
+
if(offscreen){
|
260
|
+
*visible = 1;
|
261
|
+
}
|
262
|
+
else
|
263
|
+
{
|
264
|
+
*visible = 0;
|
265
|
+
}
|
266
|
+
return 1;
|
253
267
|
}
|
254
|
-
else
|
255
|
-
|
256
|
-
|
268
|
+
else {
|
269
|
+
printf("RA_CurrentIsOffscreen: get_CurrentIsOffscreen failed 0x%x\r\n", hr) ;
|
270
|
+
return 0 ;
|
257
271
|
}
|
258
|
-
return 1;
|
259
|
-
}
|
260
|
-
else {
|
261
|
-
printf("RA_CurrentIsOffscreen: get_CurrentIsOffscreen failed 0x%x\r\n", hr) ;
|
262
|
-
return 0 ;
|
263
272
|
}
|
264
|
-
}
|
265
273
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
274
|
+
__declspec ( dllexport ) int RA_FindChildren(IUIAutomationElement *pElement, IUIAutomationElement *pChildren[]) {
|
275
|
+
IUIAutomationCondition *pTrueCondition ;
|
276
|
+
IUIAutomationElementArray *pElementArray ;
|
277
|
+
int element_count ;
|
270
278
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
279
|
+
HRESULT hr = getGlobalIUIAutomation()->CreateTrueCondition(&pTrueCondition) ;
|
280
|
+
if (FAILED(hr)) {
|
281
|
+
printf("RA_FindChildren: Could not create true condition 0x%x\r\n", hr) ;
|
282
|
+
return 0 ;
|
283
|
+
}
|
276
284
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
285
|
+
hr = pElement->FindAll(TreeScope_Children, pTrueCondition, &pElementArray) ;
|
286
|
+
if (FAILED(hr)) {
|
287
|
+
printf("RA_FindChildren: FindAll failed 0x%x\r\n", hr) ;
|
288
|
+
return 0 ;
|
289
|
+
}
|
290
|
+
|
291
|
+
hr = pElementArray->get_Length(&element_count) ;
|
292
|
+
if (FAILED(hr)) {
|
293
|
+
printf("RA_FindChildren: get_length failed 0x%x\r\n", hr) ;
|
294
|
+
return 0 ;
|
295
|
+
}
|
296
|
+
|
297
|
+
if (pChildren != NULL) {
|
298
|
+
// given some memory get the details
|
299
|
+
for (int index = 0; index < element_count; index++) {
|
300
|
+
IUIAutomationElement *pElement ;
|
301
|
+
|
302
|
+
hr = pElementArray->GetElement(index, &pElement) ;
|
303
|
+
if (FAILED(hr)) {
|
304
|
+
printf("RA_FindChildren: GetElement failed 0x%x\r\n", hr) ;
|
305
|
+
} else {
|
306
|
+
pChildren[index] = pElement ;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
return element_count ;
|
287
312
|
}
|
288
313
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
314
|
+
__declspec ( dllexport ) int RA_GetName(IUIAutomationElement *pElement, char *pName) {
|
315
|
+
BSTR bstrName ;
|
316
|
+
HRESULT hr = pElement->get_CurrentName(&bstrName) ;
|
317
|
+
|
318
|
+
if (FAILED(hr)) {
|
319
|
+
printf("RA_GetName: get_CurrentName failed 0x%x\r\n", hr) ;
|
320
|
+
return -1 ;
|
321
|
+
}
|
293
322
|
|
294
|
-
|
295
|
-
|
296
|
-
|
323
|
+
char *pszName = _com_util::ConvertBSTRToString(bstrName) ;
|
324
|
+
|
325
|
+
if (pszName != NULL){
|
326
|
+
if (pName == NULL) {
|
327
|
+
return strlen(pszName) ;
|
297
328
|
} else {
|
298
|
-
|
329
|
+
strcpy(pName, pszName) ;
|
330
|
+
return strlen(pszName) ;
|
299
331
|
}
|
332
|
+
} else {
|
333
|
+
return -1;
|
300
334
|
}
|
301
335
|
}
|
302
336
|
|
303
|
-
|
304
|
-
|
337
|
+
__declspec ( dllexport ) int RA_GetClassName(IUIAutomationElement *pElement, char *pClass) {
|
338
|
+
BSTR bstrClass ;
|
339
|
+
HRESULT hr = pElement->get_CurrentClassName(&bstrClass) ;
|
340
|
+
|
341
|
+
if (FAILED(hr)) {
|
342
|
+
printf("RA_GetName: get_CurrentClassName failed 0x%x\r\n", hr) ;
|
343
|
+
return -1 ;
|
344
|
+
}
|
305
345
|
|
306
|
-
|
307
|
-
BSTR bstrName ;
|
308
|
-
HRESULT hr = pElement->get_CurrentName(&bstrName) ;
|
346
|
+
char *pszClass = _com_util::ConvertBSTRToString(bstrClass) ;
|
309
347
|
|
310
|
-
|
311
|
-
|
312
|
-
|
348
|
+
if (pszClass != NULL){
|
349
|
+
if (pClass == NULL) {
|
350
|
+
return strlen(pszClass) ;
|
351
|
+
} else {
|
352
|
+
strcpy(pClass, pszClass) ;
|
353
|
+
return strlen(pszClass) ;
|
354
|
+
}
|
355
|
+
} else {
|
356
|
+
return -1;
|
357
|
+
}
|
313
358
|
}
|
314
359
|
|
315
|
-
|
360
|
+
__declspec ( dllexport ) BOOL RA_GetIsSet(IUIAutomationElement *pElement) {
|
361
|
+
return ToggleStateHelper().IsSet(pElement);
|
362
|
+
}
|
316
363
|
|
317
|
-
|
318
|
-
|
319
|
-
|
364
|
+
__declspec ( dllexport ) BOOL RA_GetIsSelected(IUIAutomationElement *pElement) {
|
365
|
+
ISelectionItemProvider *pSelectionPattern ;
|
366
|
+
HRESULT hr = pElement->GetCurrentPattern(UIA_SelectionItemPatternId, (IUnknown**)&pSelectionPattern) ;
|
367
|
+
|
368
|
+
if (FAILED(hr)) {
|
369
|
+
printf("RA_GetIsSelected: getCurrentPattern failed 0x%x\r\n") ;
|
370
|
+
return FALSE ;
|
371
|
+
}
|
372
|
+
|
373
|
+
BOOL RetVal ;
|
374
|
+
hr = pSelectionPattern->get_IsSelected(&RetVal) ;
|
375
|
+
if (FAILED(hr)) {
|
376
|
+
printf("RA_GetIsSelected: get_IsSelected failed 0x%x\r\n", hr) ;
|
377
|
+
return FALSE ;
|
320
378
|
} else {
|
321
|
-
|
322
|
-
return strlen(pszName) ;
|
379
|
+
return RetVal ;
|
323
380
|
}
|
324
|
-
} else {
|
325
|
-
return -1;
|
326
381
|
}
|
327
|
-
}
|
328
382
|
|
329
|
-
|
330
|
-
|
331
|
-
|
383
|
+
__declspec ( dllexport ) int RA_Select(IUIAutomationElement *pElement) {
|
384
|
+
ISelectionItemProvider *pSelectionPattern ;
|
385
|
+
HRESULT hr = pElement->GetCurrentPattern(UIA_SelectionItemPatternId, (IUnknown**)&pSelectionPattern) ;
|
386
|
+
if (FAILED(hr)) {
|
387
|
+
printf("RA_GetIsSelected: getCurrentPattern failed 0x%x\r\n") ;
|
388
|
+
return FALSE ;
|
389
|
+
}
|
332
390
|
|
333
|
-
|
334
|
-
|
335
|
-
|
391
|
+
hr = pSelectionPattern->Select();
|
392
|
+
if (FAILED(hr)) {
|
393
|
+
printf("RA_Select: Select failed 0x%x\r\n", hr) ;
|
394
|
+
return 0 ;
|
395
|
+
}
|
396
|
+
|
397
|
+
return 1;
|
336
398
|
}
|
337
399
|
|
338
|
-
char
|
400
|
+
__declspec ( dllexport ) void RA_Click(const HWND windowHandle, char* errorInfo, const int errorInfoSize) {
|
401
|
+
try {
|
402
|
+
auto automationClicker = gcnew AutomationClicker(windowHandle);
|
403
|
+
automationClicker->Click();
|
404
|
+
} catch(Exception^ e) {
|
405
|
+
if( errorInfo ) {
|
406
|
+
StringHelper::CopyToUnmanagedString(e->ToString(), errorInfo, errorInfoSize);
|
407
|
+
}
|
408
|
+
}
|
409
|
+
}
|
339
410
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
411
|
+
__declspec ( dllexport ) void RA_PointAndClick(const HWND windowHandle, char* errorInfo, const int errorInfoSize) {
|
412
|
+
try {
|
413
|
+
auto automationClicker = gcnew AutomationClicker(windowHandle);
|
414
|
+
automationClicker->MouseClick();
|
415
|
+
} catch(Exception^ e) {
|
416
|
+
if( errorInfo ) {
|
417
|
+
StringHelper::CopyToUnmanagedString(e->ToString(), errorInfo, errorInfoSize);
|
418
|
+
}
|
346
419
|
}
|
347
|
-
} else {
|
348
|
-
return -1;
|
349
420
|
}
|
350
|
-
}
|
351
421
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
if (FAILED(hr)) {
|
357
|
-
printf("RA_GetIsSet: getCurrentPattern failed 0x%x\r\n") ;
|
358
|
-
return FALSE ;
|
422
|
+
__declspec ( dllexport ) int RA_GetComboOptionsCount(const HWND windowHandle) {
|
423
|
+
auto autoComboBox = gcnew AutomatedComboBox(windowHandle);
|
424
|
+
return autoComboBox->Count;
|
359
425
|
}
|
360
426
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
printf("RA_GetIsSet: get_ToggleState failed 0x%x\r\n", hr) ;
|
365
|
-
return FALSE ;
|
366
|
-
} else {
|
367
|
-
return RetVal ;
|
427
|
+
__declspec ( dllexport ) int RA_GetSelectedComboIndex(const HWND windowHandle) {
|
428
|
+
auto autoComboBox = gcnew AutomatedComboBox(windowHandle);
|
429
|
+
return autoComboBox->SelectedIndex;
|
368
430
|
}
|
369
|
-
}
|
370
431
|
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
if (FAILED(hr)) {
|
376
|
-
printf("RA_GetIsSelected: getCurrentPattern failed 0x%x\r\n") ;
|
377
|
-
return FALSE ;
|
432
|
+
__declspec ( dllexport ) bool RA_GetComboValueByIndex(const HWND windowHandle, const int whichItem, char* comboValue, const int comboValueSize) {
|
433
|
+
auto autoComboBox = gcnew AutomatedComboBox(windowHandle);
|
434
|
+
return autoComboBox->GetValueByIndex(whichItem, comboValue, comboValueSize);
|
378
435
|
}
|
379
436
|
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
printf("RA_GetIsSelected: get_IsSelected failed 0x%x\r\n", hr) ;
|
384
|
-
return FALSE ;
|
385
|
-
} else {
|
386
|
-
return RetVal ;
|
437
|
+
__declspec ( dllexport ) bool RA_SelectComboByIndex(const HWND windowHandle, const int whichItem) {
|
438
|
+
auto autoComboBox = gcnew AutomatedComboBox(windowHandle);
|
439
|
+
return autoComboBox->SelectByIndex(whichItem);
|
387
440
|
}
|
388
|
-
}
|
389
441
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
return
|
442
|
+
__declspec ( dllexport ) int RA_SelectComboByValue(IUIAutomationElement *pElement, char *pValue) {
|
443
|
+
UIA_HWND windowHandle = 0;
|
444
|
+
pElement->get_CurrentNativeWindowHandle(&windowHandle);
|
445
|
+
|
446
|
+
auto autoComboBox = gcnew AutomatedComboBox((const HWND) windowHandle);
|
447
|
+
return autoComboBox->SelectByValue(pValue);
|
396
448
|
}
|
397
449
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
450
|
+
__declspec ( dllexport ) void RA_SelectMenuItem(const HWND windowHandle, char* errorInfo, const int errorInfoSize, const char* arg0, ...) {
|
451
|
+
va_list arguments;
|
452
|
+
va_start(arguments, arg0);
|
453
|
+
|
454
|
+
std::list<const char*> menuItems;
|
455
|
+
|
456
|
+
const char* lastArgument = arg0;
|
457
|
+
while( NULL != lastArgument ) {
|
458
|
+
menuItems.push_back(lastArgument);
|
459
|
+
lastArgument = va_arg(arguments, const char*);
|
460
|
+
}
|
461
|
+
va_end(arguments);
|
462
|
+
|
463
|
+
SelectMenuItem(windowHandle, errorInfo, errorInfoSize, menuItems);
|
402
464
|
}
|
403
465
|
|
404
|
-
|
405
|
-
|
466
|
+
__declspec ( dllexport ) BOOL RA_MenuItemExists(const HWND windowHandle, const char* arg0, ...) {
|
467
|
+
va_list arguments;
|
468
|
+
va_start(arguments, arg0);
|
469
|
+
|
470
|
+
std::list<const char*> menuItems;
|
471
|
+
|
472
|
+
const char* lastArgument = arg0;
|
473
|
+
while( NULL != lastArgument ) {
|
474
|
+
menuItems.push_back(lastArgument);
|
475
|
+
lastArgument = va_arg(arguments, const char*);
|
476
|
+
}
|
477
|
+
va_end(arguments);
|
406
478
|
|
407
|
-
|
408
|
-
IValueProvider *pValuePattern ;
|
409
|
-
HRESULT hr = pElement->GetCurrentPattern(UIA_ValuePatternId, (IUnknown**)&pValuePattern) ;
|
410
|
-
|
411
|
-
if (FAILED(hr)) {
|
412
|
-
printf("RA_Set_Value: getCurrentPattern failed 0x%x\r\n") ;
|
413
|
-
return 0 ;
|
479
|
+
return MenuItemExists(windowHandle, menuItems);
|
414
480
|
}
|
415
481
|
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
482
|
+
__declspec ( dllexport ) int RA_GetDataItemCount(const HWND windowHandle) {
|
483
|
+
try {
|
484
|
+
auto tableControl = gcnew AutomatedTable(windowHandle);
|
485
|
+
return tableControl->RowCount;
|
486
|
+
} catch(Exception^ e) {
|
487
|
+
Console::WriteLine(e->ToString());
|
488
|
+
}
|
489
|
+
}
|
420
490
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
491
|
+
__declspec ( dllexport ) bool RA_DataItemExistsByValue(const HWND windowHandle, const char* whichItem) {
|
492
|
+
try {
|
493
|
+
auto tableControl = gcnew AutomatedTable(windowHandle);
|
494
|
+
return tableControl->Exists(whichItem);
|
495
|
+
} catch(Exception^ e) {
|
496
|
+
Console::WriteLine(e->ToString());
|
497
|
+
return false;
|
498
|
+
}
|
499
|
+
}
|
430
500
|
|
431
|
-
|
432
|
-
|
501
|
+
__declspec ( dllexport ) bool RA_DataItemExists(const HWND windowHandle, const int whichItemIndex, const int whichColumnIndex) {
|
502
|
+
try {
|
503
|
+
auto tableControl = gcnew AutomatedTable(windowHandle);
|
504
|
+
return tableControl->Exists(whichItemIndex, whichColumnIndex);
|
505
|
+
} catch(Exception^ e) {
|
506
|
+
Console::WriteLine(e->ToString());
|
507
|
+
return false;
|
508
|
+
}
|
509
|
+
}
|
510
|
+
|
511
|
+
__declspec ( dllexport ) void RA_CellValueAt(const HWND windowHandle, const int row, const int column, char *foundValue, const int foundValueLength) {
|
512
|
+
try {
|
513
|
+
auto tableControl = gcnew AutomatedTable(windowHandle);
|
514
|
+
auto rowValue = tableControl->ValueAt(row, column);
|
515
|
+
StringHelper::CopyToUnmanagedString(rowValue, foundValue, foundValueLength);
|
516
|
+
} catch(Exception^ e) {
|
517
|
+
Console::WriteLine(e->ToString());
|
518
|
+
}
|
519
|
+
}
|
433
520
|
|
434
|
-
|
521
|
+
__declspec ( dllexport ) void RA_SelectDataItem(const HWND windowHandle, const int dataItemIndex) {
|
522
|
+
try {
|
523
|
+
auto tableControl = gcnew AutomatedTable(windowHandle);
|
524
|
+
tableControl->Select(dataItemIndex);
|
525
|
+
} catch(Exception^ e) {
|
526
|
+
Console::WriteLine(e->ToString());
|
527
|
+
}
|
528
|
+
}
|
435
529
|
|
436
|
-
|
437
|
-
|
438
|
-
|
530
|
+
__declspec ( dllexport ) void RA_ExpandItemByValue(const HWND windowHandle, const char* whichItem) {
|
531
|
+
try {
|
532
|
+
auto expandCollapseHelper = gcnew ExpandCollapseHelper();
|
533
|
+
expandCollapseHelper->ExpandByValue(windowHandle, whichItem);
|
534
|
+
} catch(Exception^ e) {
|
535
|
+
Console::WriteLine(e->ToString());
|
536
|
+
}
|
439
537
|
}
|
440
538
|
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
539
|
+
__declspec ( dllexport ) void RA_ExpandItemByIndex(const HWND windowHandle, const int whichItemIndex) {
|
540
|
+
try {
|
541
|
+
auto expandCollapseHelper = gcnew ExpandCollapseHelper();
|
542
|
+
expandCollapseHelper->ExpandByIndex(windowHandle, whichItemIndex);
|
543
|
+
} catch(Exception^ e) {
|
544
|
+
Console::WriteLine(e->ToString());
|
545
|
+
}
|
546
|
+
}
|
447
547
|
|
448
|
-
|
548
|
+
__declspec ( dllexport ) void RA_CollapseItemByValue(const HWND windowHandle, const char* whichItem) {
|
549
|
+
try {
|
550
|
+
auto expandCollapseHelper = gcnew ExpandCollapseHelper();
|
551
|
+
expandCollapseHelper->CollapseByValue(windowHandle, whichItem);
|
552
|
+
} catch(Exception^ e) {
|
553
|
+
Console::WriteLine(e->ToString());
|
554
|
+
}
|
555
|
+
}
|
556
|
+
|
557
|
+
__declspec ( dllexport ) void RA_CollapseItemByIndex(const HWND windowHandle, const int whichItemIndex) {
|
558
|
+
try {
|
559
|
+
auto expandCollapseHelper = gcnew ExpandCollapseHelper();
|
560
|
+
expandCollapseHelper->CollapseByIndex(windowHandle, whichItemIndex);
|
561
|
+
} catch(Exception^ e) {
|
562
|
+
Console::WriteLine(e->ToString());
|
563
|
+
}
|
564
|
+
}
|
449
565
|
}
|
450
566
|
|
567
|
+
BOOL MenuItemExists(const HWND windowHandle, std::list<const char*>& menuItems)
|
568
|
+
{
|
569
|
+
auto menuSelector = gcnew MenuItemSelector();
|
570
|
+
return menuSelector->MenuItemExists(windowHandle, menuItems);
|
571
|
+
}
|
572
|
+
|
573
|
+
void SelectMenuItem(const HWND windowHandle, char* errorInfo, const int errorInfoSize, std::list<const char*>& menuItems)
|
574
|
+
{
|
575
|
+
try {
|
576
|
+
auto menuSelector = gcnew MenuItemSelector();
|
577
|
+
menuSelector->SelectMenuPath(windowHandle, menuItems);
|
578
|
+
} catch(Exception^ e) {
|
579
|
+
if( errorInfo ) {
|
580
|
+
StringHelper::CopyToUnmanagedString(e->ToString(), errorInfo, errorInfoSize);
|
581
|
+
}
|
582
|
+
}
|
583
|
+
}
|