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,30 +0,0 @@
1
- #pragma once
2
- using namespace System::Windows::Automation;
3
- using namespace System::Windows::Forms;
4
- using namespace System::Drawing;
5
-
6
- #include "AutomationControl.h"
7
-
8
- ref class AutomationClicker : AutomationControl
9
- {
10
- public:
11
- AutomationClicker(const HWND windowHandle) : AutomationControl(windowHandle) {}
12
- AutomationClicker(const FindInformation& findInformation) : AutomationControl(findInformation) {}
13
- AutomationClicker(AutomationElement^ automationElement) : AutomationControl(automationElement) {}
14
- bool Click();
15
- void MouseClick();
16
-
17
- static void MouseClickOn(AutomationElement^ automationElement) {
18
- (gcnew AutomationClicker(automationElement))->MouseClick();
19
- }
20
-
21
- private:
22
- bool CanInvoke();
23
- void Invoke();
24
-
25
- bool CanToggle();
26
- void Toggle();
27
-
28
- bool CanSelect();
29
- void Select();
30
- };
@@ -1,40 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "AutomationControl.h"
3
- #include "AutomationFinder.h"
4
-
5
- AutomationControl::AutomationControl(const HWND windowHandle)
6
- {
7
- _control = AutomationElement::FromHandle(IntPtr(windowHandle));
8
- }
9
-
10
- AutomationControl::AutomationControl(const FindInformation& findInformation)
11
- {
12
- try {
13
- auto rootElement = AutomationElement::FromHandle(IntPtr(findInformation.rootWindow));
14
- auto finder = gcnew AutomationFinder(rootElement);
15
- _control = finder->Find(findInformation);
16
- }
17
- catch(Exception^ e) {
18
- Debug::WriteLine("AutomationControl error: {0}", e->Message);
19
- }
20
- }
21
-
22
- AutomationControl::AutomationControl(AutomationElement^ automationElement) {
23
- _control = automationElement;
24
- }
25
-
26
- void AutomationControl::Value::set(String^ value) {
27
- AsValuePattern->SetValue(value);
28
- }
29
-
30
- String^ AutomationControl::Value::get() {
31
- return AsValuePattern->Current.Value;
32
- }
33
-
34
- bool AutomationControl::IsValuePattern::get() {
35
- try {
36
- return nullptr != AsValuePattern;
37
- } catch(Exception^ e) {
38
- return false;
39
- }
40
- }
@@ -1,75 +0,0 @@
1
- #pragma once
2
-
3
- using namespace System::Windows::Automation;
4
- using namespace System::Windows;
5
- using namespace System::Diagnostics;
6
-
7
- ref class AutomationControl
8
- {
9
- public:
10
- AutomationControl(const HWND windowHandle);
11
- AutomationControl(const FindInformation& findInformation);
12
- AutomationControl(AutomationElement^ automationElement);
13
-
14
- property AutomationElement^ Element {
15
- AutomationElement^ get() { return _control; }
16
- }
17
-
18
- property String^ Name {
19
- String^ get() { return _control->Current.Name; }
20
- }
21
-
22
- property String^ ClassName {
23
- String^ get() { return _control->Current.ClassName; }
24
- }
25
-
26
- property bool IsEnabled {
27
- bool get() { return _control->Current.IsEnabled; }
28
- }
29
-
30
- property bool IsFocused {
31
- bool get() { return _control->Current.HasKeyboardFocus; }
32
- }
33
-
34
- property Rect BoundingRectangle {
35
- Rect get() { return _control->Current.BoundingRectangle; }
36
- }
37
-
38
- property System::Windows::Automation::ControlType^ ControlType {
39
- System::Windows::Automation::ControlType^ get() { return _control->Current.ControlType; }
40
- }
41
-
42
- property int ProcessId {
43
- int get() { return _control->Current.ProcessId; }
44
- }
45
-
46
- property String^ Value {
47
- String^ get();
48
- void set(String^ value);
49
- }
50
-
51
- property bool Exists {
52
- bool get() { return nullptr != _control; }
53
- }
54
-
55
- property bool IsValuePattern {
56
- bool get();
57
- }
58
-
59
- protected:
60
- AutomationElement^ _control;
61
-
62
- protected:
63
- property ValuePattern^ AsValuePattern {
64
- ValuePattern^ get() {
65
- return dynamic_cast<ValuePattern^>(_control->GetCurrentPattern(ValuePattern::Pattern));
66
- }
67
- }
68
-
69
- property SelectionPattern^ AsSelectionPattern {
70
- SelectionPattern^ get() {
71
- return dynamic_cast<SelectionPattern^>(_control->GetCurrentPattern(SelectionPattern::Pattern));
72
- }
73
- }
74
- };
75
-
@@ -1,53 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "ExpandCollapseHelper.h"
3
-
4
-
5
- void ExpandCollapseHelper::ExpandByValue(const FindInformation& findInformation, const char* whichItem)
6
- {
7
- Expand(ExpandableItem(findInformation, whichItem));
8
- }
9
-
10
- void ExpandCollapseHelper::ExpandByIndex(const FindInformation& findInformation, const int whichItemIndex)
11
- {
12
- auto expandableItem = ExpandableItems(findInformation)[whichItemIndex];
13
- Expand(expandableItem);
14
- }
15
-
16
- void ExpandCollapseHelper::CollapseByValue(const FindInformation& findInformation, const char* whichItem)
17
- {
18
- Collapse(ExpandableItem(findInformation, whichItem));
19
- }
20
-
21
- void ExpandCollapseHelper::CollapseByIndex(const FindInformation& findInformation, const int whichItemIndex)
22
- {
23
- auto expandableItem = ExpandableItems(findInformation)[whichItemIndex];
24
- Collapse(expandableItem);
25
- }
26
-
27
- AutomationElementCollection^ ExpandCollapseHelper::ExpandableItems(const FindInformation& findInformation)
28
- {
29
- auto automationElement = (gcnew AutomationControl(findInformation))->Element;
30
- return automationElement->FindAll(System::Windows::Automation::TreeScope::Subtree, IsExpandable);
31
- }
32
-
33
- AutomationElement^ ExpandCollapseHelper::ExpandableItem(const FindInformation& findInformation, const char* whichItem)
34
- {
35
- auto automationElement = (gcnew AutomationControl(findInformation))->Element;
36
- auto andTheNameMatches = gcnew PropertyCondition(AutomationElement::NameProperty, gcnew String(whichItem));
37
- return automationElement->FindFirst(System::Windows::Automation::TreeScope::Subtree, gcnew AndCondition(IsExpandable, andTheNameMatches));
38
- }
39
-
40
- void ExpandCollapseHelper::Expand(AutomationElement^ automationElement)
41
- {
42
- dynamic_cast<ExpandCollapsePattern^>(automationElement->GetCurrentPattern(ExpandCollapsePattern::Pattern))->Expand();
43
- }
44
-
45
- void ExpandCollapseHelper::Collapse(AutomationElement^ automationElement)
46
- {
47
- dynamic_cast<ExpandCollapsePattern^>(automationElement->GetCurrentPattern(ExpandCollapsePattern::Pattern))->Collapse();
48
- }
49
-
50
- PropertyCondition^ ExpandCollapseHelper::IsExpandable::get()
51
- {
52
- return gcnew PropertyCondition(AutomationElement::IsExpandCollapsePatternAvailableProperty, true);
53
- }
@@ -1,25 +0,0 @@
1
- #pragma once
2
-
3
- #include "AutomationControl.h"
4
-
5
- using namespace System::Windows::Automation;
6
-
7
- ref class ExpandCollapseHelper
8
- {
9
- public:
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);
14
-
15
- private:
16
- AutomationElementCollection^ ExpandableItems(const FindInformation& findInformation);
17
- AutomationElement^ ExpandableItem(const FindInformation& findInformation, const char* whichItem);
18
- void Expand(AutomationElement^ automationElement);
19
- void Collapse(AutomationElement^ automationElement);
20
-
21
- property PropertyCondition^ IsExpandable {
22
- PropertyCondition^ get();
23
- }
24
- };
25
-
@@ -1,10 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "SelectionItem.h"
3
-
4
- SelectionItem::SelectionItem(const HWND windowHandle) : AutomationControl(windowHandle)
5
- {
6
- }
7
-
8
- SelectionItem::SelectionItem(const FindInformation& findInformation) : AutomationControl(findInformation)
9
- {
10
- }
@@ -1,21 +0,0 @@
1
- #pragma once
2
- #include "automationcontrol.h"
3
- ref class SelectionItem :
4
- public AutomationControl
5
- {
6
- public:
7
- SelectionItem(const HWND windowHandle);
8
- SelectionItem(const FindInformation& findInformation);
9
-
10
- property bool IsSelected {
11
- bool get() { return AsSelectionItemPattern->Current.IsSelected; }
12
- }
13
-
14
- private:
15
- property SelectionItemPattern^ AsSelectionItemPattern {
16
- SelectionItemPattern^ get() {
17
- return dynamic_cast<SelectionItemPattern^>(_control->GetCurrentPattern(SelectionItemPattern::Pattern));
18
- }
19
- }
20
- };
21
-
@@ -1,2 +0,0 @@
1
- #include "StdAfx.h"
2
- #include "Toggle.h"
@@ -1,22 +0,0 @@
1
- #pragma once
2
- #include "AutomationControl.h"
3
-
4
- ref class Toggle : public AutomationControl
5
- {
6
- public:
7
- Toggle(const HWND windowHandle) : AutomationControl(windowHandle) {}
8
- Toggle(const FindInformation& findInformation) : AutomationControl(findInformation) {}
9
-
10
- property bool IsSet {
11
- bool get() { return AsTogglePattern->Current.ToggleState == System::Windows::Automation::ToggleState::On; }
12
- }
13
-
14
- private:
15
- property TogglePattern^ AsTogglePattern {
16
- TogglePattern^ get() {
17
- return dynamic_cast<TogglePattern^>(_control->GetCurrentPattern(TogglePattern::Pattern));
18
- }
19
- }
20
-
21
- };
22
-
@@ -1,3 +0,0 @@
1
-
2
- IUIAutomation* getGlobalIUIAutomation() ;
3
-
@@ -1,59 +0,0 @@
1
- using System;
2
- using System.Collections.Generic;
3
- using System.Globalization;
4
- using System.Windows.Automation;
5
- using System.Windows.Automation.Provider;
6
- using System.Windows.Forms;
7
- using WindowsForms.AutomationHelpers;
8
-
9
- namespace WindowsForms
10
- {
11
- public class AutomatableMonthCalendar : MonthCalendar
12
- {
13
- private MonthCalendarAutomationProvider _automationProvider;
14
-
15
- private IRawElementProviderSimple RawElementProviderSimple
16
- {
17
- get { return _automationProvider ?? (_automationProvider = new MonthCalendarAutomationProvider(this)); }
18
- }
19
-
20
- protected override void WndProc(ref Message m)
21
- {
22
- if (m.Msg == 0x3D /* WM_GETOBJECT */)
23
- {
24
- m.Result = AutomationInteropProvider.ReturnRawElementProvider(m.HWnd, m.WParam, m.LParam, RawElementProviderSimple);
25
- return;
26
- }
27
-
28
- base.WndProc(ref m);
29
- }
30
- }
31
-
32
- internal class MonthCalendarAutomationProvider : AutomationProvider, IValueProvider
33
- {
34
- private readonly MonthCalendar _control;
35
-
36
- public MonthCalendarAutomationProvider(MonthCalendar control)
37
- : base(control)
38
- {
39
- _control = control;
40
- }
41
-
42
- protected override List<int> SupportedPatterns
43
- {
44
- get { return new List<int> { ValuePatternIdentifiers.Pattern.Id }; }
45
- }
46
-
47
- public void SetValue(string value)
48
- {
49
- _control.SetDate(DateTime.Parse(value, new CultureInfo("en-US")));
50
- }
51
-
52
- public string Value
53
- {
54
- get { return _control.SelectionStart.ToString(new CultureInfo("en-US")); }
55
- }
56
-
57
- public bool IsReadOnly { get; private set; }
58
- }
59
- }
@@ -1,91 +0,0 @@
1
- using System.Collections.Generic;
2
- using System.Linq;
3
- using System.Windows;
4
- using System.Windows.Automation;
5
- using System.Windows.Automation.Provider;
6
- using System.Windows.Forms;
7
-
8
- namespace WindowsForms.AutomationHelpers
9
- {
10
- public abstract class AutomationProvider : IRawElementProviderFragmentRoot
11
- {
12
- private readonly Control _control;
13
- private readonly Dictionary<int, object> _properties;
14
-
15
- protected AutomationProvider(Control control)
16
- {
17
- _control = control;
18
- _properties = new Dictionary<int, object>
19
- {
20
- {AutomationElementIdentifiers.ControlTypeProperty.Id, ControlType.Custom.Id},
21
- {AutomationElementIdentifiers.LocalizedControlTypeProperty.Id, _control.GetType().FullName},
22
- {AutomationElementIdentifiers.AutomationIdProperty.Id, _control.Name},
23
- {AutomationElementIdentifiers.IsKeyboardFocusableProperty.Id, true},
24
- };
25
- }
26
-
27
- protected abstract List<int> SupportedPatterns { get; }
28
-
29
- protected const int ProviderUseComThreading = 0x20;
30
- public ProviderOptions ProviderOptions
31
- {
32
- get
33
- {
34
- return (ProviderOptions)((int)ProviderOptions.ServerSideProvider | ProviderUseComThreading);
35
- }
36
- }
37
-
38
- public IRawElementProviderSimple HostRawElementProvider
39
- {
40
- get { return AutomationInteropProvider.HostProviderFromHandle(_control.Handle); }
41
- }
42
-
43
- public Rect BoundingRectangle { get; private set; }
44
-
45
- public IRawElementProviderFragmentRoot FragmentRoot
46
- {
47
- get { return this; }
48
- }
49
-
50
- public object GetPropertyValue(int propertyId)
51
- {
52
- return _properties.Where(x => x.Key.Equals(propertyId))
53
- .Select(x => x.Value)
54
- .FirstOrDefault();
55
- }
56
-
57
- public object GetPatternProvider(int patternId)
58
- {
59
- return SupportedPatterns.Contains(patternId) ? this : null;
60
- }
61
-
62
- public IRawElementProviderSimple[] GetEmbeddedFragmentRoots()
63
- {
64
- return null;
65
- }
66
-
67
- public int[] GetRuntimeId()
68
- {
69
- return new[] { _control.GetHashCode() };
70
- }
71
-
72
- public void SetFocus()
73
- {
74
- }
75
-
76
- public IRawElementProviderFragment Navigate(NavigateDirection direction)
77
- {
78
- return null;
79
- }
80
-
81
- public IRawElementProviderFragment ElementProviderFromPoint(double x, double y)
82
- {
83
- return null;
84
- }
85
-
86
- public IRawElementProviderFragment GetFocus()
87
- {
88
- return null;
89
- }
90
- }
91
- }