rautomation 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/History.rdoc +5 -0
- data/VERSION +1 -1
- data/ext/UiaDll/Release/UiaDll.dll +0 -0
- data/ext/UiaDll/UiaDll/AutomatedSelectList.cpp +10 -0
- data/ext/UiaDll/UiaDll/AutomatedSelectList.h +1 -0
- data/ext/UiaDll/UiaDll/AutomationClicker.cpp +9 -13
- data/ext/UiaDll/UiaDll/AutomationClicker.h +5 -4
- data/ext/UiaDll/UiaDll/AutomationControl.h +8 -0
- data/ext/UiaDll/UiaDll/ControlMethods.cpp +4 -4
- data/ext/UiaDll/UiaDll/ExpandCollapseHelper.cpp +12 -12
- data/ext/UiaDll/UiaDll/ExpandCollapseHelper.h +9 -6
- data/ext/UiaDll/UiaDll/SelectListMethods.cpp +9 -4
- data/ext/UiaDll/UiaDll/TableMethods.cpp +16 -16
- data/ext/UiaDll/UiaDll/UiaDll.cpp +279 -259
- data/lib/rautomation/adapter/ms_uia/button.rb +1 -6
- data/lib/rautomation/adapter/ms_uia/button_helper.rb +0 -6
- data/lib/rautomation/adapter/ms_uia/control.rb +9 -12
- data/lib/rautomation/adapter/ms_uia/functions.rb +0 -16
- data/lib/rautomation/adapter/ms_uia/label.rb +1 -5
- data/lib/rautomation/adapter/ms_uia/list_box.rb +3 -26
- data/lib/rautomation/adapter/ms_uia/select_list.rb +6 -38
- data/lib/rautomation/adapter/ms_uia/table.rb +13 -20
- data/lib/rautomation/adapter/ms_uia/text_field.rb +2 -16
- data/lib/rautomation/adapter/ms_uia/uia_dll.rb +52 -33
- data/lib/rautomation/adapter/ms_uia/value_control.rb +2 -2
- data/spec/adapter/ms_uia/window_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d60457345affb72ade2ec56f93991a918cb39cd8
|
4
|
+
data.tar.gz: d136c890f577984d093d2831aa6f19559a54a271
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 562a850a9175f49764a49927a6dd86666afc248065a1c9cee6e4ba739702f613777f71fbb354074b071af979b60399d4d59abe61ed3ce283bc4e188f43b3d7ca
|
7
|
+
data.tar.gz: a26f7646d7b025c58584906fc9808bd0eeca4321f3b3caf53f2a8fd4ab8e02b2fc50cb8b69976e6dbfb6e0438226aeaac30ba61ef584a7bfc9fa699b79490484
|
data/Gemfile.lock
CHANGED
data/History.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.1
|
Binary file
|
@@ -17,6 +17,16 @@ array<String^>^ AutomatedSelectList::Selection::get() {
|
|
17
17
|
return selections;
|
18
18
|
}
|
19
19
|
|
20
|
+
int AutomatedSelectList::GetOptions(const char* options[]) {
|
21
|
+
auto selectionItems = SelectionItems;
|
22
|
+
|
23
|
+
if( NULL != options ) {
|
24
|
+
StringHelper::CopyNames(selectionItems, options);
|
25
|
+
}
|
26
|
+
|
27
|
+
return selectionItems->Count;
|
28
|
+
}
|
29
|
+
|
20
30
|
bool AutomatedSelectList::SelectByIndex(const int whichItem)
|
21
31
|
{
|
22
32
|
try {
|
@@ -12,6 +12,7 @@ public:
|
|
12
12
|
bool SelectByIndex(const int whichItem);
|
13
13
|
bool SelectByValue(const char* whichItem);
|
14
14
|
bool GetValueByIndex(const int whichItem, char* comboValue, const int comboValueSize);
|
15
|
+
int GetOptions(const char* options[]);
|
15
16
|
|
16
17
|
property array<String^>^ Selection {
|
17
18
|
array<String^>^ get();
|
@@ -1,10 +1,6 @@
|
|
1
1
|
#include "StdAfx.h"
|
2
2
|
#include "AutomationClicker.h"
|
3
3
|
|
4
|
-
AutomationClicker::AutomationClicker(const HWND windowHandle) {
|
5
|
-
_automationElement = AutomationElement::FromHandle(IntPtr(windowHandle));
|
6
|
-
}
|
7
|
-
|
8
4
|
void AutomationClicker::Click() {
|
9
5
|
if( CanInvoke() ) {
|
10
6
|
return Invoke();
|
@@ -18,33 +14,33 @@ void AutomationClicker::Click() {
|
|
18
14
|
}
|
19
15
|
|
20
16
|
void AutomationClicker::MouseClick() {
|
21
|
-
|
22
|
-
auto clickablePoint =
|
23
|
-
Cursor::Position = Point((int)clickablePoint.X, (int)clickablePoint.Y);
|
17
|
+
_control->SetFocus();
|
18
|
+
auto clickablePoint = _control->GetClickablePoint();
|
19
|
+
Cursor::Position = System::Drawing::Point((int)clickablePoint.X, (int)clickablePoint.Y);
|
24
20
|
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
25
21
|
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
26
22
|
}
|
27
23
|
|
28
24
|
bool AutomationClicker::CanInvoke() {
|
29
|
-
return (bool)(
|
25
|
+
return (bool)(_control->GetCurrentPropertyValue(AutomationElement::IsInvokePatternAvailableProperty));
|
30
26
|
}
|
31
27
|
|
32
28
|
void AutomationClicker::Invoke() {
|
33
|
-
dynamic_cast<InvokePattern^>(
|
29
|
+
dynamic_cast<InvokePattern^>(_control->GetCurrentPattern(InvokePattern::Pattern))->Invoke();
|
34
30
|
}
|
35
31
|
|
36
32
|
bool AutomationClicker::CanToggle() {
|
37
|
-
return (bool)(
|
33
|
+
return (bool)(_control->GetCurrentPropertyValue(AutomationElement::IsTogglePatternAvailableProperty));
|
38
34
|
}
|
39
35
|
|
40
36
|
void AutomationClicker::Toggle() {
|
41
|
-
dynamic_cast<TogglePattern^>(
|
37
|
+
dynamic_cast<TogglePattern^>(_control->GetCurrentPattern(TogglePattern::Pattern))->Toggle();
|
42
38
|
}
|
43
39
|
|
44
40
|
bool AutomationClicker::CanSelect() {
|
45
|
-
return (bool)(
|
41
|
+
return (bool)(_control->GetCurrentPropertyValue(AutomationElement::IsSelectionItemPatternAvailableProperty));
|
46
42
|
}
|
47
43
|
|
48
44
|
void AutomationClicker::Select() {
|
49
|
-
dynamic_cast<SelectionItemPattern^>(
|
45
|
+
dynamic_cast<SelectionItemPattern^>(_control->GetCurrentPattern(SelectionItemPattern::Pattern))->Select();
|
50
46
|
}
|
@@ -3,16 +3,17 @@ using namespace System::Windows::Automation;
|
|
3
3
|
using namespace System::Windows::Forms;
|
4
4
|
using namespace System::Drawing;
|
5
5
|
|
6
|
-
|
6
|
+
#include "AutomationControl.h"
|
7
|
+
|
8
|
+
ref class AutomationClicker : AutomationControl
|
7
9
|
{
|
8
10
|
public:
|
9
|
-
|
11
|
+
AutomationClicker(const HWND windowHandle) : AutomationControl(windowHandle) {}
|
12
|
+
AutomationClicker(const FindInformation& findInformation) : AutomationControl(findInformation) {}
|
10
13
|
void Click();
|
11
14
|
void MouseClick();
|
12
15
|
|
13
16
|
private:
|
14
|
-
AutomationElement^ _automationElement;
|
15
|
-
|
16
17
|
bool CanInvoke();
|
17
18
|
void Invoke();
|
18
19
|
|
@@ -22,6 +22,14 @@ public:
|
|
22
22
|
String^ get() { return _control->Current.ClassName; }
|
23
23
|
}
|
24
24
|
|
25
|
+
property bool IsEnabled {
|
26
|
+
bool get() { return _control->Current.IsEnabled; }
|
27
|
+
}
|
28
|
+
|
29
|
+
property bool IsFocused {
|
30
|
+
bool get() { return _control->Current.HasKeyboardFocus; }
|
31
|
+
}
|
32
|
+
|
25
33
|
property Rect BoundingRectangle {
|
26
34
|
Rect get() { return _control->Current.BoundingRectangle; }
|
27
35
|
}
|
@@ -3,13 +3,13 @@
|
|
3
3
|
#include "StringHelper.h"
|
4
4
|
|
5
5
|
extern "C" {
|
6
|
-
__declspec ( dllexport ) void Control_GetValue(const
|
7
|
-
auto control = gcnew AutomationControl(
|
6
|
+
__declspec ( dllexport ) void Control_GetValue(const FindInformation& findInformation, char* theValue, const int maximumLength) {
|
7
|
+
auto control = gcnew AutomationControl(findInformation);
|
8
8
|
StringHelper::CopyToUnmanagedString(control->Value, theValue, maximumLength);
|
9
9
|
}
|
10
10
|
|
11
|
-
__declspec ( dllexport ) void Control_SetValue(const
|
12
|
-
auto control = gcnew AutomationControl(
|
11
|
+
__declspec ( dllexport ) void Control_SetValue(const FindInformation& findInformation, const char* theValue) {
|
12
|
+
auto control = gcnew AutomationControl(findInformation);
|
13
13
|
control->Value = gcnew String(theValue);
|
14
14
|
}
|
15
15
|
}
|
@@ -2,37 +2,37 @@
|
|
2
2
|
#include "ExpandCollapseHelper.h"
|
3
3
|
|
4
4
|
|
5
|
-
void ExpandCollapseHelper::ExpandByValue(const
|
5
|
+
void ExpandCollapseHelper::ExpandByValue(const FindInformation& findInformation, const char* whichItem)
|
6
6
|
{
|
7
|
-
Expand(ExpandableItem(
|
7
|
+
Expand(ExpandableItem(findInformation, whichItem));
|
8
8
|
}
|
9
9
|
|
10
|
-
void ExpandCollapseHelper::ExpandByIndex(const
|
10
|
+
void ExpandCollapseHelper::ExpandByIndex(const FindInformation& findInformation, const int whichItemIndex)
|
11
11
|
{
|
12
|
-
auto expandableItem = ExpandableItems(
|
12
|
+
auto expandableItem = ExpandableItems(findInformation)[whichItemIndex];
|
13
13
|
Expand(expandableItem);
|
14
14
|
}
|
15
15
|
|
16
|
-
void ExpandCollapseHelper::CollapseByValue(const
|
16
|
+
void ExpandCollapseHelper::CollapseByValue(const FindInformation& findInformation, const char* whichItem)
|
17
17
|
{
|
18
|
-
Collapse(ExpandableItem(
|
18
|
+
Collapse(ExpandableItem(findInformation, whichItem));
|
19
19
|
}
|
20
20
|
|
21
|
-
void ExpandCollapseHelper::CollapseByIndex(const
|
21
|
+
void ExpandCollapseHelper::CollapseByIndex(const FindInformation& findInformation, const int whichItemIndex)
|
22
22
|
{
|
23
|
-
auto expandableItem = ExpandableItems(
|
23
|
+
auto expandableItem = ExpandableItems(findInformation)[whichItemIndex];
|
24
24
|
Collapse(expandableItem);
|
25
25
|
}
|
26
26
|
|
27
|
-
AutomationElementCollection^ ExpandCollapseHelper::ExpandableItems(const
|
27
|
+
AutomationElementCollection^ ExpandCollapseHelper::ExpandableItems(const FindInformation& findInformation)
|
28
28
|
{
|
29
|
-
auto automationElement =
|
29
|
+
auto automationElement = (gcnew AutomationControl(findInformation))->Element;
|
30
30
|
return automationElement->FindAll(System::Windows::Automation::TreeScope::Subtree, IsExpandable);
|
31
31
|
}
|
32
32
|
|
33
|
-
AutomationElement^ ExpandCollapseHelper::ExpandableItem(const
|
33
|
+
AutomationElement^ ExpandCollapseHelper::ExpandableItem(const FindInformation& findInformation, const char* whichItem)
|
34
34
|
{
|
35
|
-
auto automationElement =
|
35
|
+
auto automationElement = (gcnew AutomationControl(findInformation))->Element;
|
36
36
|
auto andTheNameMatches = gcnew PropertyCondition(AutomationElement::NameProperty, gcnew String(whichItem));
|
37
37
|
return automationElement->FindFirst(System::Windows::Automation::TreeScope::Subtree, gcnew AndCondition(IsExpandable, andTheNameMatches));
|
38
38
|
}
|
@@ -1,17 +1,20 @@
|
|
1
1
|
#pragma once
|
2
|
+
|
3
|
+
#include "AutomationControl.h"
|
4
|
+
|
2
5
|
using namespace System::Windows::Automation;
|
3
6
|
|
4
7
|
ref class ExpandCollapseHelper
|
5
8
|
{
|
6
9
|
public:
|
7
|
-
void ExpandByValue(const
|
8
|
-
void ExpandByIndex(const
|
9
|
-
void CollapseByValue(const
|
10
|
-
void CollapseByIndex(const
|
10
|
+
void ExpandByValue(const FindInformation& findInformation, const char* whichItem);
|
11
|
+
void ExpandByIndex(const FindInformation& findInformation, const int whichItemIndex);
|
12
|
+
void CollapseByValue(const FindInformation& findInformation, const char* whichItem);
|
13
|
+
void CollapseByIndex(const FindInformation& findInformation, const int whichItemIndex);
|
11
14
|
|
12
15
|
private:
|
13
|
-
AutomationElementCollection^ ExpandableItems(const
|
14
|
-
AutomationElement^ ExpandableItem(const
|
16
|
+
AutomationElementCollection^ ExpandableItems(const FindInformation& findInformation);
|
17
|
+
AutomationElement^ ExpandableItem(const FindInformation& findInformation, const char* whichItem);
|
15
18
|
void Expand(AutomationElement^ automationElement);
|
16
19
|
void Collapse(AutomationElement^ automationElement);
|
17
20
|
|
@@ -8,8 +8,13 @@ extern "C" {
|
|
8
8
|
return autoSelectList->Count;
|
9
9
|
}
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
__declspec ( dllexport ) int SelectList_Options(const FindInformation& findInformation, const char* options[]) {
|
12
|
+
auto selectList = gcnew AutomatedSelectList(findInformation);
|
13
|
+
return selectList->GetOptions(options);
|
14
|
+
}
|
15
|
+
|
16
|
+
__declspec ( dllexport ) int SelectList_SelectedIndex(const FindInformation& findInformation) {
|
17
|
+
auto autoSelectList = gcnew AutomatedSelectList(findInformation);
|
13
18
|
return autoSelectList->SelectedIndex;
|
14
19
|
}
|
15
20
|
|
@@ -20,8 +25,8 @@ extern "C" {
|
|
20
25
|
StringHelper::CopyToUnmanagedString(firstSelection, selection, selectionLength);
|
21
26
|
}
|
22
27
|
|
23
|
-
__declspec ( dllexport ) bool SelectList_ValueAt(const
|
24
|
-
auto autoSelectList = gcnew AutomatedSelectList(
|
28
|
+
__declspec ( dllexport ) bool SelectList_ValueAt(const FindInformation& findInformation, const int whichItem, char* comboValue, const int comboValueSize) {
|
29
|
+
auto autoSelectList = gcnew AutomatedSelectList(findInformation);
|
25
30
|
return autoSelectList->GetValueByIndex(whichItem, comboValue, comboValueSize);
|
26
31
|
}
|
27
32
|
|
@@ -3,13 +3,13 @@
|
|
3
3
|
|
4
4
|
extern "C" {
|
5
5
|
|
6
|
-
__declspec ( dllexport ) int Table_GetHeaders(const
|
7
|
-
auto tableControl = gcnew AutomatedTable(
|
6
|
+
__declspec ( dllexport ) int Table_GetHeaders(const FindInformation& findInformation, const char* headers[]) {
|
7
|
+
auto tableControl = gcnew AutomatedTable(findInformation);
|
8
8
|
return tableControl->GetHeaders(headers);
|
9
9
|
}
|
10
10
|
|
11
|
-
__declspec ( dllexport ) int Table_GetValues(const
|
12
|
-
auto tableControl = gcnew AutomatedTable(
|
11
|
+
__declspec ( dllexport ) int Table_GetValues(const FindInformation& findInformation, const char* values[]) {
|
12
|
+
auto tableControl = gcnew AutomatedTable(findInformation);
|
13
13
|
return tableControl->GetValues(values);
|
14
14
|
}
|
15
15
|
|
@@ -18,18 +18,18 @@ extern "C" {
|
|
18
18
|
return tableControl->GetValues(values);
|
19
19
|
}
|
20
20
|
|
21
|
-
__declspec ( dllexport ) int Table_RowCount(const
|
21
|
+
__declspec ( dllexport ) int Table_RowCount(const FindInformation& findInformation) {
|
22
22
|
try {
|
23
|
-
auto tableControl = gcnew AutomatedTable(
|
23
|
+
auto tableControl = gcnew AutomatedTable(findInformation);
|
24
24
|
return tableControl->RowCount;
|
25
25
|
} catch(Exception^ e) {
|
26
26
|
Console::WriteLine(e->ToString());
|
27
27
|
}
|
28
28
|
}
|
29
29
|
|
30
|
-
__declspec ( dllexport ) bool Table_CoordinateIsValid(const
|
30
|
+
__declspec ( dllexport ) bool Table_CoordinateIsValid(const FindInformation& findInformation, const int whichItemIndex, const int whichColumnIndex) {
|
31
31
|
try {
|
32
|
-
auto tableControl = gcnew AutomatedTable(
|
32
|
+
auto tableControl = gcnew AutomatedTable(findInformation);
|
33
33
|
return tableControl->Exists(whichItemIndex, whichColumnIndex);
|
34
34
|
} catch(Exception^ e) {
|
35
35
|
Console::WriteLine(e->ToString());
|
@@ -37,9 +37,9 @@ extern "C" {
|
|
37
37
|
}
|
38
38
|
}
|
39
39
|
|
40
|
-
__declspec ( dllexport ) void Table_ValueAt(const
|
40
|
+
__declspec ( dllexport ) void Table_ValueAt(const FindInformation& findInformation, const int row, const int column, char *foundValue, const int foundValueLength) {
|
41
41
|
try {
|
42
|
-
auto tableControl = gcnew AutomatedTable(
|
42
|
+
auto tableControl = gcnew AutomatedTable(findInformation);
|
43
43
|
auto rowValue = tableControl->ValueAt(row, column);
|
44
44
|
StringHelper::CopyToUnmanagedString(rowValue, foundValue, foundValueLength);
|
45
45
|
} catch(Exception^ e) {
|
@@ -47,27 +47,27 @@ extern "C" {
|
|
47
47
|
}
|
48
48
|
}
|
49
49
|
|
50
|
-
__declspec ( dllexport ) void Table_SelectByIndex(const
|
50
|
+
__declspec ( dllexport ) void Table_SelectByIndex(const FindInformation& findInformation, const int dataItemIndex) {
|
51
51
|
try {
|
52
|
-
auto tableControl = gcnew AutomatedTable(
|
52
|
+
auto tableControl = gcnew AutomatedTable(findInformation);
|
53
53
|
tableControl->Select(dataItemIndex);
|
54
54
|
} catch(Exception^ e) {
|
55
55
|
Console::WriteLine(e->ToString());
|
56
56
|
}
|
57
57
|
}
|
58
58
|
|
59
|
-
__declspec ( dllexport ) bool Table_IsSelectedByIndex(const
|
59
|
+
__declspec ( dllexport ) bool Table_IsSelectedByIndex(const FindInformation& findInformation, const int dataItemIndex) {
|
60
60
|
try {
|
61
|
-
auto tableControl = gcnew AutomatedTable(
|
61
|
+
auto tableControl = gcnew AutomatedTable(findInformation);
|
62
62
|
return tableControl->IsSelected(dataItemIndex);
|
63
63
|
} catch(Exception^ e) {
|
64
64
|
Console::WriteLine(e->ToString());
|
65
65
|
}
|
66
66
|
}
|
67
67
|
|
68
|
-
__declspec ( dllexport ) void Table_SelectByValue(const
|
68
|
+
__declspec ( dllexport ) void Table_SelectByValue(const FindInformation& findInformation, const char* dataItemValue) {
|
69
69
|
try {
|
70
|
-
auto tableControl = gcnew AutomatedTable(
|
70
|
+
auto tableControl = gcnew AutomatedTable(findInformation);
|
71
71
|
tableControl->Select(dataItemValue);
|
72
72
|
} catch(Exception^ e) {
|
73
73
|
Console::WriteLine(e->ToString());
|
@@ -14,12 +14,12 @@ IUIAutomation* getGlobalIUIAutomation() ;
|
|
14
14
|
|
15
15
|
extern "C" {
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
__declspec ( dllexport ) bool ElementExists(const FindInformation& findInformation) {
|
18
|
+
auto automationElement = gcnew AutomationControl(findInformation);
|
19
|
+
return automationElement->Exists;
|
20
|
+
}
|
21
21
|
|
22
|
-
|
22
|
+
__declspec ( dllexport ) int BoundingRectangle(const FindInformation& findInformation, long *rectangle) {
|
23
23
|
try {
|
24
24
|
auto automationElement = gcnew AutomationControl(findInformation);
|
25
25
|
auto boundary = automationElement->BoundingRectangle;
|
@@ -34,9 +34,9 @@ extern "C" {
|
|
34
34
|
Console::WriteLine("BoundingRectangle: {0}", e->Message);
|
35
35
|
return 0;
|
36
36
|
}
|
37
|
-
|
37
|
+
}
|
38
38
|
|
39
|
-
|
39
|
+
__declspec ( dllexport ) int ControlType(const FindInformation& findInformation) {
|
40
40
|
try {
|
41
41
|
auto automationElement = gcnew AutomationControl(findInformation);
|
42
42
|
return automationElement->ControlType->Id;
|
@@ -44,7 +44,7 @@ extern "C" {
|
|
44
44
|
Console::WriteLine("ControlType: {0}", e->Message);
|
45
45
|
return 0;
|
46
46
|
}
|
47
|
-
|
47
|
+
}
|
48
48
|
|
49
49
|
__declspec ( dllexport ) int ProcessId(const FindInformation& findInformation) {
|
50
50
|
try {
|
@@ -57,21 +57,49 @@ extern "C" {
|
|
57
57
|
}
|
58
58
|
|
59
59
|
__declspec ( dllexport ) void Name(const FindInformation& findInformation, char* name, const int nameLength) {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
try {
|
61
|
+
auto control = gcnew AutomationControl(findInformation);
|
62
|
+
StringHelper::CopyToUnmanagedString(control->Name, name, nameLength);
|
63
|
+
} catch(Exception^ e) {
|
64
64
|
Console::WriteLine("Name: {0}", e->Message);
|
65
|
-
|
65
|
+
}
|
66
66
|
}
|
67
67
|
|
68
68
|
__declspec ( dllexport ) void ClassName(const FindInformation& findInformation, char* className, const int classNameLength) {
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
try {
|
70
|
+
auto control = gcnew AutomationControl(findInformation);
|
71
|
+
StringHelper::CopyToUnmanagedString(control->ClassName, className, classNameLength);
|
72
|
+
} catch(Exception^ e) {
|
73
73
|
Console::WriteLine("ClassName: {0}", e->Message);
|
74
|
-
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
__declspec ( dllexport ) bool IsEnabled(const FindInformation& findInformation) {
|
78
|
+
try {
|
79
|
+
return (gcnew AutomationControl(findInformation))->IsEnabled;
|
80
|
+
} catch(Exception^ e) {
|
81
|
+
Console::WriteLine("IsEnabled: {0}", e->Message);
|
82
|
+
return false;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
__declspec ( dllexport ) bool IsFocused(const FindInformation& findInformation) {
|
87
|
+
try {
|
88
|
+
return (gcnew AutomationControl(findInformation))->IsFocused;
|
89
|
+
} catch(Exception^ e) {
|
90
|
+
Console::WriteLine("IsFocused: {0}", e->Message);
|
91
|
+
return false;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
__declspec ( dllexport ) bool SetControlFocus(const FindInformation& findInformation) {
|
96
|
+
try {
|
97
|
+
(gcnew AutomationControl(findInformation))->Element->SetFocus();
|
98
|
+
return true;
|
99
|
+
} catch(Exception^ e) {
|
100
|
+
Console::WriteLine("IsFocused: {0}", e->Message);
|
101
|
+
return false;
|
102
|
+
}
|
75
103
|
}
|
76
104
|
|
77
105
|
__declspec ( dllexport ) int GetClassNames(const FindInformation& findInformation, const char* classNames[]) {
|
@@ -87,173 +115,165 @@ extern "C" {
|
|
87
115
|
return allChildren->Count;
|
88
116
|
}
|
89
117
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
try {
|
250
|
-
auto control = gcnew AutomationControl(windowHandle);
|
251
|
-
StringHelper::CopyToUnmanagedString(control->Name, windowName, windowNameLength);
|
252
|
-
return true;
|
253
|
-
} catch(Exception^ e) {
|
254
|
-
return false;
|
255
|
-
}
|
256
|
-
}
|
118
|
+
__declspec ( dllexport ) IUIAutomationElement *RA_ElementFromHandle(HWND hwnd) {
|
119
|
+
IUIAutomationElement *pElement ;
|
120
|
+
|
121
|
+
HRESULT hr = getGlobalIUIAutomation()->ElementFromHandle(hwnd, &pElement) ;
|
122
|
+
if (SUCCEEDED(hr))
|
123
|
+
return pElement ;
|
124
|
+
else {
|
125
|
+
printf("RA_ElementFromHandle: Cannot find element from handle 0x%x. HRESULT was 0x%x\r\n", hwnd, hr) ;
|
126
|
+
return NULL ;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
__declspec ( dllexport ) IUIAutomationElement *RA_ElementFromPoint(int xCoord, int yCoord) {
|
131
|
+
IUIAutomationElement *pElement ;
|
132
|
+
POINT point;
|
133
|
+
|
134
|
+
point.x = xCoord;
|
135
|
+
point.y = yCoord;
|
136
|
+
|
137
|
+
HRESULT hr = getGlobalIUIAutomation()->ElementFromPoint(point, &pElement) ;
|
138
|
+
if (SUCCEEDED(hr))
|
139
|
+
return pElement ;
|
140
|
+
else {
|
141
|
+
printf("RA_ElementFromPoint: Cannot find element from point %d , %d. HRESULT was 0x%x\r\n", xCoord, yCoord, hr) ;
|
142
|
+
return NULL ;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
__declspec ( dllexport ) IUIAutomationElement *RA_FindChildById(IUIAutomationElement *pElement, char *automationId) {
|
147
|
+
IUIAutomationCondition *pCondition ;
|
148
|
+
VARIANT varProperty ;
|
149
|
+
|
150
|
+
VariantInit(&varProperty) ;
|
151
|
+
varProperty.vt = VT_BSTR ;
|
152
|
+
varProperty.bstrVal = _bstr_t(automationId) ;
|
153
|
+
|
154
|
+
HRESULT hr = getGlobalIUIAutomation()->CreatePropertyCondition(UIA_AutomationIdPropertyId, varProperty, &pCondition) ;
|
155
|
+
if (SUCCEEDED(hr)) {
|
156
|
+
IUIAutomationElement *pFound ;
|
157
|
+
|
158
|
+
hr = pElement->FindFirst(TreeScope_Descendants, pCondition, &pFound) ;
|
159
|
+
if (SUCCEEDED(hr)) {
|
160
|
+
if (pFound == NULL)
|
161
|
+
printf("RA_FindChildById: Element with automation id %s was not found\r\n", automationId) ;
|
162
|
+
|
163
|
+
return pFound ;
|
164
|
+
} else {
|
165
|
+
printf("RA_FindChildById: FindFirst for children looking for %s failed. hr = 0x%x\r\n", automationId, hr) ;
|
166
|
+
return NULL ;
|
167
|
+
}
|
168
|
+
} else {
|
169
|
+
printf("RA_FindChildById: Cannot create search condition. hr = 0x%x\r\n", hr) ;
|
170
|
+
return NULL ;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
__declspec ( dllexport ) HWND RA_CurrentNativeWindowHandle(IUIAutomationElement *pElement) {
|
175
|
+
UIA_HWND uia_hwnd ;
|
176
|
+
|
177
|
+
if (pElement == NULL) {
|
178
|
+
printf("RA_CurrentNativeWindowHandle: Cannot operate on NULL element\r\n") ;
|
179
|
+
return (HWND)0 ;
|
180
|
+
}
|
181
|
+
|
182
|
+
pElement->get_CurrentNativeWindowHandle(&uia_hwnd) ;
|
183
|
+
return (HWND)uia_hwnd ;
|
184
|
+
}
|
185
|
+
|
186
|
+
__declspec ( dllexport ) int RA_GetCurrentControlType(IUIAutomationElement *pElement) {
|
187
|
+
CONTROLTYPEID control_type ;
|
188
|
+
|
189
|
+
HRESULT hr = pElement->get_CurrentControlType(&control_type) ;
|
190
|
+
if (SUCCEEDED(hr))
|
191
|
+
return control_type ;
|
192
|
+
else {
|
193
|
+
printf("RA_GetCurrentControlType: CurrentControlType returned 0x%x\r\n", hr) ;
|
194
|
+
return 0 ;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
__declspec ( dllexport ) long RA_ClickMouse() {
|
199
|
+
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
200
|
+
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
201
|
+
return 0;
|
202
|
+
}
|
203
|
+
|
204
|
+
__declspec ( dllexport ) long RA_MoveMouse(int x, int y) {
|
205
|
+
return SetCursorPos(x,y);
|
206
|
+
}
|
207
|
+
|
208
|
+
__declspec ( dllexport ) int RA_CurrentIsOffscreen(IUIAutomationElement *pElement, int *visible) {
|
209
|
+
BOOL offscreen;
|
210
|
+
|
211
|
+
HRESULT hr = pElement->get_CurrentIsOffscreen(&offscreen) ;
|
212
|
+
if (SUCCEEDED(hr)) {
|
213
|
+
if(offscreen){
|
214
|
+
*visible = 1;
|
215
|
+
}
|
216
|
+
else
|
217
|
+
{
|
218
|
+
*visible = 0;
|
219
|
+
}
|
220
|
+
return 1;
|
221
|
+
}
|
222
|
+
else {
|
223
|
+
printf("RA_CurrentIsOffscreen: get_CurrentIsOffscreen failed 0x%x\r\n", hr) ;
|
224
|
+
return 0 ;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
__declspec ( dllexport ) int RA_FindChildren(IUIAutomationElement *pElement, IUIAutomationElement *pChildren[]) {
|
229
|
+
IUIAutomationCondition *pTrueCondition ;
|
230
|
+
IUIAutomationElementArray *pElementArray ;
|
231
|
+
int element_count ;
|
232
|
+
|
233
|
+
HRESULT hr = getGlobalIUIAutomation()->CreateTrueCondition(&pTrueCondition) ;
|
234
|
+
if (FAILED(hr)) {
|
235
|
+
printf("RA_FindChildren: Could not create true condition 0x%x\r\n", hr) ;
|
236
|
+
return 0 ;
|
237
|
+
}
|
238
|
+
|
239
|
+
hr = pElement->FindAll(TreeScope_Children, pTrueCondition, &pElementArray) ;
|
240
|
+
if (FAILED(hr)) {
|
241
|
+
printf("RA_FindChildren: FindAll failed 0x%x\r\n", hr) ;
|
242
|
+
return 0 ;
|
243
|
+
}
|
244
|
+
|
245
|
+
hr = pElementArray->get_Length(&element_count) ;
|
246
|
+
if (FAILED(hr)) {
|
247
|
+
printf("RA_FindChildren: get_length failed 0x%x\r\n", hr) ;
|
248
|
+
return 0 ;
|
249
|
+
}
|
250
|
+
|
251
|
+
if (pChildren != NULL) {
|
252
|
+
// given some memory get the details
|
253
|
+
for (int index = 0; index < element_count; index++) {
|
254
|
+
IUIAutomationElement *pElement ;
|
255
|
+
|
256
|
+
hr = pElementArray->GetElement(index, &pElement) ;
|
257
|
+
if (FAILED(hr)) {
|
258
|
+
printf("RA_FindChildren: GetElement failed 0x%x\r\n", hr) ;
|
259
|
+
} else {
|
260
|
+
pChildren[index] = pElement ;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
return element_count ;
|
266
|
+
}
|
267
|
+
|
268
|
+
__declspec ( dllexport ) bool RA_GetControlName(const HWND windowHandle, char* windowName, const int windowNameLength) {
|
269
|
+
try {
|
270
|
+
auto control = gcnew AutomationControl(windowHandle);
|
271
|
+
StringHelper::CopyToUnmanagedString(control->Name, windowName, windowNameLength);
|
272
|
+
return true;
|
273
|
+
} catch(Exception^ e) {
|
274
|
+
return false;
|
275
|
+
}
|
276
|
+
}
|
257
277
|
|
258
278
|
__declspec ( dllexport ) bool IsSet(const FindInformation& findInformation) {
|
259
279
|
try {
|
@@ -275,78 +295,78 @@ extern "C" {
|
|
275
295
|
}
|
276
296
|
}
|
277
297
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
298
|
+
__declspec ( dllexport ) int RA_Select(IUIAutomationElement *pElement) {
|
299
|
+
ISelectionItemProvider *pSelectionPattern ;
|
300
|
+
HRESULT hr = pElement->GetCurrentPattern(UIA_SelectionItemPatternId, (IUnknown**)&pSelectionPattern) ;
|
301
|
+
if (FAILED(hr)) {
|
302
|
+
printf("RA_GetIsSelected: getCurrentPattern failed 0x%x\r\n") ;
|
303
|
+
return FALSE ;
|
304
|
+
}
|
305
|
+
|
306
|
+
hr = pSelectionPattern->Select();
|
307
|
+
if (FAILED(hr)) {
|
308
|
+
printf("RA_Select: Select failed 0x%x\r\n", hr) ;
|
309
|
+
return 0 ;
|
310
|
+
}
|
311
|
+
|
312
|
+
return 1;
|
313
|
+
}
|
314
|
+
|
315
|
+
__declspec ( dllexport ) void RA_Click(const FindInformation& findInformation, char* errorInfo, const int errorInfoSize) {
|
316
|
+
try {
|
317
|
+
auto automationClicker = gcnew AutomationClicker(findInformation);
|
318
|
+
automationClicker->Click();
|
319
|
+
} catch(Exception^ e) {
|
320
|
+
if( errorInfo ) {
|
321
|
+
StringHelper::CopyToUnmanagedString(e->ToString(), errorInfo, errorInfoSize);
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
__declspec ( dllexport ) void RA_PointAndClick(const HWND windowHandle, char* errorInfo, const int errorInfoSize) {
|
327
|
+
try {
|
328
|
+
auto automationClicker = gcnew AutomationClicker(windowHandle);
|
329
|
+
automationClicker->MouseClick();
|
330
|
+
} catch(Exception^ e) {
|
331
|
+
if( errorInfo ) {
|
332
|
+
StringHelper::CopyToUnmanagedString(e->ToString(), errorInfo, errorInfoSize);
|
333
|
+
}
|
334
|
+
}
|
335
|
+
}
|
336
|
+
|
337
|
+
__declspec ( dllexport ) void RA_ExpandItemByValue(const FindInformation& findInformation, const char* whichItem) {
|
338
|
+
try {
|
339
|
+
auto expandCollapseHelper = gcnew ExpandCollapseHelper();
|
340
|
+
expandCollapseHelper->ExpandByValue(findInformation, whichItem);
|
341
|
+
} catch(Exception^ e) {
|
342
|
+
Console::WriteLine(e->ToString());
|
343
|
+
}
|
344
|
+
}
|
345
|
+
|
346
|
+
__declspec ( dllexport ) void RA_ExpandItemByIndex(const FindInformation& findInformation, const int whichItemIndex) {
|
347
|
+
try {
|
348
|
+
auto expandCollapseHelper = gcnew ExpandCollapseHelper();
|
349
|
+
expandCollapseHelper->ExpandByIndex(findInformation, whichItemIndex);
|
350
|
+
} catch(Exception^ e) {
|
351
|
+
Console::WriteLine(e->ToString());
|
352
|
+
}
|
353
|
+
}
|
354
|
+
|
355
|
+
__declspec ( dllexport ) void RA_CollapseItemByValue(const FindInformation& findInformation, const char* whichItem) {
|
356
|
+
try {
|
357
|
+
auto expandCollapseHelper = gcnew ExpandCollapseHelper();
|
358
|
+
expandCollapseHelper->CollapseByValue(findInformation, whichItem);
|
359
|
+
} catch(Exception^ e) {
|
360
|
+
Console::WriteLine(e->ToString());
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
364
|
+
__declspec ( dllexport ) void RA_CollapseItemByIndex(const FindInformation& findInformation, const int whichItemIndex) {
|
365
|
+
try {
|
366
|
+
auto expandCollapseHelper = gcnew ExpandCollapseHelper();
|
367
|
+
expandCollapseHelper->CollapseByIndex(findInformation, whichItemIndex);
|
368
|
+
} catch(Exception^ e) {
|
369
|
+
Console::WriteLine(e->ToString());
|
370
|
+
}
|
371
|
+
}
|
352
372
|
}
|