rautomation 2.0.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +41 -0
  4. data/.rspec +2 -0
  5. data/.yardopts +8 -0
  6. data/CHANGES.md +276 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +20 -0
  9. data/README.md +142 -0
  10. data/Rakefile +73 -0
  11. data/ext/AutoItX/AutoItX.chm +0 -0
  12. data/ext/AutoItX/AutoItX3.dll +0 -0
  13. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.cpp +30 -0
  14. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj +179 -0
  15. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj.filters +42 -0
  16. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj.user +3 -0
  17. data/ext/IAccessibleDLL/IAccessibleDLL/ReadMe.txt +48 -0
  18. data/ext/IAccessibleDLL/IAccessibleDLL/dllmain.cpp +19 -0
  19. data/ext/IAccessibleDLL/IAccessibleDLL/stdafx.cpp +8 -0
  20. data/ext/IAccessibleDLL/IAccessibleDLL/stdafx.h +22 -0
  21. data/ext/IAccessibleDLL/IAccessibleDLL/table_support.cpp +282 -0
  22. data/ext/IAccessibleDLL/IAccessibleDLL/targetver.h +8 -0
  23. data/ext/IAccessibleDLL/IAccessibleDLL.sln +31 -0
  24. data/ext/IAccessibleDLL/IAccessibleDLL.suo +0 -0
  25. data/ext/IAccessibleDLL/Release/IAccessibleDLL.dll +0 -0
  26. data/ext/UiaDll/RAutomation.UIA/Controls/Clicker.cs +63 -0
  27. data/ext/UiaDll/RAutomation.UIA/Controls/SelectList.cs +116 -0
  28. data/ext/UiaDll/RAutomation.UIA/Controls/Spinner.cs +46 -0
  29. data/ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs +54 -0
  30. data/ext/UiaDll/RAutomation.UIA/Controls/TableControl.cs +132 -0
  31. data/ext/UiaDll/RAutomation.UIA/Controls/TextControl.cs +50 -0
  32. data/ext/UiaDll/RAutomation.UIA/Expander.cs +59 -0
  33. data/ext/UiaDll/RAutomation.UIA/Extensions/Element.cs +166 -0
  34. data/ext/UiaDll/RAutomation.UIA/Extensions/Enumerable.cs +76 -0
  35. data/ext/UiaDll/RAutomation.UIA/Extensions/Property.cs +27 -0
  36. data/ext/UiaDll/RAutomation.UIA/Properties/AssemblyInfo.cs +36 -0
  37. data/ext/UiaDll/RAutomation.UIA/Properties/AutomationProperties.cs +18 -0
  38. data/ext/UiaDll/RAutomation.UIA/RAutomation.UIA.csproj +77 -0
  39. data/ext/UiaDll/Release/RAutomation.UIA.dll +0 -0
  40. data/ext/UiaDll/Release/UiaDll.dll +0 -0
  41. data/ext/UiaDll/UiaDll/ArrayHelper.cpp +14 -0
  42. data/ext/UiaDll/UiaDll/ArrayHelper.h +7 -0
  43. data/ext/UiaDll/UiaDll/AssemblyInfo.cpp +40 -0
  44. data/ext/UiaDll/UiaDll/ControlMethods.cpp +16 -0
  45. data/ext/UiaDll/UiaDll/DynamicAssemblyResolver.cpp +24 -0
  46. data/ext/UiaDll/UiaDll/DynamicAssemblyResolver.h +16 -0
  47. data/ext/UiaDll/UiaDll/Locator.cpp +93 -0
  48. data/ext/UiaDll/UiaDll/Locator.h +55 -0
  49. data/ext/UiaDll/UiaDll/MenuItemSelector.cpp +75 -0
  50. data/ext/UiaDll/UiaDll/MenuItemSelector.h +24 -0
  51. data/ext/UiaDll/UiaDll/MenuMethods.cpp +62 -0
  52. data/ext/UiaDll/UiaDll/ReadMe.txt +38 -0
  53. data/ext/UiaDll/UiaDll/SelectListMethods.cpp +84 -0
  54. data/ext/UiaDll/UiaDll/SpinnerMethods.cpp +61 -0
  55. data/ext/UiaDll/UiaDll/StringHelper.cpp +57 -0
  56. data/ext/UiaDll/UiaDll/StringHelper.h +15 -0
  57. data/ext/UiaDll/UiaDll/StringMethods.cpp +8 -0
  58. data/ext/UiaDll/UiaDll/TabControlMethods.cpp +40 -0
  59. data/ext/UiaDll/UiaDll/TableMethods.cpp +108 -0
  60. data/ext/UiaDll/UiaDll/TextMethods.cpp +25 -0
  61. data/ext/UiaDll/UiaDll/ToggleStateHelper.h +10 -0
  62. data/ext/UiaDll/UiaDll/UiaDll.cpp +216 -0
  63. data/ext/UiaDll/UiaDll/UiaDll.h +13 -0
  64. data/ext/UiaDll/UiaDll/UiaDll.vcxproj +167 -0
  65. data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +110 -0
  66. data/ext/UiaDll/UiaDll/app.ico +0 -0
  67. data/ext/UiaDll/UiaDll/app.rc +0 -0
  68. data/ext/UiaDll/UiaDll/dllmain.cpp +1 -0
  69. data/ext/UiaDll/UiaDll/resource.h +3 -0
  70. data/ext/UiaDll/UiaDll/stdafx.cpp +5 -0
  71. data/ext/UiaDll/UiaDll/stdafx.h +41 -0
  72. data/ext/UiaDll/UiaDll/targetver.h +8 -0
  73. data/ext/UiaDll/UiaDll.sln +57 -0
  74. data/ext/WindowsForms/.nuget/NuGet.Config +6 -0
  75. data/ext/WindowsForms/.nuget/NuGet.exe +0 -0
  76. data/ext/WindowsForms/.nuget/NuGet.targets +136 -0
  77. data/ext/WindowsForms/Release/FizzWare.NBuilder.dll +0 -0
  78. data/ext/WindowsForms/Release/UIA.Extensions.dll +0 -0
  79. data/ext/WindowsForms/Release/WindowsForms.exe +0 -0
  80. data/ext/WindowsForms/WindowsForms/AboutBox.Designer.cs +168 -0
  81. data/ext/WindowsForms/WindowsForms/AboutBox.cs +103 -0
  82. data/ext/WindowsForms/WindowsForms/AboutBox.resx +123 -0
  83. data/ext/WindowsForms/WindowsForms/DataEntryForm.Designer.cs +218 -0
  84. data/ext/WindowsForms/WindowsForms/DataEntryForm.cs +52 -0
  85. data/ext/WindowsForms/WindowsForms/DataEntryForm.resx +120 -0
  86. data/ext/WindowsForms/WindowsForms/DataGridView.Designer.cs +77 -0
  87. data/ext/WindowsForms/WindowsForms/DataGridView.cs +43 -0
  88. data/ext/WindowsForms/WindowsForms/DataGridView.resx +120 -0
  89. data/ext/WindowsForms/WindowsForms/FizzWare.NBuilder.dll +0 -0
  90. data/ext/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +527 -0
  91. data/ext/WindowsForms/WindowsForms/MainFormWindow.cs +109 -0
  92. data/ext/WindowsForms/WindowsForms/MainFormWindow.resx +126 -0
  93. data/ext/WindowsForms/WindowsForms/PersonForm.Designer.cs +119 -0
  94. data/ext/WindowsForms/WindowsForms/PersonForm.cs +34 -0
  95. data/ext/WindowsForms/WindowsForms/PersonForm.resx +120 -0
  96. data/ext/WindowsForms/WindowsForms/Program.cs +21 -0
  97. data/ext/WindowsForms/WindowsForms/Properties/AssemblyInfo.cs +36 -0
  98. data/ext/WindowsForms/WindowsForms/Properties/Resources.Designer.cs +71 -0
  99. data/ext/WindowsForms/WindowsForms/Properties/Resources.resx +117 -0
  100. data/ext/WindowsForms/WindowsForms/Properties/Settings.Designer.cs +30 -0
  101. data/ext/WindowsForms/WindowsForms/Properties/Settings.settings +7 -0
  102. data/ext/WindowsForms/WindowsForms/SimpleElementsForm.Designer.cs +93 -0
  103. data/ext/WindowsForms/WindowsForms/SimpleElementsForm.cs +19 -0
  104. data/ext/WindowsForms/WindowsForms/SimpleElementsForm.resx +120 -0
  105. data/ext/WindowsForms/WindowsForms/UIA.Extensions.dll +0 -0
  106. data/ext/WindowsForms/WindowsForms/ValueMonthCalendar.cs +28 -0
  107. data/ext/WindowsForms/WindowsForms/WindowsForms.csproj +166 -0
  108. data/ext/WindowsForms/WindowsForms/packages.config +4 -0
  109. data/ext/WindowsForms/WindowsForms.sln +46 -0
  110. data/lib/rautomation/adapter/autoit/button.rb +59 -0
  111. data/lib/rautomation/adapter/autoit/locators.rb +22 -0
  112. data/lib/rautomation/adapter/autoit/mouse.rb +38 -0
  113. data/lib/rautomation/adapter/autoit/text_field.rb +70 -0
  114. data/lib/rautomation/adapter/autoit/window.rb +197 -0
  115. data/lib/rautomation/adapter/autoit.rb +8 -0
  116. data/lib/rautomation/adapter/helper.rb +64 -0
  117. data/lib/rautomation/adapter/ms_uia/button.rb +21 -0
  118. data/lib/rautomation/adapter/ms_uia/button_helper.rb +19 -0
  119. data/lib/rautomation/adapter/ms_uia/checkbox.rb +23 -0
  120. data/lib/rautomation/adapter/ms_uia/constants.rb +111 -0
  121. data/lib/rautomation/adapter/ms_uia/control.rb +134 -0
  122. data/lib/rautomation/adapter/ms_uia/functions.rb +279 -0
  123. data/lib/rautomation/adapter/ms_uia/keys.rb +121 -0
  124. data/lib/rautomation/adapter/ms_uia/keystroke_converter.rb +122 -0
  125. data/lib/rautomation/adapter/ms_uia/label.rb +18 -0
  126. data/lib/rautomation/adapter/ms_uia/list_box.rb +46 -0
  127. data/lib/rautomation/adapter/ms_uia/list_item.rb +22 -0
  128. data/lib/rautomation/adapter/ms_uia/locators.rb +23 -0
  129. data/lib/rautomation/adapter/ms_uia/menu.rb +36 -0
  130. data/lib/rautomation/adapter/ms_uia/radio.rb +23 -0
  131. data/lib/rautomation/adapter/ms_uia/select_list.rb +85 -0
  132. data/lib/rautomation/adapter/ms_uia/spinner.rb +31 -0
  133. data/lib/rautomation/adapter/ms_uia/tab_control.rb +46 -0
  134. data/lib/rautomation/adapter/ms_uia/table.rb +140 -0
  135. data/lib/rautomation/adapter/ms_uia/text_field.rb +39 -0
  136. data/lib/rautomation/adapter/ms_uia/uia_dll.rb +428 -0
  137. data/lib/rautomation/adapter/ms_uia/value_control.rb +21 -0
  138. data/lib/rautomation/adapter/ms_uia/window.rb +289 -0
  139. data/lib/rautomation/adapter/ms_uia.rb +27 -0
  140. data/lib/rautomation/adapter/win_32/button.rb +14 -0
  141. data/lib/rautomation/adapter/win_32/button_helper.rb +24 -0
  142. data/lib/rautomation/adapter/win_32/checkbox.rb +14 -0
  143. data/lib/rautomation/adapter/win_32/constants.rb +73 -0
  144. data/lib/rautomation/adapter/win_32/control.rb +86 -0
  145. data/lib/rautomation/adapter/win_32/functions.rb +336 -0
  146. data/lib/rautomation/adapter/win_32/keys.rb +146 -0
  147. data/lib/rautomation/adapter/win_32/label.rb +10 -0
  148. data/lib/rautomation/adapter/win_32/list_box.rb +40 -0
  149. data/lib/rautomation/adapter/win_32/locators.rb +22 -0
  150. data/lib/rautomation/adapter/win_32/mouse.rb +59 -0
  151. data/lib/rautomation/adapter/win_32/password_field.rb +15 -0
  152. data/lib/rautomation/adapter/win_32/radio.rb +11 -0
  153. data/lib/rautomation/adapter/win_32/select_list.rb +97 -0
  154. data/lib/rautomation/adapter/win_32/table.rb +25 -0
  155. data/lib/rautomation/adapter/win_32/text_field.rb +52 -0
  156. data/lib/rautomation/adapter/win_32/window.rb +277 -0
  157. data/lib/rautomation/adapter/win_32.rb +23 -0
  158. data/lib/rautomation/button.rb +55 -0
  159. data/lib/rautomation/element_collections.rb +55 -0
  160. data/lib/rautomation/platform.rb +15 -0
  161. data/lib/rautomation/text_field.rb +60 -0
  162. data/lib/rautomation/version.rb +3 -0
  163. data/lib/rautomation/wait_helper.rb +23 -0
  164. data/lib/rautomation/window.rb +248 -0
  165. data/lib/rautomation.rb +8 -0
  166. data/rautomation.gemspec +52 -0
  167. data/spec/adapter/autoit/mouse_spec.rb +53 -0
  168. data/spec/adapter/autoit/window_spec.rb +17 -0
  169. data/spec/adapter/ms_uia/button_spec.rb +39 -0
  170. data/spec/adapter/ms_uia/checkbox_spec.rb +55 -0
  171. data/spec/adapter/ms_uia/control_spec.rb +88 -0
  172. data/spec/adapter/ms_uia/functions_spec.rb +39 -0
  173. data/spec/adapter/ms_uia/keystroke_converter_spec.rb +48 -0
  174. data/spec/adapter/ms_uia/label_spec.rb +18 -0
  175. data/spec/adapter/ms_uia/list_item_spec.rb +14 -0
  176. data/spec/adapter/ms_uia/listbox_spec.rb +73 -0
  177. data/spec/adapter/ms_uia/radio_spec.rb +39 -0
  178. data/spec/adapter/ms_uia/select_list_spec.rb +118 -0
  179. data/spec/adapter/ms_uia/spinner_spec.rb +44 -0
  180. data/spec/adapter/ms_uia/tab_control_spec.rb +53 -0
  181. data/spec/adapter/ms_uia/table_spec.rb +197 -0
  182. data/spec/adapter/ms_uia/text_field_spec.rb +43 -0
  183. data/spec/adapter/ms_uia/value_control_spec.rb +11 -0
  184. data/spec/adapter/ms_uia/window_spec.rb +81 -0
  185. data/spec/adapter/win_32/button_spec.rb +31 -0
  186. data/spec/adapter/win_32/checkbox_spec.rb +46 -0
  187. data/spec/adapter/win_32/label_spec.rb +13 -0
  188. data/spec/adapter/win_32/listbox_spec.rb +41 -0
  189. data/spec/adapter/win_32/mouse_spec.rb +49 -0
  190. data/spec/adapter/win_32/radio_spec.rb +33 -0
  191. data/spec/adapter/win_32/select_list_spec.rb +65 -0
  192. data/spec/adapter/win_32/table_spec.rb +27 -0
  193. data/spec/adapter/win_32/text_field_spec.rb +24 -0
  194. data/spec/adapter/win_32/window_spec.rb +61 -0
  195. data/spec/button_spec.rb +67 -0
  196. data/spec/buttons_spec.rb +21 -0
  197. data/spec/spec_helper.rb +128 -0
  198. data/spec/text_field_spec.rb +64 -0
  199. data/spec/text_fields_spec.rb +22 -0
  200. data/spec/window_spec.rb +150 -0
  201. data/spec/windows_spec.rb +76 -0
  202. metadata +369 -0
