rautomation 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/History.rdoc +7 -1
  4. data/VERSION +1 -1
  5. data/ext/UiaDll/RAutomation.UIA/Controls/Clicker.cs +59 -0
  6. data/ext/UiaDll/RAutomation.UIA/Controls/SelectList.cs +76 -0
  7. data/ext/UiaDll/RAutomation.UIA/Controls/Spinner.cs +46 -0
  8. data/ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs +54 -0
  9. data/ext/UiaDll/RAutomation.UIA/Controls/TableControl.cs +87 -0
  10. data/ext/UiaDll/RAutomation.UIA/Controls/TextControl.cs +50 -0
  11. data/ext/UiaDll/RAutomation.UIA/Expander.cs +59 -0
  12. data/ext/UiaDll/RAutomation.UIA/Extensions/Element.cs +108 -0
  13. data/ext/UiaDll/RAutomation.UIA/Extensions/Enumerable.cs +63 -0
  14. data/ext/UiaDll/RAutomation.UIA/Extensions/Property.cs +27 -0
  15. data/ext/UiaDll/RAutomation.UIA/Properties/AssemblyInfo.cs +36 -0
  16. data/ext/UiaDll/RAutomation.UIA/Properties/AutomationProperties.cs +18 -0
  17. data/ext/UiaDll/RAutomation.UIA/RAutomation.UIA.csproj +68 -0
  18. data/ext/UiaDll/UiaDll.sln +24 -2
  19. data/ext/UiaDll/UiaDll/ControlMethods.cpp +6 -5
  20. data/ext/UiaDll/UiaDll/DynamicAssemblyResolver.cpp +24 -0
  21. data/ext/UiaDll/UiaDll/DynamicAssemblyResolver.h +16 -0
  22. data/ext/UiaDll/UiaDll/{AutomationFinder.cpp → Locator.cpp} +25 -15
  23. data/ext/UiaDll/UiaDll/{AutomationFinder.h → Locator.h} +4 -2
  24. data/ext/UiaDll/UiaDll/MenuItemSelector.cpp +3 -3
  25. data/ext/UiaDll/UiaDll/MenuMethods.cpp +4 -0
  26. data/ext/UiaDll/UiaDll/SelectListMethods.cpp +40 -21
  27. data/ext/UiaDll/UiaDll/SpinnerMethods.cpp +61 -0
  28. data/ext/UiaDll/UiaDll/StringHelper.cpp +13 -1
  29. data/ext/UiaDll/UiaDll/StringHelper.h +1 -0
  30. data/ext/UiaDll/UiaDll/TabControlMethods.cpp +11 -8
  31. data/ext/UiaDll/UiaDll/TableMethods.cpp +20 -21
  32. data/ext/UiaDll/UiaDll/TextMethods.cpp +19 -17
  33. data/ext/UiaDll/UiaDll/UiaDll.cpp +191 -342
  34. data/ext/UiaDll/UiaDll/UiaDll.vcxproj +11 -21
  35. data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +22 -115
  36. data/ext/UiaDll/UiaDll/dllmain.cpp +1 -21
  37. data/ext/UiaDll/UiaDll/stdafx.h +0 -2
  38. data/ext/WindowsForms/WindowsForms/DataEntryForm.Designer.cs +17 -0
  39. data/ext/WindowsForms/WindowsForms/DataEntryForm.cs +2 -6
  40. data/ext/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +6 -7
  41. data/ext/WindowsForms/WindowsForms/MainFormWindow.cs +2 -0
  42. data/ext/WindowsForms/WindowsForms/UIA.Extensions.dll +0 -0
  43. data/ext/WindowsForms/WindowsForms/ValueMonthCalendar.cs +28 -0
  44. data/ext/WindowsForms/WindowsForms/WindowsForms.csproj +5 -4
  45. data/lib/rautomation/adapter/ms_uia.rb +1 -0
  46. data/lib/rautomation/adapter/ms_uia/control.rb +1 -13
  47. data/lib/rautomation/adapter/ms_uia/functions.rb +2 -16
  48. data/lib/rautomation/adapter/ms_uia/list_box.rb +2 -2
  49. data/lib/rautomation/adapter/ms_uia/spinner.rb +31 -0
  50. data/lib/rautomation/adapter/ms_uia/uia_dll.rb +59 -31
  51. data/lib/rautomation/adapter/ms_uia/window.rb +5 -4
  52. data/rautomation.gemspec +1 -0
  53. data/spec/adapter/ms_uia/spinner_spec.rb +44 -0
  54. data/spec/adapter/ms_uia/value_control_spec.rb +2 -2
  55. metadata +26 -25
  56. data/ext/UiaDll/UiaDll/AutomatedSelectList.cpp +0 -93
  57. data/ext/UiaDll/UiaDll/AutomatedSelectList.h +0 -47
  58. data/ext/UiaDll/UiaDll/AutomatedTabControl.cpp +0 -45
  59. data/ext/UiaDll/UiaDll/AutomatedTabControl.h +0 -41
  60. data/ext/UiaDll/UiaDll/AutomatedTable.cpp +0 -92
  61. data/ext/UiaDll/UiaDll/AutomatedTable.h +0 -35
  62. data/ext/UiaDll/UiaDll/AutomatedText.cpp +0 -22
  63. data/ext/UiaDll/UiaDll/AutomatedText.h +0 -26
  64. data/ext/UiaDll/UiaDll/AutomationClicker.cpp +0 -53
  65. data/ext/UiaDll/UiaDll/AutomationClicker.h +0 -30
  66. data/ext/UiaDll/UiaDll/AutomationControl.cpp +0 -40
  67. data/ext/UiaDll/UiaDll/AutomationControl.h +0 -75
  68. data/ext/UiaDll/UiaDll/ExpandCollapseHelper.cpp +0 -53
  69. data/ext/UiaDll/UiaDll/ExpandCollapseHelper.h +0 -25
  70. data/ext/UiaDll/UiaDll/SelectionItem.cpp +0 -10
  71. data/ext/UiaDll/UiaDll/SelectionItem.h +0 -21
  72. data/ext/UiaDll/UiaDll/Toggle.cpp +0 -2
  73. data/ext/UiaDll/UiaDll/Toggle.h +0 -22
  74. data/ext/UiaDll/UiaDll/globals.h +0 -3
  75. data/ext/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs +0 -59
  76. data/ext/WindowsForms/WindowsForms/AutomationHelpers/AutomationProvider.cs +0 -91
