rautomation 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -3
- data/History.rdoc +17 -0
- data/README.rdoc +2 -1
- data/Rakefile +23 -6
- data/VERSION +1 -1
- data/ext/IAccessibleDLL/Release/IAccessibleDLL.dll +0 -0
- data/ext/UiaDll/Release/UiaDll.dll +0 -0
- data/ext/UiaDll/UiaDll/{AutomatedComboBox.cpp → AutomatedSelectList.cpp} +22 -11
- data/ext/UiaDll/UiaDll/{AutomatedComboBox.h → AutomatedSelectList.h} +17 -4
- data/ext/UiaDll/UiaDll/AutomatedTable.cpp +55 -13
- data/ext/UiaDll/UiaDll/AutomatedTable.h +16 -3
- data/ext/UiaDll/UiaDll/AutomationControl.cpp +28 -0
- data/ext/UiaDll/UiaDll/AutomationControl.h +56 -0
- data/ext/UiaDll/UiaDll/AutomationFinder.cpp +57 -0
- data/ext/UiaDll/UiaDll/AutomationFinder.h +48 -0
- data/ext/UiaDll/UiaDll/ControlMethods.cpp +15 -0
- data/ext/UiaDll/UiaDll/MenuItemSelector.h +2 -0
- data/ext/UiaDll/UiaDll/MenuMethods.cpp +58 -0
- data/ext/UiaDll/UiaDll/SelectListMethods.cpp +37 -0
- data/ext/UiaDll/UiaDll/SelectionItem.cpp +10 -0
- data/ext/UiaDll/UiaDll/SelectionItem.h +21 -0
- data/ext/UiaDll/UiaDll/StringHelper.cpp +33 -2
- data/ext/UiaDll/UiaDll/StringHelper.h +6 -0
- data/ext/UiaDll/UiaDll/StringMethods.cpp +8 -0
- data/ext/UiaDll/UiaDll/TableMethods.cpp +76 -0
- data/ext/UiaDll/UiaDll/Toggle.cpp +2 -0
- data/ext/UiaDll/UiaDll/Toggle.h +22 -0
- data/ext/UiaDll/UiaDll/UiaDll.cpp +96 -327
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj +15 -4
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +91 -22
- data/ext/UiaDll/UiaDll/dllmain.cpp +1 -1
- data/ext/UiaDll/UiaDll/stdafx.h +38 -21
- data/ext/WindowsForms/Release/WindowsForms.exe +0 -0
- data/ext/WindowsForms/WindowsForms.sln +10 -0
- data/ext/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs +59 -0
- data/ext/WindowsForms/WindowsForms/AutomationHelpers/AutomationProvider.cs +91 -0
- data/ext/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +32 -10
- data/ext/WindowsForms/WindowsForms/MainFormWindow.cs +10 -0
- data/ext/WindowsForms/WindowsForms/WindowsForms.csproj +15 -6
- data/lib/rautomation/adapter/ms_uia.rb +1 -0
- data/lib/rautomation/adapter/ms_uia/checkbox.rb +2 -10
- data/lib/rautomation/adapter/ms_uia/constants.rb +1 -0
- data/lib/rautomation/adapter/ms_uia/control.rb +14 -67
- data/lib/rautomation/adapter/ms_uia/functions.rb +2 -18
- data/lib/rautomation/adapter/ms_uia/list_box.rb +5 -27
- data/lib/rautomation/adapter/ms_uia/list_item.rb +2 -29
- data/lib/rautomation/adapter/ms_uia/radio.rb +1 -1
- data/lib/rautomation/adapter/ms_uia/select_list.rb +5 -6
- data/lib/rautomation/adapter/ms_uia/table.rb +15 -50
- data/lib/rautomation/adapter/ms_uia/text_field.rb +1 -1
- data/lib/rautomation/adapter/ms_uia/uia_dll.rb +226 -58
- data/lib/rautomation/adapter/ms_uia/value_control.rb +21 -0
- data/lib/rautomation/adapter/ms_uia/window.rb +6 -104
- data/lib/rautomation/adapter/win_32/functions.rb +0 -23
- data/lib/rautomation/adapter/win_32/keys.rb +64 -61
- data/rautomation.gemspec +6 -1
- data/spec/adapter/autoit/mouse_spec.rb +1 -1
- data/spec/adapter/ms_uia/select_list_spec.rb +0 -21
- data/spec/adapter/ms_uia/table_spec.rb +13 -11
- data/spec/adapter/ms_uia/text_field_spec.rb +15 -8
- data/spec/adapter/ms_uia/value_control_spec.rb +11 -0
- data/spec/adapter/ms_uia/window_spec.rb +7 -1
- data/spec/adapter/win_32/mouse_spec.rb +1 -1
- data/spec/adapter/win_32/text_field_spec.rb +5 -5
- data/spec/adapter/win_32/window_spec.rb +1 -1
- data/spec/text_field_spec.rb +18 -23
- data/spec/window_spec.rb +1 -3
- metadata +45 -34
- data/ext/UiaDll/UiaDll/ToggleStateHelper.cpp +0 -33
@@ -79,24 +79,33 @@
|
|
79
79
|
<Reference Include="WindowsBase" />
|
80
80
|
</ItemGroup>
|
81
81
|
<ItemGroup>
|
82
|
-
<ClInclude Include="
|
82
|
+
<ClInclude Include="AutomatedSelectList.h" />
|
83
83
|
<ClInclude Include="AutomatedTable.h" />
|
84
84
|
<ClInclude Include="AutomationClicker.h" />
|
85
|
+
<ClInclude Include="AutomationControl.h" />
|
86
|
+
<ClInclude Include="AutomationFinder.h" />
|
85
87
|
<ClInclude Include="ExpandCollapseHelper.h" />
|
86
88
|
<ClInclude Include="globals.h" />
|
87
89
|
<ClInclude Include="MenuItemSelector.h" />
|
88
90
|
<ClInclude Include="resource.h" />
|
91
|
+
<ClInclude Include="SelectionItem.h" />
|
89
92
|
<ClInclude Include="Stdafx.h" />
|
90
93
|
<ClInclude Include="StringHelper.h" />
|
91
94
|
<ClInclude Include="targetver.h" />
|
92
|
-
<ClInclude Include="
|
95
|
+
<ClInclude Include="Toggle.h" />
|
93
96
|
<ClInclude Include="UiaDll.h" />
|
94
97
|
</ItemGroup>
|
95
98
|
<ItemGroup>
|
96
99
|
<ClCompile Include="AssemblyInfo.cpp" />
|
97
|
-
<ClCompile Include="
|
100
|
+
<ClCompile Include="AutomatedSelectList.cpp" />
|
98
101
|
<ClCompile Include="AutomatedTable.cpp" />
|
99
102
|
<ClCompile Include="AutomationClicker.cpp" />
|
103
|
+
<ClCompile Include="AutomationControl.cpp" />
|
104
|
+
<ClCompile Include="AutomationFinder.cpp" />
|
105
|
+
<ClCompile Include="ControlMethods.cpp" />
|
106
|
+
<ClCompile Include="MenuMethods.cpp" />
|
107
|
+
<ClCompile Include="SelectionItem.cpp" />
|
108
|
+
<ClCompile Include="SelectListMethods.cpp" />
|
100
109
|
<ClCompile Include="dllmain.cpp" />
|
101
110
|
<ClCompile Include="ExpandCollapseHelper.cpp" />
|
102
111
|
<ClCompile Include="MenuItemSelector.cpp" />
|
@@ -105,7 +114,9 @@
|
|
105
114
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
106
115
|
</ClCompile>
|
107
116
|
<ClCompile Include="StringHelper.cpp" />
|
108
|
-
<ClCompile Include="
|
117
|
+
<ClCompile Include="StringMethods.cpp" />
|
118
|
+
<ClCompile Include="TableMethods.cpp" />
|
119
|
+
<ClCompile Include="Toggle.cpp" />
|
109
120
|
<ClCompile Include="UiaDll.cpp" />
|
110
121
|
</ItemGroup>
|
111
122
|
<ItemGroup>
|
@@ -13,6 +13,42 @@
|
|
13
13
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
14
14
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
15
15
|
</Filter>
|
16
|
+
<Filter Include="Header Files\Helpers">
|
17
|
+
<UniqueIdentifier>{235d8022-1949-4a55-b1fd-af041c36744f}</UniqueIdentifier>
|
18
|
+
</Filter>
|
19
|
+
<Filter Include="Header Files\Table">
|
20
|
+
<UniqueIdentifier>{1d8355de-7c5c-4443-b063-cdb96cd03444}</UniqueIdentifier>
|
21
|
+
</Filter>
|
22
|
+
<Filter Include="Header Files\Menu">
|
23
|
+
<UniqueIdentifier>{f558a0f9-f67e-483f-86cf-a5f2ce6f1a93}</UniqueIdentifier>
|
24
|
+
</Filter>
|
25
|
+
<Filter Include="Source Files\Helpers">
|
26
|
+
<UniqueIdentifier>{0639f7bf-9510-4ad0-8032-064ba24fed5a}</UniqueIdentifier>
|
27
|
+
</Filter>
|
28
|
+
<Filter Include="Source Files\Menu">
|
29
|
+
<UniqueIdentifier>{ca87cbd9-97d0-41c0-b1d3-e0b4c6a3de8d}</UniqueIdentifier>
|
30
|
+
</Filter>
|
31
|
+
<Filter Include="Source Files\Table">
|
32
|
+
<UniqueIdentifier>{9f1663a8-aadc-46f8-8b88-b50196b59645}</UniqueIdentifier>
|
33
|
+
</Filter>
|
34
|
+
<Filter Include="Source Files\SelectList">
|
35
|
+
<UniqueIdentifier>{fe7c5a5a-36f1-4acb-9147-a32a4e168c5a}</UniqueIdentifier>
|
36
|
+
</Filter>
|
37
|
+
<Filter Include="Header Files\SelectList">
|
38
|
+
<UniqueIdentifier>{b94fabb6-af2d-4628-b91f-837e271293aa}</UniqueIdentifier>
|
39
|
+
</Filter>
|
40
|
+
<Filter Include="Header Files\Strings">
|
41
|
+
<UniqueIdentifier>{568b2839-5e30-4e34-91b0-a0e67f1c1672}</UniqueIdentifier>
|
42
|
+
</Filter>
|
43
|
+
<Filter Include="Source Files\Strings">
|
44
|
+
<UniqueIdentifier>{4059b959-0144-4a0e-8900-fbdef8bbe335}</UniqueIdentifier>
|
45
|
+
</Filter>
|
46
|
+
<Filter Include="Source Files\Control">
|
47
|
+
<UniqueIdentifier>{07c7f544-b01e-4f38-a4bb-adafe3b91fbd}</UniqueIdentifier>
|
48
|
+
</Filter>
|
49
|
+
<Filter Include="Header Files\Control">
|
50
|
+
<UniqueIdentifier>{90616ecb-ce19-48d6-88ac-a38a46e42687}</UniqueIdentifier>
|
51
|
+
</Filter>
|
16
52
|
</ItemGroup>
|
17
53
|
<ItemGroup>
|
18
54
|
<ClInclude Include="UiaDll.h">
|
@@ -30,25 +66,34 @@
|
|
30
66
|
<ClInclude Include="targetver.h">
|
31
67
|
<Filter>Header Files</Filter>
|
32
68
|
</ClInclude>
|
33
|
-
<ClInclude Include="
|
34
|
-
<Filter>Header Files</Filter>
|
69
|
+
<ClInclude Include="ExpandCollapseHelper.h">
|
70
|
+
<Filter>Header Files\Helpers</Filter>
|
35
71
|
</ClInclude>
|
36
|
-
<ClInclude Include="
|
37
|
-
<Filter>Header Files</Filter>
|
72
|
+
<ClInclude Include="AutomatedTable.h">
|
73
|
+
<Filter>Header Files\Table</Filter>
|
74
|
+
</ClInclude>
|
75
|
+
<ClInclude Include="AutomationClicker.h">
|
76
|
+
<Filter>Header Files\Helpers</Filter>
|
77
|
+
</ClInclude>
|
78
|
+
<ClInclude Include="AutomationFinder.h">
|
79
|
+
<Filter>Header Files\Helpers</Filter>
|
38
80
|
</ClInclude>
|
39
81
|
<ClInclude Include="MenuItemSelector.h">
|
40
|
-
<Filter>Header Files</Filter>
|
82
|
+
<Filter>Header Files\Menu</Filter>
|
83
|
+
</ClInclude>
|
84
|
+
<ClInclude Include="AutomatedSelectList.h">
|
85
|
+
<Filter>Header Files\SelectList</Filter>
|
41
86
|
</ClInclude>
|
42
87
|
<ClInclude Include="StringHelper.h">
|
43
|
-
<Filter>Header Files</Filter>
|
88
|
+
<Filter>Header Files\Strings</Filter>
|
44
89
|
</ClInclude>
|
45
|
-
<ClInclude Include="
|
46
|
-
<Filter>Header Files</Filter>
|
90
|
+
<ClInclude Include="AutomationControl.h">
|
91
|
+
<Filter>Header Files\Control</Filter>
|
47
92
|
</ClInclude>
|
48
|
-
<ClInclude Include="
|
49
|
-
<Filter>Header Files</Filter>
|
93
|
+
<ClInclude Include="Toggle.h">
|
94
|
+
<Filter>Header Files\Control</Filter>
|
50
95
|
</ClInclude>
|
51
|
-
<ClInclude Include="
|
96
|
+
<ClInclude Include="SelectionItem.h">
|
52
97
|
<Filter>Header Files</Filter>
|
53
98
|
</ClInclude>
|
54
99
|
</ItemGroup>
|
@@ -65,25 +110,49 @@
|
|
65
110
|
<ClCompile Include="dllmain.cpp">
|
66
111
|
<Filter>Source Files</Filter>
|
67
112
|
</ClCompile>
|
68
|
-
<ClCompile Include="
|
69
|
-
<Filter>Source Files</Filter>
|
113
|
+
<ClCompile Include="AutomatedTable.cpp">
|
114
|
+
<Filter>Source Files\Table</Filter>
|
70
115
|
</ClCompile>
|
71
|
-
<ClCompile Include="
|
72
|
-
<Filter>Source Files</Filter>
|
116
|
+
<ClCompile Include="AutomationClicker.cpp">
|
117
|
+
<Filter>Source Files\Helpers</Filter>
|
118
|
+
</ClCompile>
|
119
|
+
<ClCompile Include="AutomationFinder.cpp">
|
120
|
+
<Filter>Source Files\Helpers</Filter>
|
121
|
+
</ClCompile>
|
122
|
+
<ClCompile Include="ExpandCollapseHelper.cpp">
|
123
|
+
<Filter>Source Files\Helpers</Filter>
|
73
124
|
</ClCompile>
|
74
125
|
<ClCompile Include="MenuItemSelector.cpp">
|
75
|
-
<Filter>Source Files</Filter>
|
126
|
+
<Filter>Source Files\Menu</Filter>
|
127
|
+
</ClCompile>
|
128
|
+
<ClCompile Include="TableMethods.cpp">
|
129
|
+
<Filter>Source Files\Table</Filter>
|
130
|
+
</ClCompile>
|
131
|
+
<ClCompile Include="AutomatedSelectList.cpp">
|
132
|
+
<Filter>Source Files\SelectList</Filter>
|
133
|
+
</ClCompile>
|
134
|
+
<ClCompile Include="SelectListMethods.cpp">
|
135
|
+
<Filter>Source Files\SelectList</Filter>
|
136
|
+
</ClCompile>
|
137
|
+
<ClCompile Include="MenuMethods.cpp">
|
138
|
+
<Filter>Source Files\Menu</Filter>
|
76
139
|
</ClCompile>
|
77
140
|
<ClCompile Include="StringHelper.cpp">
|
78
|
-
<Filter>Source Files</Filter>
|
141
|
+
<Filter>Source Files\Strings</Filter>
|
79
142
|
</ClCompile>
|
80
|
-
<ClCompile Include="
|
81
|
-
<Filter>Source Files</Filter>
|
143
|
+
<ClCompile Include="StringMethods.cpp">
|
144
|
+
<Filter>Source Files\Strings</Filter>
|
82
145
|
</ClCompile>
|
83
|
-
<ClCompile Include="
|
84
|
-
<Filter>Source Files</Filter>
|
146
|
+
<ClCompile Include="AutomationControl.cpp">
|
147
|
+
<Filter>Source Files\Control</Filter>
|
85
148
|
</ClCompile>
|
86
|
-
<ClCompile Include="
|
149
|
+
<ClCompile Include="ControlMethods.cpp">
|
150
|
+
<Filter>Source Files\Control</Filter>
|
151
|
+
</ClCompile>
|
152
|
+
<ClCompile Include="Toggle.cpp">
|
153
|
+
<Filter>Source Files\Control</Filter>
|
154
|
+
</ClCompile>
|
155
|
+
<ClCompile Include="SelectionItem.cpp">
|
87
156
|
<Filter>Source Files</Filter>
|
88
157
|
</ClCompile>
|
89
158
|
</ItemGroup>
|
@@ -6,7 +6,7 @@ IUIAutomation *pAutomation ;
|
|
6
6
|
IUIAutomation* getGlobalIUIAutomation() {
|
7
7
|
if( NULL == pAutomation ) {
|
8
8
|
HRESULT hr ;
|
9
|
-
hr =
|
9
|
+
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED) ;
|
10
10
|
if (FAILED(hr)) {
|
11
11
|
printf("UiaDll: CoInitialize failed. hr = 0x%x", hr) ;
|
12
12
|
return NULL;
|
data/ext/UiaDll/UiaDll/stdafx.h
CHANGED
@@ -1,24 +1,41 @@
|
|
1
|
-
// stdafx.h : include file for standard system include files,
|
2
|
-
// or project specific include files that are used frequently, but
|
3
|
-
// are changed infrequently
|
4
|
-
//
|
5
|
-
|
6
|
-
#pragma once
|
7
|
-
|
8
|
-
#include "targetver.h"
|
9
|
-
|
10
|
-
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
11
|
-
// Windows Header Files:
|
12
|
-
#include <windows.h>
|
13
|
-
#include <ObjBase.h>
|
14
|
-
#include <UIAutomation.h>
|
15
|
-
#include <comutil.h>
|
16
|
-
|
17
|
-
#include <list>
|
18
|
-
|
19
|
-
#include "globals.h"
|
20
|
-
|
1
|
+
// stdafx.h : include file for standard system include files,
|
2
|
+
// or project specific include files that are used frequently, but
|
3
|
+
// are changed infrequently
|
4
|
+
//
|
5
|
+
|
6
|
+
#pragma once
|
7
|
+
|
8
|
+
#include "targetver.h"
|
9
|
+
|
10
|
+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
11
|
+
// Windows Header Files:
|
12
|
+
#include <windows.h>
|
13
|
+
#include <ObjBase.h>
|
14
|
+
#include <UIAutomation.h>
|
15
|
+
#include <comutil.h>
|
16
|
+
|
17
|
+
#include <list>
|
18
|
+
|
19
|
+
#include "globals.h"
|
20
|
+
|
21
21
|
using namespace System;
|
22
22
|
using namespace System::Runtime::InteropServices;
|
23
23
|
|
24
|
-
|
24
|
+
typedef enum {
|
25
|
+
Handle = 1,
|
26
|
+
Id,
|
27
|
+
Value,
|
28
|
+
Focus,
|
29
|
+
ScreenPoint
|
30
|
+
} FindMethod;
|
31
|
+
|
32
|
+
typedef struct _FindInformation {
|
33
|
+
HWND rootWindow;
|
34
|
+
int index;
|
35
|
+
FindMethod how;
|
36
|
+
union {
|
37
|
+
char stringData[256];
|
38
|
+
int intData;
|
39
|
+
int pointData[2];
|
40
|
+
} data;
|
41
|
+
} FindInformation, *LPFindInformation;
|
Binary file
|
@@ -5,12 +5,22 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsForms", "WindowsForm
|
|
5
5
|
EndProject
|
6
6
|
Global
|
7
7
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
8
|
+
Debug|Any CPU = Debug|Any CPU
|
9
|
+
Debug|Mixed Platforms = Debug|Mixed Platforms
|
8
10
|
Debug|x86 = Debug|x86
|
11
|
+
Release|Any CPU = Release|Any CPU
|
12
|
+
Release|Mixed Platforms = Release|Mixed Platforms
|
9
13
|
Release|x86 = Release|x86
|
10
14
|
EndGlobalSection
|
11
15
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
16
|
+
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Debug|Any CPU.ActiveCfg = Debug|x86
|
17
|
+
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
18
|
+
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
12
19
|
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Debug|x86.ActiveCfg = Debug|x86
|
13
20
|
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Debug|x86.Build.0 = Debug|x86
|
21
|
+
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Release|Any CPU.ActiveCfg = Release|x86
|
22
|
+
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
23
|
+
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Release|Mixed Platforms.Build.0 = Release|x86
|
14
24
|
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Release|x86.ActiveCfg = Release|x86
|
15
25
|
{79C33EDA-58C4-41EF-93DC-BA679895BD43}.Release|x86.Build.0 = Release|x86
|
16
26
|
EndGlobalSection
|
@@ -0,0 +1,59 @@
|
|
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
|
+
}
|
@@ -0,0 +1,91 @@
|
|
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
|
+
}
|