@@ -0,0 +1,76 @@
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 int[] IndexesOf<T>(this IEnumerable<T> items, Func<T, bool> trueCondition)
53
+ {
54
+ var indexes = new List<int>();
55
+ var foundIndex = 0;
56
+ foreach (var item in items)
57
+ {
58
+ if (trueCondition(item)) indexes.Add(foundIndex);
59
+ ++foundIndex;
60
+ }
61
+
62
+ return indexes.ToArray();
63
+ }
64
+
65
+ public static void ForEach<T>(this IEnumerable<T> items, Action<T> doIt)
66
+ {
67
+ foreach (var item in items)
68
+ doIt(item);
69
+ }
70
+
71
+ public static IEnumerable<AutomationElement> AsEnumerable(this AutomationElementCollection automationElements)
72
+ {
73
+ return automationElements.Cast<AutomationElement>();
74
+ }
75
+ }
76
+ }
@@ -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,77 @@
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
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
34
+ <PlatformTarget>x64</PlatformTarget>
35
+ <OutputPath>bin\x64\Debug\</OutputPath>
36
+ </PropertyGroup>
37
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
38
+ <PlatformTarget>x64</PlatformTarget>
39
+ <OutputPath>bin\x64\Release\</OutputPath>
40
+ <RegisterForComInterop>false</RegisterForComInterop>
41
+ </PropertyGroup>
42
+ <ItemGroup>
43
+ <Reference Include="System" />
44
+ <Reference Include="System.Core" />
45
+ <Reference Include="System.Drawing" />
46
+ <Reference Include="System.Windows.Forms" />
47
+ <Reference Include="System.Xml.Linq" />
48
+ <Reference Include="System.Data.DataSetExtensions" />
49
+ <Reference Include="System.Data" />
50
+ <Reference Include="System.Xml" />
51
+ <Reference Include="UIAutomationClient" />
52
+ <Reference Include="UIAutomationTypes" />
53
+ <Reference Include="WindowsBase" />
54
+ </ItemGroup>
55
+ <ItemGroup>
56
+ <Compile Include="Controls\Clicker.cs" />
57
+ <Compile Include="Controls\SelectList.cs" />
58
+ <Compile Include="Controls\Spinner.cs" />
59
+ <Compile Include="Controls\TabControl.cs" />
60
+ <Compile Include="Controls\TableControl.cs" />
61
+ <Compile Include="Controls\TextControl.cs" />
62
+ <Compile Include="Expander.cs" />
63
+ <Compile Include="Extensions\Property.cs" />
64
+ <Compile Include="Extensions\Enumerable.cs" />
65
+ <Compile Include="Extensions\Element.cs" />
66
+ <Compile Include="Properties\AssemblyInfo.cs" />
67
+ <Compile Include="Properties\AutomationProperties.cs" />
68
+ </ItemGroup>
69
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
70
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
71
+ Other similar extension points exist, see Microsoft.Common.targets.
72
+ <Target Name="BeforeBuild">
73
+ </Target>
74
+ <Target Name="AfterBuild">
75
+ </Target>
76
+ -->
77
+ </Project>
Binary file
@@ -0,0 +1,14 @@
1
+ #include "StdAfx.h"
2
+ #include "ArrayHelper.h"
3
+
4
+
5
+ int ArrayHelper::Copy(array<int, 1>^ source, int destination[])
6
+ {
7
+ if( NULL != destination ) {
8
+ auto index = 0;
9
+ for each(auto value in source) {
10
+ destination[index++] = value;
11
+ }
12
+ }
13
+ return source->Length;
14
+ }
@@ -0,0 +1,7 @@
1
+ #pragma once
2
+ ref class ArrayHelper
3
+ {
4
+ public:
5
+ static int Copy(array<int>^ source, int destination[]);
6
+ };
7
+
@@ -0,0 +1,40 @@
1
+ #include "stdafx.h"
2
+
3
+ using namespace System;
4
+ using namespace System::Reflection;
5
+ using namespace System::Runtime::CompilerServices;
6
+ using namespace System::Runtime::InteropServices;
7
+ using namespace System::Security::Permissions;
8
+
9
+ //
10
+ // General Information about an assembly is controlled through the following
11
+ // set of attributes. Change these attribute values to modify the information
12
+ // associated with an assembly.
13
+ //
14
+ [assembly:AssemblyTitleAttribute("UiaDll")];
15
+ [assembly:AssemblyDescriptionAttribute("")];
16
+ [assembly:AssemblyConfigurationAttribute("")];
17
+ [assembly:AssemblyCompanyAttribute("")];
18
+ [assembly:AssemblyProductAttribute("UiaDll")];
19
+ [assembly:AssemblyCopyrightAttribute("Copyright (c) 2012")];
20
+ [assembly:AssemblyTrademarkAttribute("")];
21
+ [assembly:AssemblyCultureAttribute("")];
22
+
23
+ //
24
+ // Version information for an assembly consists of the following four values:
25
+ //
26
+ // Major Version
27
+ // Minor Version
28
+ // Build Number
29
+ // Revision
30
+ //
31
+ // You can specify all the value or you can default the Revision and Build Numbers
32
+ // by using the '*' as shown below:
33
+
34
+ [assembly:AssemblyVersionAttribute("1.0.*")];
35
+
36
+ [assembly:ComVisible(false)];
37
+
38
+ [assembly:CLSCompliantAttribute(true)];
39
+
40
+ [assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
@@ -0,0 +1,16 @@
1
+ #include "stdafx.h"
2
+ #include "Locator.h"
3
+ #include "StringHelper.h"
4
+
5
+ using namespace RAutomation::UIA::Extensions;
6
+
7
+ extern "C" {
8
+ __declspec ( dllexport ) void Control_GetValue(const FindInformation& findInformation, char* theValue, const int maximumLength) {
9
+ auto value = Element::Value(Locator::FindFor(findInformation));
10
+ StringHelper::CopyToUnmanagedString(value, theValue, maximumLength);
11
+ }
12
+
13
+ __declspec ( dllexport ) void Control_SetValue(const FindInformation& findInformation, const char* theValue) {
14
+ Element::SetValue(Locator::FindFor(findInformation), gcnew String(theValue));
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
+ };
@@ -0,0 +1,93 @@
1
+ #include "StdAfx.h"
2
+ #include "Locator.h"
3
+
4
+ Locator::Locator(AutomationElement^ automationElement)
5
+ {
6
+ _automationElement = automationElement;
7
+ }
8
+
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)
20
+ {
21
+ return Find(Subtree, conditions);
22
+ }
23
+
24
+ AutomationElementCollection^ Locator::Find(const UIAutomation::TreeScope scope, ...array<Condition^>^ conditions)
25
+ {
26
+ return _automationElement->FindAll(scope, SomethingOrEverything(conditions));
27
+ }
28
+
29
+ AutomationElement^ Locator::FindFirst(...array<Condition^>^ conditions)
30
+ {
31
+ return FindFirst(Subtree, conditions);
32
+ }
33
+
34
+ AutomationElement^ Locator::FindFirst(const UIAutomation::TreeScope scope, ...array<Condition^>^ conditions)
35
+ {
36
+ return _automationElement->FindFirst(scope, SomethingOrEverything(conditions));
37
+ }
38
+
39
+ AutomationElement^ Locator::Find(const FindInformation& findInformation)
40
+ {
41
+ auto scope = findInformation.onlySearchChildren ? Children : Subtree;
42
+
43
+ switch(findInformation.how) {
44
+ case Id:
45
+ {
46
+ auto searchCondition = gcnew PropertyCondition(AutomationElement::AutomationIdProperty, gcnew String(findInformation.data.stringData));
47
+ if( 0 == findInformation.index ) {
48
+ return FindFirst(scope, searchCondition);
49
+ }
50
+
51
+ return FindAt(scope, findInformation.index, searchCondition);
52
+ }
53
+ case Value:
54
+ {
55
+ auto searchCondition = gcnew PropertyCondition(AutomationElement::NameProperty, gcnew String(findInformation.data.stringData));
56
+
57
+ if( 0 == findInformation.index ) {
58
+ return FindFirst(scope, searchCondition);
59
+ }
60
+
61
+ return FindAt(scope, findInformation.index, searchCondition);
62
+ }
63
+ case Focus:
64
+ return AutomationElement::FocusedElement;
65
+ case ScreenPoint:
66
+ return AutomationElement::FromPoint(Point(findInformation.data.pointData[0], findInformation.data.pointData[1]));
67
+ case Handle:
68
+ return AutomationElement::FromHandle(IntPtr(findInformation.data.intData));
69
+ }
70
+
71
+ return nullptr;
72
+ }
73
+
74
+ AutomationElement^ Locator::FindAt(const int whichItem, ...array<Condition^>^ conditions)
75
+ {
76
+ return FindAt(Subtree, whichItem, conditions);
77
+ }
78
+
79
+ AutomationElement^ Locator::FindAt(const UIAutomation::TreeScope scope, const int whichItem, ...array<Condition^>^ conditions)
80
+ {
81
+ return Find(scope, conditions)[whichItem];
82
+ }
83
+
84
+ Condition^ Locator::SomethingOrEverything(...array<Condition^>^ conditions)
85
+ {
86
+ if( conditions->Length == 0 ) {
87
+ return Condition::TrueCondition;
88
+ } else if( conditions->Length == 1 ) {
89
+ return conditions[0];
90
+ }
91
+
92
+ return gcnew AndCondition(conditions);
93
+ }
@@ -0,0 +1,55 @@
1
+ #pragma once
2
+ using namespace System::Windows;
3
+ using namespace System::Windows::Automation;
4
+
5
+ ref class Locator
6
+ {
7
+ public:
8
+ static AutomationElement^ FindFor(const FindInformation& findInformation);
9
+
10
+ Locator(AutomationElement^ automationElement);
11
+ AutomationElement^ Find(const FindInformation& findInformation);
12
+ AutomationElementCollection^ Find(...array<Condition^>^ conditions);
13
+ AutomationElementCollection^ Find(const UIAutomation::TreeScope scope, ...array<Condition^>^ conditions);
14
+ AutomationElement^ FindFirst(...array<Condition^>^ conditions);
15
+ AutomationElement^ FindFirst(const UIAutomation::TreeScope scope, ...array<Condition^>^ conditions);
16
+ AutomationElement^ FindAt(const int whichItem, ...array<Condition^>^ conditions);
17
+ AutomationElement^ FindAt(const UIAutomation::TreeScope scope, const int whichItem, ...array<Condition^>^ conditions);
18
+
19
+ static property Condition^ IsSelectionItem {
20
+ Condition^ get() {
21
+ return gcnew PropertyCondition(AutomationElement::IsSelectionItemPatternAvailableProperty, true);
22
+ }
23
+ }
24
+
25
+ static property Condition^ IsTableItem {
26
+ Condition^ get() {
27
+ return gcnew PropertyCondition(AutomationElement::IsTableItemPatternAvailableProperty, true);
28
+ }
29
+ }
30
+
31
+ static property Condition^ IsDataItem {
32
+ Condition^ get() {
33
+ return gcnew PropertyCondition(AutomationElement::ControlTypeProperty, ControlType::DataItem);
34
+ }
35
+ }
36
+
37
+ static property Condition^ IsHeaderItem {
38
+ Condition^ get() {
39
+ return gcnew PropertyCondition(AutomationElement::ControlTypeProperty, ControlType::HeaderItem);
40
+ }
41
+ }
42
+
43
+ static property Condition^ IsListItem {
44
+ Condition^ get() {
45
+ return gcnew PropertyCondition(AutomationElement::ControlTypeProperty, ControlType::ListItem);
46
+ }
47
+ }
48
+
49
+ private:
50
+ static UIAutomation::TreeScope Subtree = UIAutomation::TreeScope::Subtree;
51
+ static UIAutomation::TreeScope Children = UIAutomation::TreeScope::Children;
52
+ AutomationElement^ _automationElement;
53
+ Condition^ SomethingOrEverything(...array<Condition^>^ conditions);
54
+ };
55
+
@@ -0,0 +1,75 @@
1
+ #include "StdAfx.h"
2
+ #include "MenuItemSelector.h"
3
+
4
+ using namespace std;
5
+
6
+ void MenuItemSelector::SelectMenuPath(const HWND windowHandle, list<const char*>& menuItems)
7
+ {
8
+ auto automationElement = AutomationElement::FromHandle(IntPtr(windowHandle));
9
+ auto foundMenuItem = FindMenuItem(automationElement, menuItems);
10
+ auto invokePattern = dynamic_cast<InvokePattern^>(foundMenuItem->GetCurrentPattern(InvokePattern::Pattern));
11
+ invokePattern->Invoke();
12
+ }
13
+
14
+ BOOL MenuItemSelector::MenuItemExists(const HWND windowHandle, list<const char*>& menuItems)
15
+ {
16
+ try {
17
+ auto automationElement = AutomationElement::FromHandle(IntPtr(windowHandle));
18
+ return FindMenuItem(automationElement, menuItems) != nullptr;
19
+ } catch(Exception^) {
20
+ return FALSE;
21
+ }
22
+ }
23
+
24
+ AutomationElement^ MenuItemSelector::FindMenuItem(AutomationElement^ rootElement, std::list<const char*>& menuItems)
25
+ {
26
+ auto foundMenuItem = rootElement;
27
+
28
+ for(list<const char*>::iterator menuItem = menuItems.begin(); menuItem != menuItems.end(); ++menuItem) {
29
+ foundMenuItem = GetNextMenuItem(foundMenuItem, gcnew String(*menuItem));
30
+ }
31
+
32
+ return foundMenuItem;
33
+ }
34
+
35
+ PropertyCondition^ MenuItemSelector::NameConditionFor(String^ name)
36
+ {
37
+ return gcnew PropertyCondition(AutomationElement::NameProperty, name);
38
+ }
39
+
40
+ AutomationElement^ MenuItemSelector::GetNextMenuItem(AutomationElement^ foundMenuItem, String^ nextMenu)
41
+ {
42
+ TryToExpand(AsExpandCollapse(foundMenuItem));
43
+ auto nextMenuItem = foundMenuItem->FindFirst(System::Windows::Automation::TreeScope::Subtree,
44
+ gcnew AndCondition(MenuItemControlType, NameConditionFor(nextMenu)));
45
+ if( nullptr == nextMenuItem ) {
46
+ throw gcnew Exception(String::Format("MenuItem with the text \"{0}\" does not exist", nextMenu));
47
+ }
48
+ return nextMenuItem;
49
+ }
50
+
51
+ ExpandCollapsePattern^ MenuItemSelector::AsExpandCollapse(AutomationElement^ foundMenuItem)
52
+ {
53
+ try
54
+ {
55
+ return dynamic_cast<ExpandCollapsePattern^>(foundMenuItem->GetCurrentPattern(ExpandCollapsePattern::Pattern));
56
+ }
57
+ catch(Exception^)
58
+ {
59
+ return nullptr;
60
+ }
61
+ }
62
+
63
+ void MenuItemSelector::TryToExpand(ExpandCollapsePattern^ expandCollapsePattern)
64
+ {
65
+ if (nullptr == expandCollapsePattern) return;
66
+
67
+ try
68
+ {
69
+ expandCollapsePattern->Expand();
70
+ }
71
+ catch(Exception^)
72
+ {
73
+ expandCollapsePattern->Expand();
74
+ }
75
+ }
@@ -0,0 +1,24 @@
1
+ #pragma once
2
+ #include "StringHelper.h"
3
+
4
+ using namespace System::Windows::Automation;
5
+
6
+ public ref class MenuItemSelector
7
+ {
8
+ public:
9
+ void SelectMenuPath(const HWND windowHandle, std::list<const char*>& menuItems);
10
+ BOOL MenuItemExists(const HWND windowHandle, std::list<const char*>& menuItems);
11
+
12
+ private:
13
+ AutomationElement^ FindMenuItem(AutomationElement^ rootElement, std::list<const char*>& menuItems);
14
+ PropertyCondition^ NameConditionFor(String^ name);
15
+ AutomationElement^ GetNextMenuItem(AutomationElement^ foundMenuItem, String^ nextMenu);
16
+ ExpandCollapsePattern^ AsExpandCollapse(AutomationElement^ foundMenuItem);
17
+ void TryToExpand(ExpandCollapsePattern^ expandCollapsePattern);
18
+
19
+ property PropertyCondition^ MenuItemControlType {
20
+ private:
21
+ PropertyCondition^ get() { return gcnew PropertyCondition(AutomationElement::ControlTypeProperty, ControlType::MenuItem); }
22
+ }
23
+ };
24
+
@@ -0,0 +1,62 @@
1
+ #include "stdafx.h"
2
+ #include "MenuItemSelector.h"
3
+
4
+ BOOL MenuItemExists(const HWND windowHandle, std::list<const char*>& menuItems);
5
+ void MenuSelectPath(const HWND windowHandle, char* errorInfo, const int errorInfoSize, std::list<const char*>& menuItems);
6
+
7
+ extern "C" {
8
+
9
+ #pragma managed(push, off)
10
+ __declspec ( dllexport ) void Menu_SelectPath(const HWND windowHandle, char* errorInfo, const int errorInfoSize, const char* arg0, ...) {
11
+ va_list arguments;
12
+ va_start(arguments, arg0);
13
+
14
+ std::list<const char*> menuItems;
15
+
16
+ const char* lastArgument = arg0;
17
+ while( NULL != lastArgument ) {
18
+ menuItems.push_back(lastArgument);
19
+ lastArgument = va_arg(arguments, const char*);
20
+ }
21
+ va_end(arguments);
22
+
23
+ MenuSelectPath(windowHandle, errorInfo, errorInfoSize, menuItems);
24
+ }
25
+ #pragma managed(pop)
26
+
27
+ #pragma managed(push, off)
28
+ __declspec ( dllexport ) BOOL Menu_ItemExists(const HWND windowHandle, const char* arg0, ...) {
29
+ va_list arguments;
30
+ va_start(arguments, arg0);
31
+
32
+ std::list<const char*> menuItems;
33
+
34
+ const char* lastArgument = arg0;
35
+ while( NULL != lastArgument ) {
36
+ menuItems.push_back(lastArgument);
37
+ lastArgument = va_arg(arguments, const char*);
38
+ }
39
+ va_end(arguments);
40
+
41
+ return MenuItemExists(windowHandle, menuItems);
42
+ }
43
+ #pragma managed(pop)
44
+ }
45
+
46
+ BOOL MenuItemExists(const HWND windowHandle, std::list<const char*>& menuItems)
47
+ {
48
+ auto menuSelector = gcnew MenuItemSelector();
49
+ return menuSelector->MenuItemExists(windowHandle, menuItems);
50
+ }
51
+
52
+ void MenuSelectPath(const HWND windowHandle, char* errorInfo, const int errorInfoSize, std::list<const char*>& menuItems)
53
+ {
54
+ try {
55
+ auto menuSelector = gcnew MenuItemSelector();
56
+ menuSelector->SelectMenuPath(windowHandle, menuItems);
57
+ } catch(Exception^ e) {
58
+ if( errorInfo ) {
59
+ StringHelper::CopyToUnmanagedString(e->ToString(), errorInfo, errorInfoSize);
60
+ }
61
+ }
62
+ }