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
@@ -0,0 +1,108 @@
1
+ using System.Windows;
2
+ using System.Windows.Automation;
3
+
4
+ namespace RAutomation.UIA.Extensions
5
+ {
6
+ public static class Element
7
+ {
8
+ public static SelectionItemPattern AsSelectionItem(this AutomationElement automationElement)
9
+ {
10
+ return (SelectionItemPattern)automationElement.GetCurrentPattern(SelectionItemPattern.Pattern);
11
+ }
12
+
13
+ public static bool Exists(this AutomationElement automationElement)
14
+ {
15
+ return null != automationElement;
16
+ }
17
+
18
+ public static string Name(this AutomationElement automationElement)
19
+ {
20
+ return automationElement.Current.Name;
21
+ }
22
+
23
+ public static string ClassName(this AutomationElement automationElement)
24
+ {
25
+ return automationElement.Current.ClassName;
26
+ }
27
+
28
+ public static bool IsEnabled(this AutomationElement automationElement)
29
+ {
30
+ return automationElement.Current.IsEnabled;
31
+ }
32
+
33
+ public static bool IsFocused(this AutomationElement automationElement)
34
+ {
35
+ return automationElement.Current.HasKeyboardFocus;
36
+ }
37
+
38
+ public static int NativeWindowHandle(this AutomationElement automationElement)
39
+ {
40
+ return automationElement.Exists() ? automationElement.Current.NativeWindowHandle : 0;
41
+ }
42
+
43
+ public static Rect BoundingRectangle(this AutomationElement automationElement)
44
+ {
45
+ return automationElement.Current.BoundingRectangle;
46
+ }
47
+
48
+ public static ControlType ControlType(this AutomationElement automationElement)
49
+ {
50
+ return automationElement.Current.ControlType;
51
+ }
52
+
53
+ public static int ProcessId(this AutomationElement automationElement)
54
+ {
55
+ return automationElement.Current.ProcessId;
56
+ }
57
+
58
+ public static bool IsSelected(this AutomationElement automationElement)
59
+ {
60
+ return automationElement.AsSelectionItem().Current.IsSelected;
61
+ }
62
+
63
+ public static bool IsOffscreen(this AutomationElement automationElement)
64
+ {
65
+ return automationElement.Current.IsOffscreen;
66
+ }
67
+
68
+ public static TogglePattern AsTogglePattern(this AutomationElement automationElement)
69
+ {
70
+ return (TogglePattern)automationElement.GetCurrentPattern(TogglePattern.Pattern);
71
+ }
72
+
73
+ public static bool IsToggled(this AutomationElement automationElement)
74
+ {
75
+ return automationElement.AsTogglePattern().Current.ToggleState == ToggleState.On;
76
+ }
77
+
78
+ public static string Value(this AutomationElement automationElement)
79
+ {
80
+ return automationElement.AsValuePattern().Current.Value;
81
+ }
82
+
83
+ public static void SetValue(this AutomationElement automationElement, string value)
84
+ {
85
+ automationElement.AsValuePattern().SetValue(value);
86
+ }
87
+
88
+ public static bool IsValuePattern(this AutomationElement automationElement)
89
+ {
90
+ return (bool) automationElement.GetCurrentPropertyValue(AutomationElement.IsValuePatternAvailableProperty);
91
+ }
92
+
93
+ public static ValuePattern AsValuePattern(this AutomationElement automationElement)
94
+ {
95
+ return (ValuePattern) automationElement.GetCurrentPattern(ValuePattern.Pattern);
96
+ }
97
+
98
+ public static TextPattern AsTextPattern(this AutomationElement automationElement)
99
+ {
100
+ return (TextPattern) automationElement.GetCurrentPattern(TextPattern.Pattern);
101
+ }
102
+
103
+ public static T As<T>(this AutomationElement automationElement, AutomationPattern pattern)
104
+ {
105
+ return (T) automationElement.GetCurrentPattern(pattern);
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,63 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using System.Windows.Automation;
5
+
6
+ namespace RAutomation.UIA.Extensions
7
+ {
8
+ public static class Enumerable
9
+ {
10
+ public static IEnumerable<AutomationElement> Find(this AutomationElement automationElement, Condition condition)
11
+ {
12
+ return automationElement.Find(Condition.TrueCondition, condition);
13
+ }
14
+
15
+ public static IEnumerable<AutomationElement> Find(this AutomationElement automationElement, params Condition[] conditions)
16
+ {
17
+ return automationElement.FindAll(TreeScope.Subtree, new AndCondition(conditions)).AsEnumerable();
18
+ }
19
+
20
+ public static IEnumerable<AutomationElement> FindAny(this AutomationElement automationElement, params Condition[] conditions)
21
+ {
22
+ return automationElement.FindAll(TreeScope.Subtree, new OrCondition(conditions)).AsEnumerable();
23
+ }
24
+
25
+ public static AutomationElement FindOne(this AutomationElement automationElement, params Condition[] conditions)
26
+ {
27
+ return automationElement.FindFirst(TreeScope.Subtree, new AndCondition(conditions));
28
+ }
29
+
30
+ public static IEnumerable<string> Names(this IEnumerable<AutomationElement> automationElements)
31
+ {
32
+ return automationElements.Select(x => x.Current.Name);
33
+ }
34
+
35
+ public static IEnumerable<SelectionItemPattern> AsSelectionItems(this IEnumerable<AutomationElement> automationElements)
36
+ {
37
+ return automationElements.Select(Element.AsSelectionItem);
38
+ }
39
+
40
+ public static int IndexOf<T>(this IEnumerable<T> items, Func<T, bool> trueCondition)
41
+ {
42
+ var foundIndex = 0;
43
+ foreach (var item in items)
44
+ {
45
+ if (trueCondition(item)) return foundIndex;
46
+ ++foundIndex;
47
+ }
48
+
49
+ return -1;
50
+ }
51
+
52
+ public static void ForEach<T>(this IEnumerable<T> items, Action<T> doIt)
53
+ {
54
+ foreach (var item in items)
55
+ doIt(item);
56
+ }
57
+
58
+ public static IEnumerable<AutomationElement> AsEnumerable(this AutomationElementCollection automationElements)
59
+ {
60
+ return automationElements.Cast<AutomationElement>();
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,27 @@
1
+ using System.Windows.Automation;
2
+
3
+ namespace RAutomation.UIA.Extensions
4
+ {
5
+ public static class Property
6
+ {
7
+ public static Condition Condition(this ControlType controlType)
8
+ {
9
+ return new PropertyCondition(AutomationElement.ControlTypeProperty, controlType);
10
+ }
11
+
12
+ public static Condition TrueCondition(this AutomationProperty property)
13
+ {
14
+ return new PropertyCondition(property, true);
15
+ }
16
+
17
+ public static Condition Is(this AutomationProperty property, object value)
18
+ {
19
+ return new PropertyCondition(property, value);
20
+ }
21
+
22
+ public static bool In(this AutomationProperty property, AutomationElement element)
23
+ {
24
+ return (bool) element.GetCurrentPropertyValue(property);
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,36 @@
1
+ using System.Reflection;
2
+ using System.Runtime.CompilerServices;
3
+ using System.Runtime.InteropServices;
4
+
5
+ // General Information about an assembly is controlled through the following
6
+ // set of attributes. Change these attribute values to modify the information
7
+ // associated with an assembly.
8
+ [assembly: AssemblyTitle("RAutomation.UIA")]
9
+ [assembly: AssemblyDescription("")]
10
+ [assembly: AssemblyConfiguration("")]
11
+ [assembly: AssemblyCompany("")]
12
+ [assembly: AssemblyProduct("RAutomation.UIA")]
13
+ [assembly: AssemblyCopyright("Copyright © 2013")]
14
+ [assembly: AssemblyTrademark("")]
15
+ [assembly: AssemblyCulture("")]
16
+
17
+ // Setting ComVisible to false makes the types in this assembly not visible
18
+ // to COM components. If you need to access a type in this assembly from
19
+ // COM, set the ComVisible attribute to true on that type.
20
+ [assembly: ComVisible(false)]
21
+
22
+ // The following GUID is for the ID of the typelib if this project is exposed to COM
23
+ [assembly: Guid("8ef7f953-d78c-4088-abdb-1104f2300df8")]
24
+
25
+ // Version information for an assembly consists of the following four values:
26
+ //
27
+ // Major Version
28
+ // Minor Version
29
+ // Build Number
30
+ // Revision
31
+ //
32
+ // You can specify all the values or you can default the Build and Revision Numbers
33
+ // by using the '*' as shown below:
34
+ // [assembly: AssemblyVersion("1.0.*")]
35
+ [assembly: AssemblyVersion("1.0.0.0")]
36
+ [assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,18 @@
1
+ using System.Windows.Automation;
2
+ using RAutomation.UIA.Extensions;
3
+
4
+ namespace RAutomation.UIA.Properties
5
+ {
6
+ public class AutomationProperties
7
+ {
8
+ public static Condition IsSelectionItem
9
+ {
10
+ get { return new PropertyCondition(AutomationElement.IsSelectionItemPatternAvailableProperty, true); }
11
+ }
12
+
13
+ public static Condition IsDataItem
14
+ {
15
+ get { return ControlType.DataItem.Condition(); }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,68 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
+ <PropertyGroup>
5
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
+ <ProjectGuid>{0834D9AE-B1AA-422B-B3B2-796C1C346301}</ProjectGuid>
8
+ <OutputType>Library</OutputType>
9
+ <AppDesignerFolder>Properties</AppDesignerFolder>
10
+ <RootNamespace>RAutomation.UIA</RootNamespace>
11
+ <AssemblyName>RAutomation.UIA</AssemblyName>
12
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13
+ <FileAlignment>512</FileAlignment>
14
+ <TargetFrameworkProfile />
15
+ </PropertyGroup>
16
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17
+ <DebugSymbols>true</DebugSymbols>
18
+ <DebugType>full</DebugType>
19
+ <Optimize>false</Optimize>
20
+ <OutputPath>bin\Debug\</OutputPath>
21
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
22
+ <ErrorReport>prompt</ErrorReport>
23
+ <WarningLevel>4</WarningLevel>
24
+ </PropertyGroup>
25
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26
+ <DebugType>pdbonly</DebugType>
27
+ <Optimize>true</Optimize>
28
+ <OutputPath>bin\Release\</OutputPath>
29
+ <DefineConstants>TRACE</DefineConstants>
30
+ <ErrorReport>prompt</ErrorReport>
31
+ <WarningLevel>4</WarningLevel>
32
+ </PropertyGroup>
33
+ <ItemGroup>
34
+ <Reference Include="System" />
35
+ <Reference Include="System.Core" />
36
+ <Reference Include="System.Drawing" />
37
+ <Reference Include="System.Windows.Forms" />
38
+ <Reference Include="System.Xml.Linq" />
39
+ <Reference Include="System.Data.DataSetExtensions" />
40
+ <Reference Include="System.Data" />
41
+ <Reference Include="System.Xml" />
42
+ <Reference Include="UIAutomationClient" />
43
+ <Reference Include="UIAutomationTypes" />
44
+ <Reference Include="WindowsBase" />
45
+ </ItemGroup>
46
+ <ItemGroup>
47
+ <Compile Include="Controls\Clicker.cs" />
48
+ <Compile Include="Controls\SelectList.cs" />
49
+ <Compile Include="Controls\Spinner.cs" />
50
+ <Compile Include="Controls\TabControl.cs" />
51
+ <Compile Include="Controls\TableControl.cs" />
52
+ <Compile Include="Controls\TextControl.cs" />
53
+ <Compile Include="Expander.cs" />
54
+ <Compile Include="Extensions\Property.cs" />
55
+ <Compile Include="Extensions\Enumerable.cs" />
56
+ <Compile Include="Extensions\Element.cs" />
57
+ <Compile Include="Properties\AssemblyInfo.cs" />
58
+ <Compile Include="Properties\AutomationProperties.cs" />
59
+ </ItemGroup>
60
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
61
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
62
+ Other similar extension points exist, see Microsoft.Common.targets.
63
+ <Target Name="BeforeBuild">
64
+ </Target>
65
+ <Target Name="AfterBuild">
66
+ </Target>
67
+ -->
68
+ </Project>
@@ -1,18 +1,40 @@
1
1
  
2
- Microsoft Visual Studio Solution File, Format Version 11.00
3
- # Visual Studio 2010
2
+ Microsoft Visual Studio Solution File, Format Version 12.00
3
+ # Visual Studio 2012
4
4
  Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UiaDll", "UiaDll\UiaDll.vcxproj", "{4A06195F-8D10-4384-97C3-86D512C40DE4}"
5
5
  EndProject
6
+ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RAutomation.UIA", "RAutomation.UIA\RAutomation.UIA.csproj", "{0834D9AE-B1AA-422B-B3B2-796C1C346301}"
7
+ EndProject
6
8
  Global
7
9
  GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+ Debug|Any CPU = Debug|Any CPU
11
+ Debug|Mixed Platforms = Debug|Mixed Platforms
8
12
  Debug|Win32 = Debug|Win32
13
+ Release|Any CPU = Release|Any CPU
14
+ Release|Mixed Platforms = Release|Mixed Platforms
9
15
  Release|Win32 = Release|Win32
10
16
  EndGlobalSection
11
17
  GlobalSection(ProjectConfigurationPlatforms) = postSolution
18
+ {4A06195F-8D10-4384-97C3-86D512C40DE4}.Debug|Any CPU.ActiveCfg = Debug|Win32
19
+ {4A06195F-8D10-4384-97C3-86D512C40DE4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
20
+ {4A06195F-8D10-4384-97C3-86D512C40DE4}.Debug|Mixed Platforms.Build.0 = Debug|Win32
12
21
  {4A06195F-8D10-4384-97C3-86D512C40DE4}.Debug|Win32.ActiveCfg = Debug|Win32
13
22
  {4A06195F-8D10-4384-97C3-86D512C40DE4}.Debug|Win32.Build.0 = Debug|Win32
23
+ {4A06195F-8D10-4384-97C3-86D512C40DE4}.Release|Any CPU.ActiveCfg = Release|Win32
24
+ {4A06195F-8D10-4384-97C3-86D512C40DE4}.Release|Mixed Platforms.ActiveCfg = Release|Win32
25
+ {4A06195F-8D10-4384-97C3-86D512C40DE4}.Release|Mixed Platforms.Build.0 = Release|Win32
14
26
  {4A06195F-8D10-4384-97C3-86D512C40DE4}.Release|Win32.ActiveCfg = Release|Win32
15
27
  {4A06195F-8D10-4384-97C3-86D512C40DE4}.Release|Win32.Build.0 = Release|Win32
28
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Debug|Any CPU.Build.0 = Debug|Any CPU
30
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
31
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
32
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Debug|Win32.ActiveCfg = Debug|Any CPU
33
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Release|Any CPU.ActiveCfg = Release|Any CPU
34
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Release|Any CPU.Build.0 = Release|Any CPU
35
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
36
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Release|Mixed Platforms.Build.0 = Release|Any CPU
37
+ {0834D9AE-B1AA-422B-B3B2-796C1C346301}.Release|Win32.ActiveCfg = Release|Any CPU
16
38
  EndGlobalSection
17
39
  GlobalSection(SolutionProperties) = preSolution
18
40
  HideSolutionNode = FALSE
@@ -1,15 +1,16 @@
1
1
  #include "stdafx.h"
2
- #include "AutomationControl.h"
2
+ #include "Locator.h"
3
3
  #include "StringHelper.h"
4
4
 
5
+ using namespace RAutomation::UIA::Extensions;
6
+
5
7
  extern "C" {
6
8
  __declspec ( dllexport ) void Control_GetValue(const FindInformation& findInformation, char* theValue, const int maximumLength) {
7
- auto control = gcnew AutomationControl(findInformation);
8
- StringHelper::CopyToUnmanagedString(control->Value, theValue, maximumLength);
9
+ auto value = Element::Value(Locator::FindFor(findInformation));
10
+ StringHelper::CopyToUnmanagedString(value, theValue, maximumLength);
9
11
  }
10
12
 
11
13
  __declspec ( dllexport ) void Control_SetValue(const FindInformation& findInformation, const char* theValue) {
12
- auto control = gcnew AutomationControl(findInformation);
13
- control->Value = gcnew String(theValue);
14
+ Element::SetValue(Locator::FindFor(findInformation), gcnew String(theValue));
14
15
  }
15
16
  }
@@ -0,0 +1,24 @@
1
+ #include "StdAfx.h"
2
+ #include "DynamicAssemblyResolver.h"
3
+
4
+ void DynamicAssemblyResolver::PrivatePath::set(String^ path) {
5
+ _PrivatePath = path;
6
+ AppDomain::CurrentDomain->AssemblyResolve += gcnew ResolveEventHandler(Resolve);
7
+ }
8
+
9
+ Assembly^ DynamicAssemblyResolver::Resolve(Object^ sender, ResolveEventArgs^ args)
10
+ {
11
+ try
12
+ {
13
+ auto fullPrivatePath = Path::Combine(_PrivatePath, AssemblyFromQualifiedName(args->Name));
14
+ return Assembly::LoadFrom(fullPrivatePath);
15
+ }
16
+ catch(...) { }
17
+
18
+ return nullptr;
19
+ }
20
+
21
+ String^ DynamicAssemblyResolver::AssemblyFromQualifiedName(String^ qualifiedName)
22
+ {
23
+ return qualifiedName->Substring(0, qualifiedName->IndexOf(",")) + ".dll";
24
+ }
@@ -0,0 +1,16 @@
1
+ #pragma once
2
+ using namespace System::IO;
3
+ using namespace System::Reflection;
4
+
5
+ ref class DynamicAssemblyResolver
6
+ {
7
+ public:
8
+ static property String^ PrivatePath {
9
+ void set(String^ value);
10
+ }
11
+
12
+ private:
13
+ static String^ _PrivatePath = nullptr;
14
+ static Assembly^ Resolve(Object^ sender, ResolveEventArgs^ args);
15
+ static String^ AssemblyFromQualifiedName(String^ qualifiedName);
16
+ };
@@ -1,37 +1,47 @@
1
1
  #include "StdAfx.h"
2
- #include "AutomationFinder.h"
2
+ #include "Locator.h"
3
3
 
4
- AutomationFinder::AutomationFinder(AutomationElement^ automationElement)
4
+ Locator::Locator(AutomationElement^ automationElement)
5
5
  {
6
6
  _automationElement = automationElement;
7
7
  }
8
8
 
9
- AutomationElementCollection^ AutomationFinder::Find(...array<Condition^>^ conditions)
9
+ AutomationElement^ Locator::FindFor(const FindInformation& findInformation)
10
+ {
11
+ try {
12
+ auto finder = gcnew Locator(AutomationElement::FromHandle(IntPtr(findInformation.rootWindow)));
13
+ return finder->Find(findInformation);
14
+ } catch(Exception^) {
15
+ return nullptr;
16
+ }
17
+ }
18
+
19
+ AutomationElementCollection^ Locator::Find(...array<Condition^>^ conditions)
10
20
  {
11
21
  return Find(Subtree, conditions);
12
22
  }
13
23
 
14
- AutomationElementCollection^ AutomationFinder::Find(const UIAutomation::TreeScope scope, ...array<Condition^>^ conditions)
24
+ AutomationElementCollection^ Locator::Find(const UIAutomation::TreeScope scope, ...array<Condition^>^ conditions)
15
25
  {
16
26
  return _automationElement->FindAll(scope, SomethingOrEverything(conditions));
17
27
  }
18
28
 
19
- AutomationElement^ AutomationFinder::FindFirst(...array<Condition^>^ conditions)
29
+ AutomationElement^ Locator::FindFirst(...array<Condition^>^ conditions)
20
30
  {
21
31
  return FindFirst(Subtree, conditions);
22
32
  }
23
33
 
24
- AutomationElement^ AutomationFinder::FindFirst(const UIAutomation::TreeScope scope, ...array<Condition^>^ conditions)
34
+ AutomationElement^ Locator::FindFirst(const UIAutomation::TreeScope scope, ...array<Condition^>^ conditions)
25
35
  {
26
36
  return _automationElement->FindFirst(scope, SomethingOrEverything(conditions));
27
37
  }
28
38
 
29
- AutomationElement^ AutomationFinder::Find(const FindInformation& findInformation)
39
+ AutomationElement^ Locator::Find(const FindInformation& findInformation)
30
40
  {
31
41
  auto scope = findInformation.onlySearchChildren ? Children : Subtree;
32
42
 
33
43
  switch(findInformation.how) {
34
- case FindMethod::Id:
44
+ case Id:
35
45
  {
36
46
  auto searchCondition = gcnew PropertyCondition(AutomationElement::AutomationIdProperty, gcnew String(findInformation.data.stringData));
37
47
  if( 0 == findInformation.index ) {
@@ -40,7 +50,7 @@ AutomationElement^ AutomationFinder::Find(const FindInformation& findInformation
40
50
 
41
51
  return FindAt(scope, findInformation.index, searchCondition);
42
52
  }
43
- case FindMethod::Value:
53
+ case Value:
44
54
  {
45
55
  auto searchCondition = gcnew PropertyCondition(AutomationElement::NameProperty, gcnew String(findInformation.data.stringData));
46
56
 
@@ -50,28 +60,28 @@ AutomationElement^ AutomationFinder::Find(const FindInformation& findInformation
50
60
 
51
61
  return FindAt(scope, findInformation.index, searchCondition);
52
62
  }
53
- case FindMethod::Focus:
63
+ case Focus:
54
64
  return AutomationElement::FocusedElement;
55
- case FindMethod::ScreenPoint:
65
+ case ScreenPoint:
56
66
  return AutomationElement::FromPoint(Point(findInformation.data.pointData[0], findInformation.data.pointData[1]));
57
- case FindMethod::Handle:
67
+ case Handle:
58
68
  return AutomationElement::FromHandle(IntPtr(findInformation.data.intData));
59
69
  }
60
70
 
61
71
  return nullptr;
62
72
  }
63
73
 
64
- AutomationElement^ AutomationFinder::FindAt(const int whichItem, ...array<Condition^>^ conditions)
74
+ AutomationElement^ Locator::FindAt(const int whichItem, ...array<Condition^>^ conditions)
65
75
  {
66
76
  return FindAt(Subtree, whichItem, conditions);
67
77
  }
68
78
 
69
- AutomationElement^ AutomationFinder::FindAt(const UIAutomation::TreeScope scope, const int whichItem, ...array<Condition^>^ conditions)
79
+ AutomationElement^ Locator::FindAt(const UIAutomation::TreeScope scope, const int whichItem, ...array<Condition^>^ conditions)
70
80
  {
71
81
  return Find(scope, conditions)[whichItem];
72
82
  }
73
83
 
74
- Condition^ AutomationFinder::SomethingOrEverything(...array<Condition^>^ conditions)
84
+ Condition^ Locator::SomethingOrEverything(...array<Condition^>^ conditions)
75
85
  {
76
86
  if( conditions->Length == 0 ) {
77
87
  return Condition::TrueCondition;