rautomation 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/.gitignore +9 -8
  2. data/Gemfile.lock +2 -2
  3. data/History.rdoc +13 -0
  4. data/README.rdoc +3 -2
  5. data/Rakefile +30 -10
  6. data/VERSION +1 -1
  7. data/ext/UiaDll/Release/UiaDll.dll +0 -0
  8. data/ext/UiaDll/UiaDll/AssemblyInfo.cpp +40 -0
  9. data/ext/UiaDll/UiaDll/AutomatedComboBox.cpp +66 -0
  10. data/ext/UiaDll/UiaDll/AutomatedComboBox.h +32 -0
  11. data/ext/UiaDll/UiaDll/AutomatedTable.cpp +50 -0
  12. data/ext/UiaDll/UiaDll/AutomatedTable.h +22 -0
  13. data/ext/UiaDll/UiaDll/AutomationClicker.cpp +50 -0
  14. data/ext/UiaDll/UiaDll/AutomationClicker.h +24 -0
  15. data/ext/UiaDll/UiaDll/ExpandCollapseHelper.cpp +53 -0
  16. data/ext/UiaDll/UiaDll/ExpandCollapseHelper.h +22 -0
  17. data/ext/UiaDll/UiaDll/MenuItemSelector.cpp +75 -0
  18. data/ext/UiaDll/UiaDll/MenuItemSelector.h +22 -0
  19. data/ext/UiaDll/UiaDll/ReadMe.txt +8 -18
  20. data/ext/UiaDll/UiaDll/StringHelper.cpp +9 -0
  21. data/ext/UiaDll/UiaDll/StringHelper.h +7 -0
  22. data/ext/UiaDll/UiaDll/ToggleStateHelper.cpp +33 -0
  23. data/ext/UiaDll/UiaDll/ToggleStateHelper.h +10 -0
  24. data/ext/UiaDll/UiaDll/UiaDll.cpp +458 -325
  25. data/ext/UiaDll/UiaDll/UiaDll.h +13 -0
  26. data/ext/UiaDll/UiaDll/UiaDll.vcxproj +45 -28
  27. data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +66 -7
  28. data/ext/UiaDll/UiaDll/app.ico +0 -0
  29. data/ext/UiaDll/UiaDll/app.rc +0 -0
  30. data/ext/UiaDll/UiaDll/dllmain.cpp +5 -23
  31. data/ext/UiaDll/UiaDll/resource.h +3 -0
  32. data/ext/UiaDll/UiaDll/stdafx.cpp +0 -3
  33. data/ext/UiaDll/UiaDll/stdafx.h +23 -18
  34. data/ext/UiaDll/UiaDll.sln +6 -6
  35. data/ext/WindowsForms/Release/WindowsForms.exe +0 -0
  36. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.Designer.cs +0 -0
  37. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.cs +0 -0
  38. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/AboutBox.resx +0 -0
  39. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.Designer.cs +0 -0
  40. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.cs +0 -0
  41. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/DataEntryForm.resx +0 -0
  42. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.Designer.cs +173 -76
  43. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.cs +76 -77
  44. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/MainFormWindow.resx +3 -0
  45. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.Designer.cs +0 -0
  46. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.cs +0 -0
  47. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/PersonForm.resx +0 -0
  48. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Program.cs +0 -0
  49. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/AssemblyInfo.cs +0 -0
  50. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Resources.Designer.cs +0 -0
  51. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Resources.resx +0 -0
  52. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Settings.Designer.cs +0 -0
  53. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/Properties/Settings.settings +0 -0
  54. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.Designer.cs +0 -0
  55. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.cs +0 -0
  56. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/SimpleElementsForm.resx +0 -0
  57. data/ext/WindowsForms/{src/WindowsForms/WindowsForms → WindowsForms}/WindowsForms.csproj +2 -2
  58. data/ext/WindowsForms/{src/WindowsForms/WindowsForms.sln → WindowsForms.sln} +0 -0
  59. data/lib/rautomation/adapter/ms_uia/constants.rb +1 -0
  60. data/lib/rautomation/adapter/ms_uia/control.rb +11 -0
  61. data/lib/rautomation/adapter/ms_uia/functions.rb +8 -5
  62. data/lib/rautomation/adapter/ms_uia/menu.rb +36 -0
  63. data/lib/rautomation/adapter/ms_uia/select_list.rb +4 -12
  64. data/lib/rautomation/adapter/ms_uia/table.rb +90 -11
  65. data/lib/rautomation/adapter/ms_uia/uia_dll.rb +48 -2
  66. data/lib/rautomation/adapter/ms_uia/window.rb +6 -1
  67. data/lib/rautomation/adapter/ms_uia.rb +1 -0
  68. data/spec/adapter/autoit/mouse_spec.rb +2 -2
  69. data/spec/adapter/ms_uia/functions_spec.rb +39 -0
  70. data/spec/adapter/ms_uia/select_list_spec.rb +26 -13
  71. data/spec/adapter/ms_uia/table_spec.rb +96 -2
  72. data/spec/adapter/ms_uia/window_spec.rb +37 -11
  73. data/spec/adapter/win_32/mouse_spec.rb +2 -2
  74. data/spec/adapter/win_32/window_spec.rb +0 -9
  75. data/spec/spec_helper.rb +3 -3
  76. data/spec/window_spec.rb +17 -6
  77. metadata +48 -40
  78. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.cpp +0 -174
  79. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj +0 -95
  80. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj.filters +0 -42
  81. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj.user +0 -3
  82. data/ext/ListViewExplorer/ListViewExplorer/ReadMe.txt +0 -40
  83. data/ext/ListViewExplorer/ListViewExplorer/stdafx.cpp +0 -8
  84. data/ext/ListViewExplorer/ListViewExplorer/stdafx.h +0 -17
  85. data/ext/ListViewExplorer/ListViewExplorer/table_support.cpp +0 -250
  86. data/ext/ListViewExplorer/ListViewExplorer/table_support.h +0 -2
  87. data/ext/ListViewExplorer/ListViewExplorer/targetver.h +0 -8
  88. data/ext/ListViewExplorer/ListViewExplorer.sln +0 -20
  89. data/ext/ListViewExplorer/ListViewExplorer.suo +0 -0
  90. data/ext/UiaDll/UiaDll.suo +0 -0
  91. data/ext/WindowsForms/bin/WindowsForms.exe +0 -0
  92. 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