@@ -1,93 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "AutomatedSelectList.h"
3
-
4
- AutomatedSelectList::AutomatedSelectList(const HWND windowHandle) : AutomationControl(windowHandle)
5
- { }
6
-
7
- AutomatedSelectList::AutomatedSelectList(const FindInformation& findInformation) : AutomationControl(findInformation)
8
- { }
9
-
10
- array<String^>^ AutomatedSelectList::Selection::get() {
11
- auto selectedElements = AsSelectionPattern->Current.GetSelection();
12
- auto selections = gcnew array<String^>(selectedElements.Length);
13
- auto whichOne = 0;
14
- for each(auto element in selectedElements) {
15
- selections[whichOne++] = element->Current.Name;
16
- }
17
- return selections;
18
- }
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
-
30
- bool AutomatedSelectList::SelectByIndex(const int whichItem)
31
- {
32
- try {
33
- auto selectionItems = _control->FindAll(System::Windows::Automation::TreeScope::Subtree, SelectionCondition);
34
- Select(selectionItems[whichItem]);
35
- return true;
36
- } catch(Exception^ e) {
37
- Console::WriteLine(e->ToString());
38
- return false;
39
- }
40
- }
41
-
42
- bool AutomatedSelectList::SelectByValue(const char* whichItem)
43
- {
44
- try {
45
- auto nameCondition = gcnew PropertyCondition(AutomationElement::NameProperty, gcnew String(whichItem));
46
- auto selectionAndNameCondition = gcnew AndCondition(SelectionCondition, nameCondition);
47
-
48
- Select(_control->FindFirst(System::Windows::Automation::TreeScope::Subtree, selectionAndNameCondition));
49
- return true;
50
- } catch(Exception^ e) {
51
- Console::WriteLine(e->ToString());
52
- return false;
53
- }
54
- }
55
-
56
- bool AutomatedSelectList::GetValueByIndex(const int whichItem, char* comboValue, const int comboValueSize)
57
- {
58
- try {
59
- auto selectionItem = SelectionItems[whichItem];
60
- auto nameProperty = dynamic_cast<String^>(selectionItem->GetCurrentPropertyValue(AutomationElement::NameProperty));
61
-
62
- StringHelper::CopyToUnmanagedString(nameProperty, comboValue, comboValueSize);
63
- return true;
64
- } catch(Exception^ e) {
65
- Console::WriteLine(e->ToString());
66
- return false;
67
- }
68
- }
69
-
70
- int AutomatedSelectList::SelectedIndex::get() {
71
- int selectedIndex = 0;
72
- for each(AutomationElement^ selectionItem in SelectionItems) {
73
- auto selectionPattern = dynamic_cast<SelectionItemPattern^>(selectionItem->GetCurrentPattern(SelectionItemPattern::Pattern));
74
- if( selectionPattern->Current.IsSelected ) {
75
- return selectedIndex;
76
- }
77
- ++selectedIndex;
78
- }
79
- return -1;
80
- }
81
-
82
-
83
- void AutomatedSelectList::Select(AutomationElement^ itemToSelect)
84
- {
85
- auto selectionPattern = dynamic_cast<SelectionItemPattern^>(itemToSelect->GetCurrentPattern(SelectionItemPattern::Pattern));
86
-
87
- try {
88
- AutomationClicker::MouseClickOn(itemToSelect);
89
- } catch(Exception^) {}
90
-
91
- if( !selectionPattern->Current.IsSelected )
92
- selectionPattern->Select();
93
- }
@@ -1,47 +0,0 @@
1
- #pragma once
2
- #include "AutomationControl.h"
3
- #include "AutomationClicker.h"
4
- #include "StringHelper.h"
5
-
6
- using namespace System::Windows::Automation;
7
-
8
- ref class AutomatedSelectList : public AutomationControl
9
- {
10
- public:
11
- AutomatedSelectList(const HWND windowHandle);
12
- AutomatedSelectList(const FindInformation& findInformation);
13
- bool SelectByIndex(const int whichItem);
14
- bool SelectByValue(const char* whichItem);
15
- bool GetValueByIndex(const int whichItem, char* comboValue, const int comboValueSize);
16
- int GetOptions(const char* options[]);
17
-
18
- property array<String^>^ Selection {
19
- array<String^>^ get();
20
- }
21
-
22
- property int Count {
23
- int get() { return SelectionItems->Count; }
24
- }
25
-
26
- property int SelectedIndex {
27
- int get();
28
- }
29
-
30
- private:
31
- void Select(AutomationElement^ itemToSelect);
32
-
33
- property SelectionPattern^ AsSelectionPattern {
34
- SelectionPattern^ get() {
35
- return dynamic_cast<SelectionPattern^>(_control->GetCurrentPattern(SelectionPattern::Pattern));
36
- }
37
- }
38
-
39
- property AutomationElementCollection^ SelectionItems {
40
- AutomationElementCollection^ get() { return _control->FindAll(System::Windows::Automation::TreeScope::Subtree, SelectionCondition); }
41
- }
42
-
43
- property PropertyCondition^ SelectionCondition {
44
- PropertyCondition^ get() { return gcnew PropertyCondition(AutomationElement::IsSelectionItemPatternAvailableProperty, true); }
45
- }
46
- };
47
-
@@ -1,45 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "AutomatedTabControl.h"
3
-
4
- AutomatedTabControl::AutomatedTabControl(const FindInformation& findInformation) : AutomationControl(findInformation)
5
- {}
6
-
7
- String^ AutomatedTabControl::Selection::get()
8
- {
9
- auto theSelection = AsSelectionPattern->Current.GetSelection()[0];
10
- return theSelection->Current.Name;
11
- }
12
-
13
- void AutomatedTabControl::Selection::set(String^ value)
14
- {
15
- Select(_control->FindFirst(UIA::TreeScope::Subtree, GetNamedTabItemCondition(value)));
16
- }
17
-
18
- void AutomatedTabControl::SelectedIndex::set(int selectedIndex)
19
- {
20
- Select(TabItems[selectedIndex]);
21
- }
22
-
23
- int AutomatedTabControl::SelectedIndex::get()
24
- {
25
- int selectedIndex = 0;
26
- for each(AutomationElement^ selectionItem in TabItems) {
27
- auto selectionPattern = dynamic_cast<SelectionItemPattern^>(selectionItem->GetCurrentPattern(SelectionItemPattern::Pattern));
28
- if( selectionPattern->Current.IsSelected ) {
29
- return selectedIndex;
30
- }
31
- ++selectedIndex;
32
- }
33
- return -1;
34
- }
35
-
36
- int AutomatedTabControl::GetTabItems(const char* options[])
37
- {
38
- auto tabItems = TabItems;
39
-
40
- if( NULL != options ) {
41
- StringHelper::CopyNames(tabItems, options);
42
- }
43
-
44
- return tabItems->Count;
45
- }
@@ -1,41 +0,0 @@
1
- #pragma once
2
- #include "AutomationControl.h"
3
- #include "StringHelper.h"
4
-
5
- namespace UIA = System::Windows::Automation;
6
-
7
- ref class AutomatedTabControl : AutomationControl
8
- {
9
- public:
10
- AutomatedTabControl(const FindInformation& findInformation);
11
-
12
- int GetTabItems(const char* options[]);
13
-
14
- property String^ Selection {
15
- String^ get();
16
- void set(String^);
17
- }
18
-
19
- property int SelectedIndex {
20
- int get();
21
- void set(int);
22
- }
23
-
24
- private:
25
- property AutomationElementCollection^ TabItems {
26
- AutomationElementCollection^ get() { return _control->FindAll(UIA::TreeScope::Subtree, TabItemCondition); }
27
- }
28
-
29
- property Condition^ TabItemCondition {
30
- Condition^ get() { return gcnew PropertyCondition(AutomationElement::ControlTypeProperty, UIA::ControlType::TabItem); }
31
- }
32
-
33
- Condition^ GetNamedTabItemCondition(String^ name) {
34
- return gcnew AndCondition(TabItemCondition, gcnew PropertyCondition(AutomationElement::NameProperty, name));
35
- }
36
-
37
- void Select(AutomationElement^ tabItem) {
38
- dynamic_cast<SelectionItemPattern^>(tabItem->GetCurrentPattern(SelectionItemPattern::Pattern))->Select();
39
- }
40
- };
41
-
@@ -1,92 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "AutomatedTable.h"
3
-
4
- AutomatedTable::AutomatedTable(const HWND windowHandle) : AutomationControl(windowHandle)
5
- {
6
- _finder = gcnew AutomationFinder(_control);
7
- }
8
-
9
- AutomatedTable::AutomatedTable(const FindInformation& finderInformation) : AutomationControl(finderInformation)
10
- {
11
- _finder = gcnew AutomationFinder(_control);
12
- }
13
-
14
- int AutomatedTable::GetHeaders(const char* headers[])
15
- {
16
- auto headerItems = _finder->Find(AutomationFinder::IsHeaderItem);
17
-
18
- if( NULL != headers ) {
19
- StringHelper::CopyNames(headerItems, headers);
20
- }
21
-
22
- return headerItems->Count;
23
- }
24
-
25
- int AutomatedTable::GetValues(const char* values[])
26
- {
27
- auto tableItems = _finder->Find(gcnew OrCondition(AutomationFinder::IsTableItem, AutomationFinder::IsListItem));
28
-
29
- if( NULL != values ) {
30
- StringHelper::CopyNames(tableItems, values);
31
- }
32
-
33
- return tableItems->Count;
34
- }
35
-
36
- int AutomatedTable::RowCount::get()
37
- {
38
- auto tablePattern = dynamic_cast<TablePattern^>(_control->GetCurrentPattern(TablePattern::Pattern));
39
- return tablePattern->Current.RowCount;
40
- }
41
-
42
- bool AutomatedTable::Exists(const int whichItemIndex, const int whichColumnIndex)
43
- {
44
- return nullptr != DataItemAt(whichItemIndex, whichColumnIndex);
45
- }
46
-
47
- String^ AutomatedTable::ValueAt(const int whichItemIndex, const int whichItemColumn)
48
- {
49
- return DataItemAt(whichItemIndex, whichItemColumn)->Current.Name;
50
- }
51
-
52
- AutomationElement^ AutomatedTable::DataItemAt(const int whichItemIndex, const int whichItemColumn)
53
- {
54
- auto indexProperty = gcnew PropertyCondition(TableItemPattern::RowProperty, whichItemIndex);
55
- auto columnProperty = gcnew PropertyCondition(TableItemPattern::ColumnProperty, whichItemColumn);
56
- return _finder->FindFirst(AutomationFinder::IsTableItem, indexProperty, columnProperty);
57
- }
58
-
59
- bool AutomatedTable::Exists(Condition^ condition)
60
- {
61
- return _finder->Find(AutomationFinder::IsTableItem, condition)->Count > 0;
62
- }
63
-
64
- void AutomatedTable::Select(const int dataItemIndex)
65
- {
66
- try {
67
- Select(_finder->Find(AutomationFinder::IsDataItem)[dataItemIndex]);
68
- } catch(IndexOutOfRangeException^ e) {
69
- throw gcnew ArgumentException(String::Format("Table item at index {0} does not exist", dataItemIndex));
70
- }
71
- }
72
-
73
- bool AutomatedTable::IsSelected(const int dataItemIndex) {
74
-
75
- return AsSelectionItem(_finder->FindAt(dataItemIndex, AutomationFinder::IsSelectionItem))->Current.IsSelected;
76
- }
77
-
78
- void AutomatedTable::Select(const char* dataItemValue)
79
- {
80
- try {
81
- auto nameCondition = gcnew PropertyCondition(AutomationElement::NameProperty, gcnew String(dataItemValue));
82
- Select(_finder->Find(AutomationFinder::IsDataItem, nameCondition)[0]);
83
- } catch(IndexOutOfRangeException^ e) {
84
- throw gcnew ArgumentException(String::Format("Table item with the value \"{0}\" was not found", gcnew String(dataItemValue)));
85
- }
86
- }
87
-
88
- void AutomatedTable::Select(AutomationElement^ dataItem)
89
- {
90
- auto selectionItemPattern = dynamic_cast<SelectionItemPattern^>(dataItem->GetCurrentPattern(SelectionItemPattern::Pattern));
91
- selectionItemPattern->Select();
92
- }
@@ -1,35 +0,0 @@
1
- #pragma once
2
- #include "AutomationControl.h"
3
- #include "AutomationFinder.h"
4
- #include "StringHelper.h"
5
-
6
- using namespace System::Windows::Automation;
7
-
8
- ref class AutomatedTable : AutomationControl
9
- {
10
- public:
11
- AutomatedTable(const HWND windowHandle);
12
- AutomatedTable(const FindInformation& finderInformation);
13
- bool Exists(const int whichItemIndex, const int whichColumnIndex);
14
- String^ ValueAt(const int whichItemIndex, const int whichColumnIndex);
15
- void Select(const int dataItemIndex);
16
- void Select(const char* dataItemValue);
17
- bool IsSelected(const int dataItemIndex);
18
- int GetHeaders(const char* headers[]);
19
- int GetValues(const char* values[]);
20
-
21
- property int RowCount {
22
- int get();
23
- }
24
-
25
- private:
26
- AutomationFinder^ _finder;
27
- bool Exists(Condition^ condition);
28
- AutomationElement^ DataItemAt(const int whichItemIndex, const int whichItemRow);
29
- void Select(AutomationElement^ dataItem);
30
-
31
- SelectionItemPattern^ AsSelectionItem(AutomationElement^ automationElement) {
32
- return dynamic_cast<SelectionItemPattern^>(automationElement->GetCurrentPattern(SelectionItemPattern::Pattern));
33
- }
34
- };
35
-
@@ -1,22 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "AutomatedText.h"
3
-
4
- String^ AutomatedText::Text::get() {
5
- if( IsValuePattern ) {
6
- return Value;
7
- } else {
8
- return AsTextPattern->DocumentRange->GetText(-1);
9
- }
10
- }
11
-
12
- void AutomatedText::Text::set(String^ value) {
13
- if( IsValuePattern ) {
14
- Value = value;
15
- } else {
16
- _control->SetFocus();
17
- SendKeys::SendWait("^{HOME}"); // Move to start of control
18
- SendKeys::SendWait("^+{END}"); // Select everything
19
- SendKeys::SendWait("{DEL}"); // Delete selection
20
- SendKeys::SendWait(value);
21
- }
22
- }
@@ -1,26 +0,0 @@
1
- #pragma once
2
-
3
- #include "automationcontrol.h"
4
-
5
- using namespace System::Windows::Automation;
6
- using namespace System::Windows::Forms;
7
-
8
- ref class AutomatedText : public AutomationControl
9
- {
10
- public:
11
- AutomatedText(const HWND windowHandle) : AutomationControl(windowHandle) {}
12
- AutomatedText(const FindInformation& finderInformation) : AutomationControl(finderInformation) {}
13
-
14
- property String^ Text {
15
- String^ get();
16
- void set(String^ value);
17
- }
18
-
19
- private:
20
- property TextPattern^ AsTextPattern {
21
- TextPattern^ get() {
22
- return dynamic_cast<TextPattern^>(_control->GetCurrentPattern(TextPattern::Pattern));
23
- }
24
- }
25
- };
26
-
@@ -1,53 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "AutomationClicker.h"
3
-
4
- bool AutomationClicker::Click() {
5
- try {
6
- if( CanInvoke() ) {
7
- Invoke();
8
- } else if( CanToggle() ) {
9
- Toggle();
10
- } else if( CanSelect() ) {
11
- Select();
12
- }
13
-
14
- return true;
15
- } catch(Exception^ e) {
16
- Console::WriteLine("AutomationClicker::Click - {0}", e->Message);
17
- return false;
18
- }
19
-
20
- throw gcnew Exception(gcnew String("AutomationElement did not support the InvokePattern, TogglePattern or the SelectionItemPattern"));
21
- }
22
-
23
- void AutomationClicker::MouseClick() {
24
- _control->SetFocus();
25
- auto clickablePoint = _control->GetClickablePoint();
26
- Cursor::Position = System::Drawing::Point((int)clickablePoint.X, (int)clickablePoint.Y);
27
- mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
28
- mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
29
- }
30
-
31
- bool AutomationClicker::CanInvoke() {
32
- return (bool)(_control->GetCurrentPropertyValue(AutomationElement::IsInvokePatternAvailableProperty));
33
- }
34
-
35
- void AutomationClicker::Invoke() {
36
- dynamic_cast<InvokePattern^>(_control->GetCurrentPattern(InvokePattern::Pattern))->Invoke();
37
- }
38
-
39
- bool AutomationClicker::CanToggle() {
40
- return (bool)(_control->GetCurrentPropertyValue(AutomationElement::IsTogglePatternAvailableProperty));
41
- }
42
-
43
- void AutomationClicker::Toggle() {
44
- dynamic_cast<TogglePattern^>(_control->GetCurrentPattern(TogglePattern::Pattern))->Toggle();
45
- }
46
-
47
- bool AutomationClicker::CanSelect() {
48
- return (bool)(_control->GetCurrentPropertyValue(AutomationElement::IsSelectionItemPatternAvailableProperty));
49
- }
50
-
51
- void AutomationClicker::Select() {
52
- dynamic_cast<SelectionItemPattern^>(_control->GetCurrentPattern(SelectionItemPattern::Pattern))->Select();
53
- }