- extern "C"
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
- VariantInit(&varProperty) ;
16
- varProperty.vt = VT_BSTR ;
17
- varProperty.bstrVal = _bstr_t(pszAutomationId) ;
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()->CreatePropertyCondition(UIA_AutomationIdPropertyId, varProperty, &pCondition) ;
23
+ HRESULT hr = getGlobalIUIAutomation()->GetRootElement(&pRootElement) ;
20
24
  if (SUCCEEDED(hr)) {
21
- IUIAutomationElement *pFound ;
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 = pRootElement->FindFirst(TreeScope_Children, pCondition, &pFound) ;
32
+ hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_AutomationIdPropertyId, varProperty, &pCondition) ;
24
33
  if (SUCCEEDED(hr)) {
25
- return pFound ;
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
- VariantInit(&varProperty);
43
- varProperty.vt = VT_I4;
44
- varProperty.intVal = (processId);
45
+ //This doesn't work
46
+ __declspec( dllexport ) int RA_FindWindowByPID(int processId, IUIAutomationElement *pElement) {
47
+ IUIAutomationElement *pRootElement;
45
48
 
46
- hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_ProcessIdPropertyId, varProperty, &pCondition);
49
+ HRESULT hr = getGlobalIUIAutomation()->GetRootElement(&pRootElement);
47
50
  if (SUCCEEDED(hr)) {
51
+ IUIAutomationCondition *pCondition;
52
+ VARIANT varProperty;
48
53
 
49
- hr = pRootElement->FindFirst(TreeScope_Children, pCondition, &pElement);
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
- return 1;
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
- extern "C"
59
- __declspec( dllexport ) BOOL RA_IsOffscreen(IUIAutomationElement *pElement) {
60
- BOOL isOffscreen ;
61
- pElement->get_CurrentIsOffscreen(&isOffscreen) ;
70
+ __declspec( dllexport ) BOOL RA_IsOffscreen(IUIAutomationElement *pElement) {
71
+ BOOL isOffscreen ;
72
+ pElement->get_CurrentIsOffscreen(&isOffscreen) ;
62
73
 
63
- return isOffscreen ;
64
- }
74
+ return isOffscreen ;
75
+ }
65
76
 
66
- extern "C"
67
- __declspec ( dllexport ) IUIAutomationElement *RA_ElementFromHandle(HWND hwnd) {
68
- IUIAutomationElement *pElement ;
77
+ __declspec ( dllexport ) IUIAutomationElement *RA_ElementFromHandle(HWND hwnd) {
78
+ IUIAutomationElement *pElement ;
69
79
 
70
- HRESULT hr = getGlobalIUIAutomation()->ElementFromHandle(hwnd, &pElement) ;
71
- if (SUCCEEDED(hr))
72
- return pElement ;
73
- else {
74
- printf("RA_ElementFromHandle: Cannot find element from handle 0x%x. HRESULT was 0x%x\r\n", hwnd, hr) ;
75
- return NULL ;
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
- extern "C"
80
- __declspec ( dllexport ) IUIAutomationElement *RA_GetFocusedElement() {
81
- IUIAutomationElement *pelement;
82
-
83
- HRESULT hr = getGlobalIUIAutomation()->GetFocusedElement(&pelement);
84
-
85
- if (SUCCEEDED(hr))
86
- return pelement;
87
- else {
88
- printf("RA_GetFocusedElement: Cannot find element from focus. HRESULT was 0x%x\r\n", hr) ;
89
- return false ;
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
- extern "C"
94
- __declspec ( dllexport ) IUIAutomationElement *RA_ElementFromPoint(int xCoord, int yCoord) {
95
- IUIAutomationElement *pElement ;
96
- POINT point;
102
+ __declspec ( dllexport ) IUIAutomationElement *RA_ElementFromPoint(int xCoord, int yCoord) {
103
+ IUIAutomationElement *pElement ;
104
+ POINT point;
97
105
 
98
- point.x = xCoord;
99
- point.y = yCoord;
106
+ point.x = xCoord;
107
+ point.y = yCoord;
100
108
 
101
- HRESULT hr = getGlobalIUIAutomation()->ElementFromPoint(point, &pElement) ;
102
- if (SUCCEEDED(hr))
103
- return pElement ;
104
- else {
105
- printf("RA_ElementFromPoint: Cannot find element from point %d , %d. HRESULT was 0x%x\r\n", xCoord, yCoord, hr) ;
106
- return NULL ;
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
- extern "C" __declspec ( dllexport ) IUIAutomationElement *RA_FindChildById(IUIAutomationElement *pElement, char *automationId) {
111
- IUIAutomationCondition *pCondition ;
112
- VARIANT varProperty ;
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
- HRESULT hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_AutomationIdPropertyId, varProperty, &pCondition) ;
119
- if (SUCCEEDED(hr)) {
120
- IUIAutomationElement *pFound ;
122
+ VariantInit(&varProperty) ;
123
+ varProperty.vt = VT_BSTR ;
124
+ varProperty.bstrVal = _bstr_t(automationId) ;
121
125
 
122
- hr = pElement->FindFirst(TreeScope_Descendants, pCondition, &pFound) ;
126
+ HRESULT hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_AutomationIdPropertyId, varProperty, &pCondition) ;
123
127
  if (SUCCEEDED(hr)) {
124
- if (pFound == NULL)
125
- printf("RA_FindChildById: Element with automation id %s was not found\r\n", automationId) ;
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
- return pFound ;
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: FindFirst for children looking for %s failed. hr = 0x%x\r\n", automationId, hr) ;
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
- extern "C" __declspec ( dllexport ) IUIAutomationElement *RA_FindChildByName(IUIAutomationElement *pElement, char *elementName) {
139
- IUIAutomationCondition *pCondition ;
140
- VARIANT varProperty ;
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
- HRESULT hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_NamePropertyId, varProperty, &pCondition) ;
147
- if (SUCCEEDED(hr)) {
148
- IUIAutomationElement *pFound ;
150
+ VariantInit(&varProperty) ;
151
+ varProperty.vt = VT_BSTR ;
152
+ varProperty.bstrVal = _bstr_t(elementName) ;
149
153
 
150
- hr = pElement->FindFirst(TreeScope_Descendants, pCondition, &pFound) ;
154
+ HRESULT hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_NamePropertyId, varProperty, &pCondition) ;
151
155
  if (SUCCEEDED(hr)) {
152
- if (pFound == NULL)
153
- printf("RA_FindChildByName: Element with automation name %s was not found\r\n", elementName) ;
154
- //printf("RA_FindChildByName: success with value %s\r\n", elementName) ;
155
- return pFound ;
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: FindFirst for children looking for %s failed. hr = 0x%x\r\n", elementName, hr) ;
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
- extern "C" __declspec ( dllexport ) HWND RA_CurrentNativeWindowHandle(IUIAutomationElement *pElement) {
167
- UIA_HWND uia_hwnd ;
174
+ __declspec ( dllexport ) HWND RA_CurrentNativeWindowHandle(IUIAutomationElement *pElement) {
175
+ UIA_HWND uia_hwnd ;
168
176
 
169
- if (pElement == NULL) {
170
- printf("RA_CurrentNativeWindowHandle: Cannot operate on NULL element\r\n") ;
171
- return (HWND)0 ;
172
- }
177
+ if (pElement == NULL) {
178
+ printf("RA_CurrentNativeWindowHandle: Cannot operate on NULL element\r\n") ;
179
+ return (HWND)0 ;
180
+ }
173
181
 
174
- pElement->get_CurrentNativeWindowHandle(&uia_hwnd) ;
175
- return (HWND)uia_hwnd ;
176
- }
182
+ pElement->get_CurrentNativeWindowHandle(&uia_hwnd) ;
183
+ return (HWND)uia_hwnd ;
184
+ }
177
185
 
178
- extern "C" __declspec ( dllexport ) int RA_GetCurrentProcessId(IUIAutomationElement *pElement) {
179
- HRESULT hr;
180
- int process_id;
186
+ __declspec ( dllexport ) int RA_GetCurrentProcessId(IUIAutomationElement *pElement) {
187
+ HRESULT hr;
188
+ int process_id;
181
189
 
182
- hr = pElement->get_CurrentProcessId(&process_id);
190
+ hr = pElement->get_CurrentProcessId(&process_id);
183
191
 
184
- if (SUCCEEDED(hr)){
185
- return process_id;
186
- }
187
- else {
188
- printf("RA_GetCurrentProcessId: get_CurrentProcessId returned 0x%x\r\n", hr) ;
189
- return 0 ;
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
- extern "C" __declspec ( dllexport ) BOOL RA_SetFocus(IUIAutomationElement *pElement) {
194
- HRESULT hr = pElement->SetFocus() ;
195
- if (hr != S_OK)
196
- printf("RA_SetFocus: SetFocus on element returned 0x%x\r\n", hr) ;
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
- return SUCCEEDED(hr) ;
199
- }
206
+ return SUCCEEDED(hr) ;
207
+ }
200
208
 
201
- extern "C" __declspec ( dllexport ) int RA_GetCurrentControlType(IUIAutomationElement *pElement) {
202
- CONTROLTYPEID control_type ;
209
+ __declspec ( dllexport ) int RA_GetCurrentControlType(IUIAutomationElement *pElement) {
210
+ CONTROLTYPEID control_type ;
203
211
 
204
- HRESULT hr = pElement->get_CurrentControlType(&control_type) ;
205
- if (SUCCEEDED(hr))
206
- return control_type ;
207
- else {
208
- printf("RA_GetCurrentControlType: CurrentControlType returned 0x%x\r\n", hr) ;
209
- return 0 ;
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
- extern "C" __declspec ( dllexport ) long RA_ClickMouse() {
214
- mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
215
- mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
216
- return 0;
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
- extern "C" __declspec ( dllexport ) long RA_MoveMouse(int x, int y) {
220
- return SetCursorPos(x,y);
221
- }
227
+ __declspec ( dllexport ) long RA_MoveMouse(int x, int y) {
228
+ return SetCursorPos(x,y);
229
+ }
222
230
 
223
- extern "C" __declspec ( dllexport ) long RA_GetDesktopHandle() {
224
- return (long)GetDesktopWindow();
225
- }
231
+ __declspec ( dllexport ) long RA_GetDesktopHandle() {
232
+ return (long)GetDesktopWindow();
233
+ }
226
234
 
227
- extern "C" __declspec ( dllexport ) int RA_CurrentBoundingRectangle(IUIAutomationElement *pElement, long *rectangle) {
228
- RECT boundary;
235
+ __declspec ( dllexport ) int RA_CurrentBoundingRectangle(IUIAutomationElement *pElement, long *rectangle) {
236
+ RECT boundary;
229
237
 
230
- HRESULT hr = pElement->get_CurrentBoundingRectangle(&boundary) ;
231
- if (SUCCEEDED(hr)) {
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
- return 1;
239
- }
240
- else {
241
- printf("RA_CurrentBoundingRectangle: get_CurrentBoundingRectangle failed 0x%x\r\n", hr) ;
242
- return 0 ;
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
- extern "C" __declspec ( dllexport ) int RA_CurrentIsOffscreen(IUIAutomationElement *pElement, int *visible) {
247
- BOOL offscreen;
254
+ __declspec ( dllexport ) int RA_CurrentIsOffscreen(IUIAutomationElement *pElement, int *visible) {
255
+ BOOL offscreen;
248
256
 
249
- HRESULT hr = pElement->get_CurrentIsOffscreen(&offscreen) ;
250
- if (SUCCEEDED(hr)) {
251
- if(offscreen){
252
- *visible = 1;
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
- *visible = 0;
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
- extern "C" __declspec ( dllexport ) int RA_FindChildren(IUIAutomationElement *pElement, IUIAutomationElement *pChildren[]) {
267
- IUIAutomationCondition *pTrueCondition ;
268
- IUIAutomationElementArray *pElementArray ;
269
- int element_count ;
274
+ __declspec ( dllexport ) int RA_FindChildren(IUIAutomationElement *pElement, IUIAutomationElement *pChildren[]) {
275
+ IUIAutomationCondition *pTrueCondition ;
276
+ IUIAutomationElementArray *pElementArray ;
277
+ int element_count ;
270
278
 
271
- HRESULT hr = getGlobalIUIAutomation()->CreateTrueCondition(&pTrueCondition) ;
272
- if (FAILED(hr)) {
273
- printf("RA_FindChildren: Could not create true condition 0x%x\r\n", hr) ;
274
- return 0 ;
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
- hr = pElement->FindAll(TreeScope_Children, pTrueCondition, &pElementArray) ;
278
- if (FAILED(hr)) {
279
- printf("RA_FindChildren: FindAll failed 0x%x\r\n", hr) ;
280
- return 0 ;
281
- }
282
-
283
- hr = pElementArray->get_Length(&element_count) ;
284
- if (FAILED(hr)) {
285
- printf("RA_FindChildren: get_length failed 0x%x\r\n", hr) ;
286
- return 0 ;
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
- if (pChildren != NULL) {
290
- // given some memory get the details
291
- for (int index = 0; index < element_count; index++) {
292
- IUIAutomationElement *pElement ;
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
- hr = pElementArray->GetElement(index, &pElement) ;
295
- if (FAILED(hr)) {
296
- printf("RA_FindChildren: GetElement failed 0x%x\r\n", hr) ;
323
+ char *pszName = _com_util::ConvertBSTRToString(bstrName) ;
324
+
325
+ if (pszName != NULL){
326
+ if (pName == NULL) {
327
+ return strlen(pszName) ;
297
328
  } else {
298
- pChildren[index] = pElement ;
329
+ strcpy(pName, pszName) ;
330
+ return strlen(pszName) ;
299
331
  }
332
+ } else {
333
+ return -1;
300
334
  }
301
335
  }
302
336
 
303
- return element_count ;
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
- extern "C" __declspec ( dllexport ) int RA_GetName(IUIAutomationElement *pElement, char *pName) {
307
- BSTR bstrName ;
308
- HRESULT hr = pElement->get_CurrentName(&bstrName) ;
346
+ char *pszClass = _com_util::ConvertBSTRToString(bstrClass) ;
309
347
 
310
- if (FAILED(hr)) {
311
- printf("RA_GetName: get_CurrentName failed 0x%x\r\n", hr) ;
312
- return -1 ;
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
- char *pszName = _com_util::ConvertBSTRToString(bstrName) ;
360
+ __declspec ( dllexport ) BOOL RA_GetIsSet(IUIAutomationElement *pElement) {
361
+ return ToggleStateHelper().IsSet(pElement);
362
+ }
316
363
 
317
- if (pszName != NULL){
318
- if (pName == NULL) {
319
- return strlen(pszName) ;
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
- strcpy(pName, pszName) ;
322
- return strlen(pszName) ;
379
+ return RetVal ;
323
380
  }
324
- } else {
325
- return -1;
326
381
  }
327
- }
328
382
 
329
- extern "C" __declspec ( dllexport ) int RA_GetClassName(IUIAutomationElement *pElement, char *pClass) {
330
- BSTR bstrClass ;
331
- HRESULT hr = pElement->get_CurrentClassName(&bstrClass) ;
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
- if (FAILED(hr)) {
334
- printf("RA_GetName: get_CurrentClassName failed 0x%x\r\n", hr) ;
335
- return -1 ;
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 *pszClass = _com_util::ConvertBSTRToString(bstrClass) ;
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
- if (pszClass != NULL){
341
- if (pClass == NULL) {
342
- return strlen(pszClass) ;
343
- } else {
344
- strcpy(pClass, pszClass) ;
345
- return strlen(pszClass) ;
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
- extern "C" __declspec ( dllexport ) BOOL RA_GetIsSet(IUIAutomationElement *pElement) {
353
- IToggleProvider *pTogglePattern ;
354
- HRESULT hr = pElement->GetCurrentPattern(UIA_TogglePatternId, (IUnknown**)&pTogglePattern) ;
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
- ToggleState RetVal ;
362
- hr = pTogglePattern->get_ToggleState(&RetVal) ;
363
- if (FAILED(hr)) {
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
- extern "C" __declspec ( dllexport ) BOOL RA_GetIsSelected(IUIAutomationElement *pElement) {
372
- ISelectionItemProvider *pSelectionPattern ;
373
- HRESULT hr = pElement->GetCurrentPattern(UIA_SelectionItemPatternId, (IUnknown**)&pSelectionPattern) ;
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
- BOOL RetVal ;
381
- hr = pSelectionPattern->get_IsSelected(&RetVal) ;
382
- if (FAILED(hr)) {
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
- extern "C" __declspec ( dllexport ) int RA_Select(IUIAutomationElement *pElement) {
391
- ISelectionItemProvider *pSelectionPattern ;
392
- HRESULT hr = pElement->GetCurrentPattern(UIA_SelectionItemPatternId, (IUnknown**)&pSelectionPattern) ;
393
- if (FAILED(hr)) {
394
- printf("RA_GetIsSelected: getCurrentPattern failed 0x%x\r\n") ;
395
- return FALSE ;
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
- hr = pSelectionPattern->Select();
399
- if (FAILED(hr)) {
400
- printf("RA_Select: Select failed 0x%x\r\n", hr) ;
401
- return 0 ;
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
- return 1;
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
- extern "C" __declspec ( dllexport ) int RA_Set_Value(IUIAutomationElement *pElement, char *pValue) {
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
- BSTR unicodestr;
417
-
418
- int lenA = lstrlenA(pValue);
419
- int lenW = ::MultiByteToWideChar(CP_ACP, 0, pValue, lenA, 0, 0);
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
- if (lenW > 0)
422
- {
423
- unicodestr = ::SysAllocStringLen(0, lenW);
424
- ::MultiByteToWideChar(CP_ACP, 0, pValue, lenA, unicodestr, lenW);
425
- }
426
- else
427
- {
428
- printf("RA_Set_Value: conversion to unicode string failed\r\n");
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
- hr = pValuePattern->SetValue(unicodestr);
432
- ::SysFreeString(unicodestr);
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
- if (FAILED(hr)) {
437
- printf("RA_SetValue: SetValue failed 0x%x\r\n", hr) ;
438
- return 0 ;
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
- //It'd be great if this worked
442
- /*hr = UiaRaiseAutomationEvent((IRawElementProviderSimple*) pElement, UIA_Selection_InvalidatedEventId);
443
- if (FAILED(hr)) {
444
- printf("RA_SetValue: UiaRaiseAutomationEvent failed 0x%x\r\n", hr) ;
445
- return 0 ;
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
- return 1;
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
+ }