├── .gitattributes
├── .gitignore
├── GitVersionConfig.yaml
├── LICENSE.txt
├── Libs
├── Interop.UIAutomationClient.dll
└── Interop.UIAutomationClient.txt
├── README.md
├── UIAComWrapper.ncrunchsolution
├── UIAComWrapperX.sln
├── UiaComWrapperX
├── AnnotationPattern.cs
├── Automation.cs
├── AutomationElement.cs
├── AutomationElementCollection.cs
├── AutomationInteropProvider.cs
├── AutomationTypes.cs
├── BasePattern.cs
├── CacheRequest.cs
├── ClientEventList.cs
├── ClientSideProviders.cs
├── Conditions.cs
├── DockPattern.cs
├── DragPattern.cs
├── DropTargetPattern.cs
├── Events.cs
├── ExpandCollapsePattern.cs
├── GridPattern.cs
├── InternalSchema.cs
├── InternalTypes.cs
├── InvokePattern.cs
├── LegacyIAccessiblePattern.cs
├── MultipleViewPattern.cs
├── ObjectModelPattern.cs
├── Properties
│ └── AssemblyInfo.cs
├── ProviderInterfaces.cs
├── ScrollPattern.cs
├── SelectionPattern.cs
├── SpreadsheetPattern.cs
├── StringTable.Designer.cs
├── StringTable.resx
├── StylesPattern.cs
├── SynchronizedInput.cs
├── TablePattern.cs
├── TextChildPattern.cs
├── TextPattern.cs
├── TextRange.cs
├── TextTypes.cs
├── TogglePattern.cs
├── TransformPattern.cs
├── TreeWalker.cs
├── UIAComWrapper.ncrunchproject
├── UIAComWrapper.snk
├── UIAComWrapperX.csproj
├── UIAComWrapperX.nuspec
├── UiaCoreProviderApi.cs
├── Utility.cs
├── ValuePattern.cs
├── VirtualizedPatterns.cs
├── WindowPattern.cs
└── install.ps1
├── UiaComWrapperXTests
├── AppHost.cs
├── AutomationElementCollectionTest.cs
├── AutomationElementTest.cs
├── CacheRequestTest.cs
├── ClientSideProvidersTest.cs
├── ConditionTest.cs
├── EventTests.cs
├── ExplorerHost.cs
├── ExplorerTargetTests.cs
├── Internal_ObjectConverterTest.cs
├── MockPatternTest.cs
├── Properties
│ └── AssemblyInfo.cs
├── ScenarioTests.cs
├── Test References
│ └── test.xps
├── TreeWalkerTest.cs
├── UIAComWrapper.snk
├── UIAComWrapperTests.ncrunchproject
├── UIAComWrapperXTests.csproj
├── packages.config
└── test.xps
└── appveyor.yml
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Normalise endings to CRLF
13 | *.cs eol=crlf
14 | *.xml eol=crlf
15 | *.xaml eol=crlf
16 | *.xsl eol=crlf
17 | *.xsd eol=crlf
18 | *.cshtml eol=crlf
19 | *.css eol=crlf
20 | *.js eol=crlf
21 | *.txt eol=crlf
22 | *.config eol=crlf
23 | *.sql eol=crlf
24 | *.sln eol=crlf
25 | *.csproj eol=crlf
26 | *.vbproj eol=crlf
27 | *.fsproj eol=crlf
28 | *.dbproj eol=crlf
29 | *.nunit eol=crlf
30 | *.html eol=crlf
31 | *.md eol=crlf
32 | *.proj eol=crlf
33 | *.bat eol=crlf
34 | *.cmd eol=crlf
35 | *.nuspec eol=crlf
36 | *.targets eol=crlf
37 | *.conf eol=crlf
38 | *.manifest eol=crlf
39 | *.ps1 eol=crlf
40 | *.resx eol=crlf
41 | *.asax eol=crlf
42 | *.aspx eol=crlf
43 | *.ncrunchproject eol=crlf
44 | *.ncrunchsolution eol=crlf
45 | *.msbuild eol=crlf
46 | *.template eol=crlf
47 | *.settings eol=crlf
48 | *.java eol=crlf
49 | .gitattributes eol=crlf
50 | .classpath eol=crlf
51 | .project eol=crlf
52 |
53 | # Standard to msysgit
54 | *.doc diff=astextplain
55 | *.DOC diff=astextplain
56 | *.docx diff=astextplain
57 | *.DOCX diff=astextplain
58 | *.dot diff=astextplain
59 | *.DOT diff=astextplain
60 | *.pdf diff=astextplain
61 | *.PDF diff=astextplain
62 | *.rtf diff=astextplain
63 | *.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | ## Ignore Visual Studio temporary files, build results, and
6 | ## files generated by popular Visual Studio add-ons.
7 |
8 | # User-specific files
9 | *.suo
10 | *.user
11 | *.sln.docstates
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Rr]elease/
16 | x64/
17 | *_i.c
18 | *_p.c
19 | *.ilk
20 | *.meta
21 | *.obj
22 | *.pch
23 | *.pdb
24 | *.pgc
25 | *.pgd
26 | *.rsp
27 | *.sbr
28 | *.tlb
29 | *.tli
30 | *.tlh
31 | *.tmp
32 | *.vspscc
33 | *.vssscc
34 | .builds
35 |
36 | # Visual C++ cache files
37 | ipch/
38 | *.aps
39 | *.ncb
40 | *.opensdf
41 | *.sdf
42 |
43 | # Visual Studio profiler
44 | *.psess
45 | *.vsp
46 |
47 | # Guidance Automation Toolkit
48 | *.gpState
49 |
50 | # ReSharper is a .NET coding add-in
51 | _ReSharper*
52 | # TeamCity is a build server addin for VS
53 | _TeamCity.*
54 |
55 | # NCrunch
56 | .*crunch*.local.xml
57 |
58 | # Installshield output folder
59 | [Ee]xpress
60 |
61 | # DocProject is a documentation generator add-in
62 | DocProject/buildhelp/
63 | DocProject/Help/*.HxT
64 | DocProject/Help/*.HxC
65 | DocProject/Help/*.hhc
66 | DocProject/Help/*.hhk
67 | DocProject/Help/*.hhp
68 | DocProject/Help/Html2
69 | DocProject/Help/html
70 |
71 | # Click-Once directory
72 | publish
73 |
74 | # Publish Web Output
75 | *.Publish.xml
76 |
77 | # Others
78 | [Bb]in
79 | [Oo]bj
80 | sql
81 | TestResults
82 | [Tt]est[Rr]esult*
83 | *.Cache
84 | ClientBin
85 | [Ss]tyle[Cc]op.*
86 | ~$*
87 | *.dbmdl
88 | *.orig
89 | Generated_Code #added for RIA/Silverlight projects
90 |
91 | # Backup & report files from converting an old project file to a newer
92 | # Visual Studio version. Backup files are not needed, because we have git ;-)
93 | _UpgradeReport_Files/
94 | Backup*/
95 | UpgradeLog*.XML
96 |
97 | # NuGet temporary packages folder
98 | packages
99 |
100 | # any logs
101 | *.log
102 |
103 | Thumbs.db
104 | .vs/UIAComWrapperX/v15/Server/sqlite3/db.lock
105 | .vs/UIAComWrapperX/v15/Server/sqlite3/storage.ide
106 | .vs/UIAComWrapperX/v15/Server/sqlite3/storage.ide-shm
107 | .vs/UIAComWrapperX/v15/Server/sqlite3/storage.ide-wal
108 | .vs/slnx.sqlite
109 | .vs/VSWorkspaceState.json
110 |
--------------------------------------------------------------------------------
/GitVersionConfig.yaml:
--------------------------------------------------------------------------------
1 | assembly-versioning-scheme: MajorMinor
2 | mode: ContinuousDelivery
3 | next-version: 1.2.0
4 | branches: {}
5 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Microsoft Public License (Ms-PL)
2 |
3 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
4 |
5 | 1. Definitions
6 |
7 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
8 |
9 | A "contribution" is the original software, or any additions or changes to the software.
10 |
11 | A "contributor" is any person that distributes its contribution under this license.
12 |
13 | "Licensed patents" are a contributor's patent claims that read directly on its contribution.
14 |
15 | 2. Grant of Rights
16 |
17 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
18 |
19 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
20 |
21 | 3. Conditions and Limitations
22 |
23 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
24 |
25 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
26 |
27 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
28 |
29 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
30 |
31 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
32 |
--------------------------------------------------------------------------------
/Libs/Interop.UIAutomationClient.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/technoscavenger/UIAComWrapperX/94171c31c78386b5180e347cfc7baae1f5d25b12/Libs/Interop.UIAutomationClient.dll
--------------------------------------------------------------------------------
/Libs/Interop.UIAutomationClient.txt:
--------------------------------------------------------------------------------
1 | From (VS2015) C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | UIAComWrapperX
2 | =============
3 |
4 | [](https://ci.appveyor.com/project/ivan-danilov/uiacomwrapper/branch/master)
5 | [](https://ci.appveyor.com/project/ivan-danilov/UiaComWrapper/branch/master)
6 |
7 | The UI Automation COM-to-.NET Adapter makes it possible to use the new Windows Automation API 3.0 COM interfaces, with their improved reliability and performance, while still using the same System.Windows.Automation classes as in earlier versions of UI Automation
8 |
9 | Changes
10 | -------
11 | ### v1.1.0.15
12 | - Update Interop.UIAutomationClient.dll to VS2015
13 | ### v1.1.0.14
14 | - added source indexing with [GitLink](https://github.com/GitTools/GitLink). Makes issue debugging much easier as stepping into UIAComWrapper code in VS automatically downloads proper source code from GitHub.
--------------------------------------------------------------------------------
/UIAComWrapper.ncrunchsolution:
--------------------------------------------------------------------------------
1 |
2 | 1
3 | True
4 | false
5 | true
6 | UseDynamicAnalysis
7 | UseStaticAnalysis
8 | UseStaticAnalysis
9 | UseStaticAnalysis
10 | Run all tests automatically:BFRydWU=;Run all tests manually:BUZhbHNl;Run impacted tests automatically, others manually (experimental!):CklzSW1wYWN0ZWQ=;Run pinned tests automatically, others manually:CElzUGlubmVk
11 |
12 |
13 |
--------------------------------------------------------------------------------
/UIAComWrapperX.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.136
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIAComWrapperX", "UiaComWrapperX\UIAComWrapperX.csproj", "{1DD63894-DBB9-40EF-BFF2-55624CB285AF}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIAComWrapperXTests", "UiaComWrapperXTests\UIAComWrapperXTests.csproj", "{5BD04451-8FAC-475A-BD33-6FE2DD59FEE3}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {1DD63894-DBB9-40EF-BFF2-55624CB285AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {1DD63894-DBB9-40EF-BFF2-55624CB285AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {1DD63894-DBB9-40EF-BFF2-55624CB285AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {1DD63894-DBB9-40EF-BFF2-55624CB285AF}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {5BD04451-8FAC-475A-BD33-6FE2DD59FEE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {5BD04451-8FAC-475A-BD33-6FE2DD59FEE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {5BD04451-8FAC-475A-BD33-6FE2DD59FEE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {5BD04451-8FAC-475A-BD33-6FE2DD59FEE3}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {5C361FCA-6291-4EBB-A6DA-2FA0041B238D}
30 | EndGlobalSection
31 | GlobalSection(TestCaseManagementSettings) = postSolution
32 | CategoryFile = UIAComWrapper3.vsmdi
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/UiaComWrapperX/AnnotationPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 | using System;
8 | using System.Collections;
9 | using System.Diagnostics;
10 | using System.Runtime.InteropServices;
11 | using UIAComWrapperInternal;
12 |
13 | namespace System.Windows.Automation
14 | {
15 | public class AnnotationPattern : BasePattern
16 | {
17 |
18 | private UIAutomationClient.IUIAutomationAnnotationPattern _pattern;
19 | public static readonly AutomationProperty AnnotationTypeIdProperty = AnnotationPatternIdentifiers.AnnotationTypeIdProperty;
20 | public static readonly AutomationProperty AnnotationTypeNameProperty = AnnotationPatternIdentifiers.AnnotationTypeNameProperty;
21 | public static readonly AutomationProperty AuthorProperty = AnnotationPatternIdentifiers.AuthorProperty;
22 | public static readonly AutomationProperty DateTimeProperty = AnnotationPatternIdentifiers.DateTimeProperty;
23 | public static readonly AutomationProperty TargetProperty = AnnotationPatternIdentifiers.TargetProperty;
24 | public static readonly AutomationPattern Pattern = AnnotationPatternIdentifiers.Pattern;
25 |
26 |
27 | private AnnotationPattern(AutomationElement el, UIAutomationClient.IUIAutomationAnnotationPattern pattern, bool cached)
28 | : base(el, cached)
29 | {
30 | Debug.Assert(pattern != null);
31 | this._pattern = pattern;
32 | }
33 |
34 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
35 | {
36 | return (pattern == null) ? null : new AnnotationPattern(el, (UIAutomationClient.IUIAutomationAnnotationPattern)pattern, cached);
37 | }
38 |
39 | public AnnotationPatternInformation Cached
40 | {
41 | get
42 | {
43 | Utility.ValidateCached(this._cached);
44 | return new AnnotationPatternInformation(this._el, true);
45 | }
46 | }
47 |
48 | public AnnotationPatternInformation Current
49 | {
50 | get
51 | {
52 | return new AnnotationPatternInformation(this._el, false);
53 | }
54 | }
55 |
56 |
57 | [StructLayout(LayoutKind.Sequential)]
58 | public struct AnnotationPatternInformation
59 | {
60 | private AutomationElement _el;
61 | private bool _isCached;
62 | internal AnnotationPatternInformation(AutomationElement element, bool isCached)
63 | {
64 | this._el = element;
65 | this._isCached = isCached;
66 | }
67 |
68 | public AnnotationType AnnotationTypeId
69 | {
70 | get
71 | {
72 | return (AnnotationType)this._el.GetCurrentPropertyValue(AnnotationPattern.AnnotationTypeIdProperty, _isCached);
73 | }
74 | }
75 |
76 | public string AnnotationTypeName
77 | {
78 | get
79 | {
80 | return (string)this._el.GetCurrentPropertyValue(AnnotationPattern.AnnotationTypeNameProperty, _isCached);
81 | }
82 | }
83 |
84 | public string Author
85 | {
86 | get
87 | {
88 | return (string)this._el.GetCurrentPropertyValue(AnnotationPattern.AuthorProperty, _isCached);
89 | }
90 | }
91 |
92 | public string DateTime
93 | {
94 | get
95 | {
96 | return (string)this._el.GetCurrentPropertyValue(AnnotationPattern.DateTimeProperty, _isCached);
97 | }
98 | }
99 |
100 | public AutomationElement Target
101 | {
102 | get
103 | {
104 | return (AutomationElement)this._el.GetCurrentPropertyValue(AnnotationPattern.TargetProperty, _isCached);
105 | }
106 | }
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/UiaComWrapperX/AutomationElementCollection.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Diagnostics;
10 | using System.Collections;
11 | using UIAComWrapperInternal;
12 |
13 | namespace System.Windows.Automation
14 | {
15 | public class AutomationElementCollection : ICollection, IEnumerable
16 | {
17 | private UIAutomationClient.IUIAutomationElementArray _obj;
18 |
19 | internal AutomationElementCollection(UIAutomationClient.IUIAutomationElementArray obj)
20 | {
21 | Debug.Assert(obj != null);
22 | this._obj = obj;
23 | }
24 |
25 | internal static AutomationElementCollection Wrap(UIAutomationClient.IUIAutomationElementArray obj)
26 | {
27 | return (obj == null) ? null : new AutomationElementCollection(obj);
28 | }
29 |
30 | public virtual void CopyTo(Array array, int index)
31 | {
32 | int cElem = this._obj.Length;
33 | for (int i = 0; i < cElem; ++i)
34 | {
35 | array.SetValue(this[i], i + index);
36 | }
37 | }
38 |
39 | public void CopyTo(AutomationElement[] array, int index)
40 | {
41 | int cElem = this._obj.Length;
42 | for (int i = 0; i < cElem; ++i)
43 | {
44 | array.SetValue(this[i], i + index);
45 | }
46 | }
47 |
48 | public IEnumerator GetEnumerator()
49 | {
50 | return new AutomationElementCollectionEnumerator(this._obj);
51 | }
52 |
53 | public int Count
54 | {
55 | get
56 | {
57 | return this._obj.Length;
58 | }
59 | }
60 |
61 | public virtual bool IsSynchronized
62 | {
63 | get
64 | {
65 | return false;
66 | }
67 | }
68 |
69 | public AutomationElement this[int index]
70 | {
71 | get
72 | {
73 | return AutomationElement.Wrap(this._obj.GetElement(index));
74 | }
75 | }
76 |
77 | public virtual object SyncRoot
78 | {
79 | get
80 | {
81 | return this;
82 | }
83 | }
84 | }
85 |
86 | public class AutomationElementCollectionEnumerator : IEnumerator
87 | {
88 | private UIAutomationClient.IUIAutomationElementArray _obj;
89 | private int _index = -1;
90 | private int _cElem;
91 |
92 | #region IEnumerator Members
93 |
94 | internal AutomationElementCollectionEnumerator(UIAutomationClient.IUIAutomationElementArray obj)
95 | {
96 | Debug.Assert(obj != null);
97 | this._obj = obj;
98 | this._cElem = obj.Length;
99 | }
100 |
101 | public object Current
102 | {
103 | get
104 | {
105 | return AutomationElement.Wrap(this._obj.GetElement(this._index));
106 | }
107 | }
108 |
109 | public bool MoveNext()
110 | {
111 | if (this._index < (this._cElem - 1))
112 | {
113 | ++this._index;
114 | return true;
115 | }
116 | else
117 | {
118 | return false;
119 | }
120 | }
121 |
122 | public void Reset()
123 | {
124 | this._index = -1;
125 | }
126 |
127 | #endregion
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/UiaComWrapperX/AutomationInteropProvider.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Runtime.InteropServices;
10 | using UIAComWrapperInternal;
11 | using UIAutomationClient;
12 |
13 | namespace System.Windows.Automation.Providers
14 | {
15 | public static class AutomationInteropProvider
16 | {
17 | // Constants
18 | public const int AppendRuntimeId = 3;
19 | public const int InvalidateLimit = 20;
20 | public const int RootObjectId = -25;
21 |
22 | public static IRawElementProviderSimple HostProviderFromHandle(IntPtr hwnd)
23 | {
24 | Utility.ValidateArgument(hwnd != IntPtr.Zero, "HWND must not be null");
25 | return UiaCoreProviderApi.UiaHostProviderFromHwnd(hwnd);
26 | }
27 |
28 | public static void RaiseAutomationEvent(AutomationEvent eventId, IRawElementProviderSimple provider, AutomationEventArgs e)
29 | {
30 | Utility.ValidateArgumentNonNull(eventId, "eventId");
31 | Utility.ValidateArgumentNonNull(provider, "provider");
32 | Utility.ValidateArgumentNonNull(e, "e");
33 | if (e.EventId == AutomationElementIdentifiers.AsyncContentLoadedEvent)
34 | {
35 | AsyncContentLoadedEventArgs args = e as AsyncContentLoadedEventArgs;
36 | if (args == null)
37 | {
38 | throw new ArgumentException("e");
39 | }
40 | UiaCoreProviderApi.UiaRaiseAsyncContentLoadedEvent(provider, args.AsyncContentLoadedState, args.PercentComplete);
41 | }
42 | else
43 | {
44 | if ((e.EventId == WindowPatternIdentifiers.WindowClosedEvent) && !(e is WindowClosedEventArgs))
45 | {
46 | throw new ArgumentException("e");
47 | }
48 | UiaCoreProviderApi.UiaRaiseAutomationEvent(provider, eventId.Id);
49 | }
50 | }
51 |
52 | public static void RaiseAutomationPropertyChangedEvent(IRawElementProviderSimple element, AutomationPropertyChangedEventArgs e)
53 | {
54 | Utility.ValidateArgumentNonNull(element, "element");
55 | Utility.ValidateArgumentNonNull(e, "e");
56 | UiaCoreProviderApi.UiaRaiseAutomationPropertyChangedEvent(element, e.Property.Id, e.OldValue, e.NewValue);
57 | }
58 |
59 | public static void RaiseStructureChangedEvent(IRawElementProviderSimple provider, StructureChangedEventArgs e)
60 | {
61 | Utility.ValidateArgumentNonNull(provider, "provider");
62 | Utility.ValidateArgumentNonNull(e, "e");
63 | UiaCoreProviderApi.UiaRaiseStructureChangedEvent(provider, (UIAutomationClient.StructureChangeType)e.StructureChangeType, e.GetRuntimeId());
64 | }
65 |
66 | public static IntPtr ReturnRawElementProvider(IntPtr hwnd, IntPtr wParam, IntPtr lParam, IRawElementProviderSimple el)
67 | {
68 | Utility.ValidateArgument(hwnd != IntPtr.Zero, "HWND must not be null");
69 | Utility.ValidateArgumentNonNull(el, "el");
70 | return UiaCoreProviderApi.UiaReturnRawElementProvider(hwnd, wParam, lParam, el);
71 | }
72 |
73 | public static bool ClientsAreListening
74 | {
75 | get
76 | {
77 | return UiaCoreProviderApi.UiaClientsAreListening();
78 | }
79 | }
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/UiaComWrapperX/BasePattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Diagnostics;
10 |
11 | namespace System.Windows.Automation
12 | {
13 | public class BasePattern
14 | {
15 |
16 | internal AutomationElement _el;
17 | internal bool _cached;
18 |
19 |
20 | internal BasePattern(AutomationElement el, bool cached)
21 | {
22 | Debug.Assert(el != null);
23 | this._el = el;
24 | this._cached = cached;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/UiaComWrapperX/CacheRequest.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using UIAComWrapperInternal;
12 |
13 | namespace System.Windows.Automation
14 | {
15 | public sealed class CacheRequest
16 | {
17 |
18 | private UIAutomationClient.IUIAutomationCacheRequest _obj;
19 | private object _lock;
20 | private int _cRef;
21 | [ThreadStatic]
22 | private static Stack _cacheStack;
23 | internal static readonly CacheRequest DefaultCacheRequest = new CacheRequest();
24 |
25 |
26 | internal CacheRequest(UIAutomationClient.IUIAutomationCacheRequest obj)
27 | {
28 | Debug.Assert(obj != null);
29 | this._obj = obj;
30 | this._lock = new object();
31 | }
32 |
33 | public CacheRequest()
34 | {
35 | this._obj = Automation.Factory.CreateCacheRequest();
36 | this._lock = new object();
37 | }
38 |
39 | public IDisposable Activate()
40 | {
41 | this.Push();
42 | return new CacheRequestActivation(this);
43 | }
44 |
45 | public void Add(AutomationPattern pattern)
46 | {
47 | Utility.ValidateArgumentNonNull(pattern, "pattern");
48 | lock (this._lock)
49 | {
50 | this.CheckAccess();
51 | this._obj.AddPattern(pattern.Id);
52 | }
53 | }
54 |
55 | public void Add(AutomationProperty property)
56 | {
57 | Utility.ValidateArgumentNonNull(property, "property");
58 | lock (this._lock)
59 | {
60 | this.CheckAccess();
61 | this._obj.AddProperty(property.Id);
62 | }
63 | }
64 |
65 | private void CheckAccess()
66 | {
67 | if ((this._cRef != 0) || (this == DefaultCacheRequest))
68 | {
69 | throw new InvalidOperationException("Can't modify an active cache request");
70 | }
71 | }
72 |
73 | public CacheRequest Clone()
74 | {
75 | return new CacheRequest(this._obj.Clone());
76 | }
77 |
78 | public void Pop()
79 | {
80 | if (((_cacheStack == null) || (_cacheStack.Count == 0)) || (_cacheStack.Peek() != this))
81 | {
82 | throw new InvalidOperationException("Only the top cache request can be popped");
83 | }
84 | _cacheStack.Pop();
85 | lock (this._lock)
86 | {
87 | this._cRef--;
88 | }
89 | }
90 |
91 | public void Push()
92 | {
93 | if (_cacheStack == null)
94 | {
95 | _cacheStack = new Stack();
96 | }
97 | _cacheStack.Push(this);
98 | lock (this._lock)
99 | {
100 | this._cRef++;
101 | }
102 | }
103 |
104 |
105 | public AutomationElementMode AutomationElementMode
106 | {
107 | get
108 | {
109 | return (AutomationElementMode)this._obj.AutomationElementMode;
110 | }
111 | set
112 | {
113 | lock (this._lock)
114 | {
115 | this.CheckAccess();
116 | this._obj.AutomationElementMode = (UIAutomationClient.AutomationElementMode)value;
117 | }
118 | }
119 | }
120 |
121 | public static CacheRequest Current
122 | {
123 | get
124 | {
125 | if ((_cacheStack != null) && (_cacheStack.Count != 0))
126 | {
127 | return (CacheRequest)_cacheStack.Peek();
128 | }
129 | return DefaultCacheRequest;
130 | }
131 | }
132 |
133 | internal static UIAutomationClient.IUIAutomationCacheRequest CurrentNativeCacheRequest
134 | {
135 | get
136 | {
137 | return CacheRequest.Current.NativeCacheRequest;
138 | }
139 | }
140 |
141 | public Condition TreeFilter
142 | {
143 | get
144 | {
145 | return Condition.Wrap(this._obj.TreeFilter);
146 | }
147 | set
148 | {
149 | Utility.ValidateArgumentNonNull(value, "TreeFilter");
150 | lock (this._lock)
151 | {
152 | this.CheckAccess();
153 | this._obj.TreeFilter = value.NativeCondition;
154 | }
155 | }
156 | }
157 |
158 | public TreeScope TreeScope
159 | {
160 | get
161 | {
162 | return (TreeScope)this._obj.TreeScope;
163 | }
164 | set
165 | {
166 | lock (this._lock)
167 | {
168 | this.CheckAccess();
169 | this._obj.TreeScope = (UIAutomationClient.TreeScope)value;
170 | }
171 | }
172 | }
173 |
174 | internal UIAutomationClient.IUIAutomationCacheRequest NativeCacheRequest
175 | {
176 | get
177 | {
178 | return this._obj;
179 | }
180 | }
181 | }
182 |
183 | internal class CacheRequestActivation : IDisposable
184 | {
185 |
186 | private CacheRequest _request;
187 |
188 |
189 | internal CacheRequestActivation(CacheRequest request)
190 | {
191 | this._request = request;
192 | }
193 |
194 | public void Dispose()
195 | {
196 | if (this._request != null)
197 | {
198 | this._request.Pop();
199 | this._request = null;
200 | }
201 | }
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/UiaComWrapperX/ClientEventList.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Diagnostics;
11 | using System.Windows.Automation;
12 | using UIAutomationClient;
13 | using StructureChangeType = System.Windows.Automation.StructureChangeType;
14 |
15 | namespace UIAComWrapperInternal
16 | {
17 | internal class EventListener
18 | {
19 | private int _eventId;
20 | private int[] _runtimeId;
21 | private Delegate _handler;
22 |
23 | public EventListener(int eventId, int[] runtimeId, Delegate handler)
24 | {
25 | Debug.Assert(handler != null);
26 |
27 | this._eventId = eventId;
28 | this._runtimeId = runtimeId;
29 | this._handler = handler;
30 | }
31 |
32 | public int EventId
33 | {
34 | get { return _eventId; }
35 | }
36 |
37 | public int[] RuntimeId
38 | {
39 | get { return _runtimeId; }
40 | }
41 |
42 | public Delegate Handler
43 | {
44 | get { return _handler; }
45 | }
46 |
47 | public override bool Equals(object obj)
48 | {
49 | EventListener listener = obj as EventListener;
50 | return (listener != null &&
51 | this._eventId == listener.EventId &&
52 | this._handler == listener.Handler &&
53 | Automation.Compare(this._runtimeId, listener.RuntimeId));
54 | }
55 |
56 | public override int GetHashCode()
57 | {
58 | return _handler.GetHashCode();
59 | }
60 | }
61 |
62 | internal class FocusEventListener : EventListener, UIAutomationClient.IUIAutomationFocusChangedEventHandler
63 | {
64 | private AutomationFocusChangedEventHandler _focusHandler;
65 |
66 | public FocusEventListener(AutomationFocusChangedEventHandler handler) :
67 | base(AutomationElement.AutomationFocusChangedEvent.Id, null, handler)
68 | {
69 | Debug.Assert(handler != null);
70 | this._focusHandler = handler;
71 | }
72 |
73 | #region IUIAutomationFocusChangedEventHandler Members
74 |
75 | void UIAutomationClient.IUIAutomationFocusChangedEventHandler.HandleFocusChangedEvent(
76 | UIAutomationClient.IUIAutomationElement sender)
77 | {
78 | // Can't set the arguments -- they come from a WinEvent handler.
79 | AutomationFocusChangedEventArgs args = new AutomationFocusChangedEventArgs(0, 0);
80 | _focusHandler(AutomationElement.Wrap(sender), args);
81 | }
82 |
83 | #endregion
84 | }
85 |
86 | internal class BasicEventListener : EventListener, UIAutomationClient.IUIAutomationEventHandler
87 | {
88 | private AutomationEventHandler _basicHandler;
89 |
90 | public BasicEventListener(AutomationEvent eventKind, AutomationElement element, AutomationEventHandler handler) :
91 | base(eventKind.Id, element.GetRuntimeId(), handler)
92 | {
93 | Debug.Assert(handler != null);
94 | this._basicHandler = handler;
95 | }
96 |
97 | #region IUIAutomationEventHandler Members
98 |
99 | void UIAutomationClient.IUIAutomationEventHandler.HandleAutomationEvent(
100 | UIAutomationClient.IUIAutomationElement sender, int eventId)
101 | {
102 | AutomationEventArgs args;
103 | if (eventId != WindowPatternIdentifiers.WindowClosedEvent.Id)
104 | {
105 | args = new AutomationEventArgs(AutomationEvent.LookupById(eventId));
106 | }
107 | else
108 | {
109 | args = new WindowClosedEventArgs((int[])sender.GetRuntimeId());
110 | }
111 | _basicHandler(AutomationElement.Wrap(sender), args);
112 | }
113 |
114 | #endregion
115 | }
116 |
117 | internal class PropertyEventListener : EventListener, UIAutomationClient.IUIAutomationPropertyChangedEventHandler
118 | {
119 | private AutomationPropertyChangedEventHandler _propChangeHandler;
120 |
121 | public PropertyEventListener(AutomationEvent eventKind, AutomationElement element, AutomationPropertyChangedEventHandler handler) :
122 | base(AutomationElement.AutomationPropertyChangedEvent.Id, element.GetRuntimeId(), handler)
123 | {
124 | Debug.Assert(handler != null);
125 | this._propChangeHandler = handler;
126 | }
127 |
128 | #region IUIAutomationPropertyChangedEventHandler Members
129 |
130 | void UIAutomationClient.IUIAutomationPropertyChangedEventHandler.HandlePropertyChangedEvent(
131 | UIAutomationClient.IUIAutomationElement sender,
132 | int propertyId,
133 | object newValue)
134 | {
135 | AutomationProperty property = AutomationProperty.LookupById(propertyId);
136 | object wrappedObj = Utility.WrapObjectAsProperty(property, newValue);
137 | AutomationPropertyChangedEventArgs args = new AutomationPropertyChangedEventArgs(
138 | property,
139 | null,
140 | wrappedObj);
141 | this._propChangeHandler(AutomationElement.Wrap(sender), args);
142 | }
143 |
144 | #endregion
145 | }
146 |
147 | internal class StructureEventListener : EventListener, UIAutomationClient.IUIAutomationStructureChangedEventHandler
148 | {
149 | private StructureChangedEventHandler _structureChangeHandler;
150 |
151 | public StructureEventListener(AutomationEvent eventKind, AutomationElement element, StructureChangedEventHandler handler) :
152 | base(AutomationElement.StructureChangedEvent.Id, element.GetRuntimeId(), handler)
153 | {
154 | Debug.Assert(handler != null);
155 | this._structureChangeHandler = handler;
156 | }
157 |
158 | public void HandleStructureChangedEvent(IUIAutomationElement sender, UIAutomationClient.StructureChangeType changeType, int[] runtimeId)
159 | {
160 | StructureChangedEventArgs args = new StructureChangedEventArgs(
161 | (StructureChangeType)changeType,
162 | (int[])runtimeId);
163 | this._structureChangeHandler(AutomationElement.Wrap(sender), args);
164 | }
165 | }
166 |
167 | internal class ClientEventList
168 | {
169 | private static readonly System.Collections.Generic.LinkedList _events = new LinkedList();
170 |
171 | public static void Add(EventListener listener)
172 | {
173 | lock (_events)
174 | {
175 | _events.AddLast(listener);
176 | }
177 | }
178 |
179 | public static EventListener Remove(AutomationEvent eventId, AutomationElement element, Delegate handler)
180 | {
181 | // Create a prototype to seek
182 | int[] runtimeId = (element == null) ? null : element.GetRuntimeId();
183 | EventListener prototype = new EventListener(eventId.Id, runtimeId, handler);
184 | lock (_events)
185 | {
186 | LinkedListNode node = _events.Find(prototype);
187 | if (node == null)
188 | {
189 | throw new ArgumentException("event handler not found");
190 | }
191 | EventListener result = node.Value;
192 | _events.Remove(node);
193 | return result;
194 | }
195 | }
196 |
197 | public static void Clear()
198 | {
199 | lock (_events)
200 | {
201 | _events.Clear();
202 | }
203 | }
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/UiaComWrapperX/DockPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class DockPattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationDockPattern _pattern;
20 | public static readonly AutomationProperty DockPositionProperty = DockPatternIdentifiers.DockPositionProperty;
21 | public static readonly AutomationPattern Pattern = DockPatternIdentifiers.Pattern;
22 |
23 |
24 | private DockPattern(AutomationElement el, UIAutomationClient.IUIAutomationDockPattern pattern, bool cached)
25 | : base(el, cached)
26 | {
27 | Debug.Assert(pattern != null);
28 | this._pattern = pattern;
29 | }
30 |
31 | public void SetDockPosition(DockPosition dockPosition)
32 | {
33 | try
34 | {
35 | this._pattern.SetDockPosition((UIAutomationClient.DockPosition)dockPosition);
36 | }
37 | catch (System.Runtime.InteropServices.COMException e)
38 | {
39 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
40 | }
41 | }
42 |
43 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
44 | {
45 | return (pattern == null) ? null : new DockPattern(el, (UIAutomationClient.IUIAutomationDockPattern)pattern, cached);
46 | }
47 |
48 |
49 | public DockPatternInformation Cached
50 | {
51 | get
52 | {
53 | Utility.ValidateCached(this._cached);
54 | return new DockPatternInformation(this._el, true);
55 | }
56 | }
57 |
58 | public DockPatternInformation Current
59 | {
60 | get
61 | {
62 | return new DockPatternInformation(this._el, false);
63 | }
64 | }
65 |
66 |
67 | [StructLayout(LayoutKind.Sequential)]
68 | public struct DockPatternInformation
69 | {
70 | private AutomationElement _el;
71 | private bool _isCached;
72 | internal DockPatternInformation(AutomationElement element, bool isCached)
73 | {
74 | this._el = element;
75 | this._isCached = isCached;
76 | }
77 |
78 | public DockPosition DockPosition
79 | {
80 | get
81 | {
82 | return (DockPosition)this._el.GetPropertyValue(DockPattern.DockPositionProperty, _isCached);
83 | }
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/UiaComWrapperX/DragPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 | using System;
8 | using System.Collections;
9 | using System.Diagnostics;
10 | using System.Runtime.InteropServices;
11 | using UIAComWrapperInternal;
12 |
13 | namespace System.Windows.Automation
14 | {
15 | public class DragPattern : BasePattern
16 | {
17 |
18 | private UIAutomationClient.IUIAutomationDragPattern _pattern;
19 | public static readonly AutomationProperty IsGrabbedProperty = DragPatternIdentifiers.IsGrabbedProperty;
20 | public static readonly AutomationProperty GrabbedItemsProperty = DragPatternIdentifiers.GrabbedItemsProperty;
21 | public static readonly AutomationProperty DropEffectProperty = DragPatternIdentifiers.DropEffectProperty;
22 | public static readonly AutomationProperty DropEffectsProperty = DragPatternIdentifiers.DropEffectsProperty;
23 | public static readonly AutomationEvent DragStartEvent = DragPatternIdentifiers.DragStartEvent;
24 | public static readonly AutomationEvent DragCancelEvent = DragPatternIdentifiers.DragCancelEvent;
25 | public static readonly AutomationEvent DragCompleteEvent = DragPatternIdentifiers.DragCompleteEvent;
26 | public static readonly AutomationPattern Pattern = DragPatternIdentifiers.Pattern;
27 |
28 |
29 | private DragPattern(AutomationElement el, UIAutomationClient.IUIAutomationDragPattern pattern, bool cached)
30 | : base(el, cached)
31 | {
32 | Debug.Assert(pattern != null);
33 | this._pattern = pattern;
34 | }
35 |
36 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
37 | {
38 | return (pattern == null) ? null : new DragPattern(el, (UIAutomationClient.IUIAutomationDragPattern)pattern, cached);
39 | }
40 |
41 |
42 | public DragPatternInformation Cached
43 | {
44 | get
45 | {
46 | Utility.ValidateCached(this._cached);
47 | return new DragPatternInformation(this._el, true);
48 | }
49 | }
50 |
51 | public DragPatternInformation Current
52 | {
53 | get
54 | {
55 | return new DragPatternInformation(this._el, false);
56 | }
57 | }
58 |
59 |
60 | [StructLayout(LayoutKind.Sequential)]
61 | public struct DragPatternInformation
62 | {
63 | private AutomationElement _el;
64 | private bool _isCached;
65 | internal DragPatternInformation(AutomationElement element, bool isCached)
66 | {
67 | this._el = element;
68 | this._isCached = isCached;
69 | }
70 |
71 | public bool IsGrabbed
72 | {
73 | get
74 | {
75 | return (bool)this._el.GetPropertyValue(DragPattern.IsGrabbedProperty, _isCached);
76 | }
77 | }
78 |
79 | public AutomationElement[] GrabbedItems
80 | {
81 | get
82 | {
83 | return (AutomationElement[])this._el.GetPropertyValue(DragPattern.GrabbedItemsProperty, _isCached);
84 | }
85 | }
86 |
87 | public string DropEffect
88 | {
89 | get
90 | {
91 | return (string)this._el.GetPropertyValue(DragPattern.DropEffectProperty, _isCached);
92 | }
93 | }
94 |
95 | public string[] DropEffects
96 | {
97 | get
98 | {
99 | return (string[])this._el.GetPropertyValue(DragPattern.DropEffectsProperty, _isCached);
100 | }
101 | }
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/UiaComWrapperX/DropTargetPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 | using System;
8 | using System.Collections;
9 | using System.Diagnostics;
10 | using System.Runtime.InteropServices;
11 | using UIAComWrapperInternal;
12 |
13 | namespace System.Windows.Automation
14 | {
15 | public class DropTargetPattern : BasePattern
16 | {
17 |
18 | private UIAutomationClient.IUIAutomationDropTargetPattern _pattern;
19 | public static readonly AutomationProperty DropTargetEffectProperty = DropTargetPatternIdentifiers.DropTargetEffectProperty;
20 | public static readonly AutomationProperty DropTargetEffectsProperty = DropTargetPatternIdentifiers.DropTargetEffectsProperty;
21 | public static readonly AutomationEvent DropTargetEnterEvent = DropTargetPatternIdentifiers.DragEnterEvent;
22 | public static readonly AutomationEvent DropTargetLeaveEvent = DropTargetPatternIdentifiers.DragLeaveEvent;
23 | public static readonly AutomationEvent DroppedEvent = DropTargetPatternIdentifiers.DroppedEvent;
24 | public static readonly AutomationPattern Pattern = DropTargetPatternIdentifiers.Pattern;
25 |
26 |
27 | private DropTargetPattern(AutomationElement el, UIAutomationClient.IUIAutomationDropTargetPattern pattern, bool cached)
28 | : base(el, cached)
29 | {
30 | Debug.Assert(pattern != null);
31 | this._pattern = pattern;
32 | }
33 |
34 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
35 | {
36 | return (pattern == null) ? null : new DropTargetPattern(el, (UIAutomationClient.IUIAutomationDropTargetPattern)pattern, cached);
37 | }
38 |
39 |
40 | public DropTargetPatternInformation Cached
41 | {
42 | get
43 | {
44 | Utility.ValidateCached(this._cached);
45 | return new DropTargetPatternInformation(this._el, true);
46 | }
47 | }
48 |
49 | public DropTargetPatternInformation Current
50 | {
51 | get
52 | {
53 | return new DropTargetPatternInformation(this._el, false);
54 | }
55 | }
56 |
57 |
58 | [StructLayout(LayoutKind.Sequential)]
59 | public struct DropTargetPatternInformation
60 | {
61 | private AutomationElement _el;
62 | private bool _isCached;
63 | internal DropTargetPatternInformation(AutomationElement element, bool isCached)
64 | {
65 | this._el = element;
66 | this._isCached = isCached;
67 | }
68 |
69 | public string DropTargetEffect
70 | {
71 | get
72 | {
73 | return (string)this._el.GetPropertyValue(DropTargetPattern.DropTargetEffectProperty, _isCached);
74 | }
75 | }
76 |
77 | public string[] DropTargetEffects
78 | {
79 | get
80 | {
81 | return (string[])this._el.GetPropertyValue(DropTargetPattern.DropTargetEffectsProperty, _isCached);
82 | }
83 | }
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/UiaComWrapperX/Events.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Runtime.InteropServices;
10 |
11 | namespace System.Windows.Automation
12 | {
13 | public class AutomationEventArgs : EventArgs
14 | {
15 |
16 | private AutomationEvent _eventId;
17 |
18 |
19 | public AutomationEventArgs(AutomationEvent eventId)
20 | {
21 | this._eventId = eventId;
22 | }
23 |
24 |
25 | public AutomationEvent EventId
26 | {
27 | get
28 | {
29 | return this._eventId;
30 | }
31 | }
32 | }
33 |
34 | public delegate void AutomationEventHandler(object sender, AutomationEventArgs e);
35 |
36 | public sealed class WindowClosedEventArgs : AutomationEventArgs
37 | {
38 |
39 | private int[] _runtimeId;
40 |
41 |
42 | public WindowClosedEventArgs(int[] runtimeId)
43 | : base(WindowPatternIdentifiers.WindowClosedEvent)
44 | {
45 | if (runtimeId == null)
46 | {
47 | throw new ArgumentNullException("runtimeId");
48 | }
49 | this._runtimeId = (int[])runtimeId.Clone();
50 | }
51 |
52 | public int[] GetRuntimeId()
53 | {
54 | return (int[])this._runtimeId.Clone();
55 | }
56 | }
57 |
58 | [Guid("d8e55844-7043-4edc-979d-593cc6b4775e"), ComVisible(true)]
59 | public enum AsyncContentLoadedState
60 | {
61 | Beginning,
62 | Progress,
63 | Completed
64 | }
65 |
66 | public sealed class AsyncContentLoadedEventArgs : AutomationEventArgs
67 | {
68 |
69 | private AsyncContentLoadedState _asyncContentState;
70 | private double _percentComplete;
71 |
72 |
73 | public AsyncContentLoadedEventArgs(AsyncContentLoadedState asyncContentState, double percentComplete)
74 | : base(AutomationElementIdentifiers.AsyncContentLoadedEvent)
75 | {
76 | this._asyncContentState = asyncContentState;
77 | this._percentComplete = percentComplete;
78 | }
79 |
80 |
81 | public AsyncContentLoadedState AsyncContentLoadedState
82 | {
83 | get
84 | {
85 | return this._asyncContentState;
86 | }
87 | }
88 |
89 | public double PercentComplete
90 | {
91 | get
92 | {
93 | return this._percentComplete;
94 | }
95 | }
96 | }
97 |
98 | public sealed class AutomationPropertyChangedEventArgs : AutomationEventArgs
99 | {
100 |
101 | private object _newValue;
102 | private object _oldValue;
103 | private AutomationProperty _property;
104 |
105 |
106 | public AutomationPropertyChangedEventArgs(AutomationProperty property, object oldValue, object newValue)
107 | : base(AutomationElementIdentifiers.AutomationPropertyChangedEvent)
108 | {
109 | this._oldValue = oldValue;
110 | this._newValue = newValue;
111 | this._property = property;
112 | }
113 |
114 |
115 | public object NewValue
116 | {
117 | get
118 | {
119 | return this._newValue;
120 | }
121 | }
122 |
123 | public object OldValue
124 | {
125 | get
126 | {
127 | return this._oldValue;
128 | }
129 | }
130 |
131 | public AutomationProperty Property
132 | {
133 | get
134 | {
135 | return this._property;
136 | }
137 | }
138 | }
139 |
140 | public delegate void AutomationPropertyChangedEventHandler(object sender, AutomationPropertyChangedEventArgs e);
141 |
142 | public class AutomationFocusChangedEventArgs : AutomationEventArgs
143 | {
144 |
145 | private int _idChild;
146 | private int _idObject;
147 |
148 |
149 | public AutomationFocusChangedEventArgs(int idObject, int idChild)
150 | : base(AutomationElement.AutomationFocusChangedEvent)
151 | {
152 | this._idObject = idObject;
153 | this._idChild = idChild;
154 | }
155 |
156 |
157 | public int ChildId
158 | {
159 | get
160 | {
161 | return this._idChild;
162 | }
163 | }
164 |
165 | public int ObjectId
166 | {
167 | get
168 | {
169 | return this._idObject;
170 | }
171 | }
172 | }
173 |
174 | public delegate void AutomationFocusChangedEventHandler(object sender, AutomationFocusChangedEventArgs e);
175 |
176 |
177 | [Guid("e4cfef41-071d-472c-a65c-c14f59ea81eb"), ComVisible(true)]
178 | public enum StructureChangeType
179 | {
180 | ChildAdded,
181 | ChildRemoved,
182 | ChildrenInvalidated,
183 | ChildrenBulkAdded,
184 | ChildrenBulkRemoved,
185 | ChildrenReordered
186 | }
187 |
188 | public sealed class StructureChangedEventArgs : AutomationEventArgs
189 | {
190 |
191 | private int[] _runtimeID;
192 | private StructureChangeType _structureChangeType;
193 |
194 |
195 | public StructureChangedEventArgs(StructureChangeType structureChangeType, int[] runtimeId)
196 | : base(AutomationElementIdentifiers.StructureChangedEvent)
197 | {
198 | if (runtimeId == null)
199 | {
200 | throw new ArgumentNullException("runtimeId");
201 | }
202 | this._structureChangeType = structureChangeType;
203 | this._runtimeID = (int[])runtimeId.Clone();
204 | }
205 |
206 | public int[] GetRuntimeId()
207 | {
208 | return (int[])this._runtimeID.Clone();
209 | }
210 |
211 |
212 | public StructureChangeType StructureChangeType
213 | {
214 | get
215 | {
216 | return this._structureChangeType;
217 | }
218 | }
219 | }
220 |
221 | public delegate void StructureChangedEventHandler(object sender, StructureChangedEventArgs e);
222 | }
223 |
--------------------------------------------------------------------------------
/UiaComWrapperX/ExpandCollapsePattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class ExpandCollapsePattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationExpandCollapsePattern _pattern;
20 | public static readonly AutomationProperty ExpandCollapseStateProperty = ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty;
21 | public static readonly AutomationPattern Pattern = ExpandCollapsePatternIdentifiers.Pattern;
22 |
23 |
24 | private ExpandCollapsePattern(AutomationElement el, UIAutomationClient.IUIAutomationExpandCollapsePattern pattern, bool cached)
25 | : base(el, cached)
26 | {
27 | Debug.Assert(pattern != null);
28 | this._pattern = pattern;
29 | }
30 |
31 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
32 | {
33 | return (pattern == null) ? null : new ExpandCollapsePattern(el, (UIAutomationClient.IUIAutomationExpandCollapsePattern)pattern, cached);
34 | }
35 |
36 | public void Collapse()
37 | {
38 | try
39 | {
40 | this._pattern.Collapse(); }
41 | catch (System.Runtime.InteropServices.COMException e)
42 | {
43 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
44 | }
45 | }
46 |
47 | public void Expand()
48 | {
49 | try
50 | {
51 | this._pattern.Expand(); }
52 | catch (System.Runtime.InteropServices.COMException e)
53 | {
54 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
55 | }
56 | }
57 |
58 |
59 | public ExpandCollapsePatternInformation Cached
60 | {
61 | get
62 | {
63 | Utility.ValidateCached(this._cached);
64 | return new ExpandCollapsePatternInformation(this._el, true);
65 | }
66 | }
67 |
68 | public ExpandCollapsePatternInformation Current
69 | {
70 | get
71 | {
72 | return new ExpandCollapsePatternInformation(this._el, false);
73 | }
74 | }
75 |
76 |
77 | [StructLayout(LayoutKind.Sequential)]
78 | public struct ExpandCollapsePatternInformation
79 | {
80 | private AutomationElement _el;
81 | private bool _isCached;
82 | internal ExpandCollapsePatternInformation(AutomationElement element, bool isCached)
83 | {
84 | this._el = element;
85 | this._isCached = isCached;
86 | }
87 |
88 | public ExpandCollapseState ExpandCollapseState
89 | {
90 | get
91 | {
92 | return (ExpandCollapseState)this._el.GetPropertyValue(ExpandCollapsePattern.ExpandCollapseStateProperty, _isCached);
93 | }
94 | }
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/UiaComWrapperX/GridPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class GridPattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationGridPattern _pattern;
20 | public static readonly AutomationPattern Pattern = GridPatternIdentifiers.Pattern;
21 | public static readonly AutomationProperty ColumnCountProperty = GridPatternIdentifiers.ColumnCountProperty;
22 | public static readonly AutomationProperty RowCountProperty = GridPatternIdentifiers.RowCountProperty;
23 |
24 |
25 | protected GridPattern(AutomationElement el, UIAutomationClient.IUIAutomationGridPattern pattern, bool cached)
26 | : base(el, cached)
27 | {
28 | Debug.Assert(pattern != null);
29 | this._pattern = pattern;
30 | }
31 |
32 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
33 | {
34 | return (pattern == null) ? null : new GridPattern(el, (UIAutomationClient.IUIAutomationGridPattern)pattern, cached);
35 | }
36 |
37 | public AutomationElement GetItem(int row, int column)
38 | {
39 | try
40 | {
41 | // Looks like we have to cache explicitly here, since GetItem doesn't
42 | // take a cache request.
43 | return AutomationElement.Wrap(this._pattern.GetItem(row, column)).GetUpdatedCache(CacheRequest.Current);
44 | }
45 | catch (System.Runtime.InteropServices.COMException e)
46 | {
47 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
48 | }
49 | }
50 |
51 |
52 | public GridPatternInformation Cached
53 | {
54 | get
55 | {
56 | Utility.ValidateCached(this._cached);
57 | return new GridPatternInformation(this._el, true);
58 | }
59 | }
60 |
61 | public GridPatternInformation Current
62 | {
63 | get
64 | {
65 | return new GridPatternInformation(this._el, false);
66 | }
67 | }
68 |
69 |
70 | [StructLayout(LayoutKind.Sequential)]
71 | public struct GridPatternInformation
72 | {
73 | private AutomationElement _el;
74 | private bool _isCached;
75 | internal GridPatternInformation(AutomationElement element, bool isCached)
76 | {
77 | this._el = element;
78 | this._isCached = isCached;
79 | }
80 |
81 | public int RowCount
82 | {
83 | get
84 | {
85 | return (int)this._el.GetPropertyValue(GridPattern.RowCountProperty, _isCached);
86 | }
87 | }
88 | public int ColumnCount
89 | {
90 | get
91 | {
92 | return (int)this._el.GetPropertyValue(GridPattern.ColumnCountProperty, _isCached);
93 | }
94 | }
95 | }
96 | }
97 |
98 | public class GridItemPattern : BasePattern
99 | {
100 |
101 | private UIAutomationClient.IUIAutomationGridItemPattern _pattern;
102 | public static readonly AutomationPattern Pattern = GridItemPatternIdentifiers.Pattern;
103 | public static readonly AutomationProperty ColumnProperty = GridItemPatternIdentifiers.ColumnProperty;
104 | public static readonly AutomationProperty ColumnSpanProperty = GridItemPatternIdentifiers.ColumnSpanProperty;
105 | public static readonly AutomationProperty ContainingGridProperty = GridItemPatternIdentifiers.ContainingGridProperty;
106 | public static readonly AutomationProperty RowProperty = GridItemPatternIdentifiers.RowProperty;
107 | public static readonly AutomationProperty RowSpanProperty = GridItemPatternIdentifiers.RowSpanProperty;
108 |
109 |
110 | protected GridItemPattern(AutomationElement el, UIAutomationClient.IUIAutomationGridItemPattern pattern, bool cached)
111 | : base(el, cached)
112 | {
113 | Debug.Assert(pattern != null);
114 | this._pattern = pattern;
115 | }
116 |
117 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
118 | {
119 | return (pattern == null) ? null : new GridItemPattern(el, (UIAutomationClient.IUIAutomationGridItemPattern)pattern, cached);
120 | }
121 |
122 |
123 | public GridItemPatternInformation Cached
124 | {
125 | get
126 | {
127 | Utility.ValidateCached(this._cached);
128 | return new GridItemPatternInformation(this._el, true);
129 | }
130 | }
131 |
132 | public GridItemPatternInformation Current
133 | {
134 | get
135 | {
136 | return new GridItemPatternInformation(this._el, false);
137 | }
138 | }
139 |
140 |
141 | [StructLayout(LayoutKind.Sequential)]
142 | public struct GridItemPatternInformation
143 | {
144 | private AutomationElement _el;
145 | private bool _isCached;
146 | internal GridItemPatternInformation(AutomationElement element, bool isCached)
147 | {
148 | this._el = element;
149 | this._isCached = isCached;
150 | }
151 |
152 | public int Row
153 | {
154 | get
155 | {
156 | return (int)this._el.GetPropertyValue(GridItemPattern.RowProperty, _isCached);
157 | }
158 | }
159 | public int Column
160 | {
161 | get
162 | {
163 | return (int)this._el.GetPropertyValue(GridItemPattern.ColumnProperty, _isCached);
164 | }
165 | }
166 | public int RowSpan
167 | {
168 | get
169 | {
170 | return (int)this._el.GetPropertyValue(GridItemPattern.RowSpanProperty, _isCached);
171 | }
172 | }
173 | public int ColumnSpan
174 | {
175 | get
176 | {
177 | return (int)this._el.GetPropertyValue(GridItemPattern.ColumnSpanProperty, _isCached);
178 | }
179 | }
180 | public AutomationElement ContainingGrid
181 | {
182 | get
183 | {
184 | return (AutomationElement)this._el.GetPropertyValue(GridItemPattern.ContainingGridProperty, _isCached);
185 | }
186 | }
187 | }
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/UiaComWrapperX/InvokePattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Diagnostics;
10 | using UIAComWrapperInternal;
11 |
12 | namespace System.Windows.Automation
13 | {
14 | public class InvokePattern : BasePattern
15 | {
16 |
17 | private UIAutomationClient.IUIAutomationInvokePattern _pattern;
18 | public static readonly AutomationEvent InvokedEvent = InvokePatternIdentifiers.InvokedEvent;
19 | public static readonly AutomationPattern Pattern = InvokePatternIdentifiers.Pattern;
20 |
21 |
22 | private InvokePattern(AutomationElement el, UIAutomationClient.IUIAutomationInvokePattern pattern, bool cached)
23 | : base(el, cached)
24 | {
25 | Debug.Assert(pattern != null);
26 | this._pattern = pattern;
27 | }
28 |
29 | public void Invoke()
30 | {
31 | try
32 | {
33 | this._pattern.Invoke();
34 | }
35 | catch (System.Runtime.InteropServices.COMException e)
36 | {
37 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
38 | }
39 | }
40 |
41 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
42 | {
43 | return (pattern == null) ? null : new InvokePattern(el, (UIAutomationClient.IUIAutomationInvokePattern)pattern, cached);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/UiaComWrapperX/LegacyIAccessiblePattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class LegacyIAccessiblePattern : BasePattern
17 | {
18 | public static readonly AutomationProperty ChildIdProperty = LegacyIAccessiblePatternIdentifiers.ChildIdProperty;
19 | public static readonly AutomationProperty NameProperty = LegacyIAccessiblePatternIdentifiers.NameProperty;
20 | public static readonly AutomationProperty ValueProperty = LegacyIAccessiblePatternIdentifiers.ValueProperty;
21 | public static readonly AutomationProperty DescriptionProperty = LegacyIAccessiblePatternIdentifiers.DescriptionProperty;
22 | public static readonly AutomationProperty RoleProperty = LegacyIAccessiblePatternIdentifiers.RoleProperty;
23 | public static readonly AutomationProperty StateProperty = LegacyIAccessiblePatternIdentifiers.StateProperty;
24 | public static readonly AutomationProperty HelpProperty = LegacyIAccessiblePatternIdentifiers.HelpProperty;
25 | public static readonly AutomationProperty KeyboardShortcutProperty = LegacyIAccessiblePatternIdentifiers.KeyboardShortcutProperty;
26 | public static readonly AutomationProperty SelectionProperty = LegacyIAccessiblePatternIdentifiers.SelectionProperty;
27 | public static readonly AutomationProperty DefaultActionProperty = LegacyIAccessiblePatternIdentifiers.DefaultActionProperty;
28 | public static readonly AutomationPattern Pattern = LegacyIAccessiblePatternIdentifiers.Pattern;
29 |
30 | private UIAutomationClient.IUIAutomationLegacyIAccessiblePattern _pattern;
31 |
32 | private LegacyIAccessiblePattern(AutomationElement el, UIAutomationClient.IUIAutomationLegacyIAccessiblePattern pattern, bool cached)
33 | : base(el, cached)
34 | {
35 | Debug.Assert(pattern != null);
36 | this._pattern = pattern;
37 | }
38 |
39 | public void Select(int flagsSelect)
40 | {
41 | try
42 | {
43 | this._pattern.Select(flagsSelect);
44 | }
45 | catch (System.Runtime.InteropServices.COMException e)
46 | {
47 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
48 | }
49 | }
50 |
51 | public void DoDefaultAction()
52 | {
53 | try
54 | {
55 | this._pattern.DoDefaultAction();
56 | }
57 | catch (System.Runtime.InteropServices.COMException e)
58 | {
59 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
60 | }
61 | }
62 |
63 | public void SetValue(string value)
64 | {
65 | try
66 | {
67 | this._pattern.SetValue(value);
68 | }
69 | catch (System.Runtime.InteropServices.COMException e)
70 | {
71 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
72 | }
73 | }
74 |
75 | public Accessibility.IAccessible GetIAccessible()
76 | {
77 | try
78 | {
79 | return (Accessibility.IAccessible)this._pattern.GetIAccessible();
80 | }
81 | catch (System.Runtime.InteropServices.COMException e)
82 | {
83 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
84 | }
85 | }
86 |
87 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
88 | {
89 | return (pattern == null) ? null : new LegacyIAccessiblePattern(el, (UIAutomationClient.IUIAutomationLegacyIAccessiblePattern)pattern, cached);
90 | }
91 |
92 |
93 | public LegacyIAccessiblePatternInformation Cached
94 | {
95 | get
96 | {
97 | Utility.ValidateCached(this._cached);
98 | return new LegacyIAccessiblePatternInformation(this._el, true);
99 | }
100 | }
101 |
102 | public LegacyIAccessiblePatternInformation Current
103 | {
104 | get
105 | {
106 | return new LegacyIAccessiblePatternInformation(this._el, false);
107 | }
108 | }
109 |
110 |
111 | [StructLayout(LayoutKind.Sequential)]
112 | public struct LegacyIAccessiblePatternInformation
113 | {
114 | private AutomationElement _el;
115 | private bool _isCached;
116 | internal LegacyIAccessiblePatternInformation(AutomationElement element, bool isCached)
117 | {
118 | this._el = element;
119 | this._isCached = isCached;
120 | }
121 |
122 | public AutomationElement[] GetSelection()
123 | {
124 | return (AutomationElement[])this._el.GetPropertyValue(LegacyIAccessiblePattern.SelectionProperty, _isCached);
125 | }
126 |
127 | public int ChildId
128 | {
129 | get
130 | {
131 | return (int)this._el.GetPropertyValue(LegacyIAccessiblePattern.ChildIdProperty, _isCached);
132 | }
133 | }
134 |
135 | public string DefaultAction
136 | {
137 | get
138 | {
139 | return (string)this._el.GetPropertyValue(LegacyIAccessiblePattern.DefaultActionProperty, _isCached);
140 | }
141 | }
142 |
143 | public string Description
144 | {
145 | get
146 | {
147 | return (string)this._el.GetPropertyValue(LegacyIAccessiblePattern.DescriptionProperty, _isCached);
148 | }
149 | }
150 |
151 | public string Help
152 | {
153 | get
154 | {
155 | return (string)this._el.GetPropertyValue(LegacyIAccessiblePattern.HelpProperty, _isCached);
156 | }
157 | }
158 |
159 | public string KeyboardShortcut
160 | {
161 | get
162 | {
163 | return (string)this._el.GetPropertyValue(LegacyIAccessiblePattern.KeyboardShortcutProperty, _isCached);
164 | }
165 | }
166 |
167 | public string Name
168 | {
169 | get
170 | {
171 | return (string)this._el.GetPropertyValue(LegacyIAccessiblePattern.NameProperty, _isCached);
172 | }
173 | }
174 |
175 | public uint Role
176 | {
177 | get
178 | {
179 | return Convert.ToUInt32(this._el.GetPropertyValue(LegacyIAccessiblePattern.RoleProperty, _isCached));
180 | }
181 | }
182 |
183 | public uint State
184 | {
185 | get
186 | {
187 | return Convert.ToUInt32(this._el.GetPropertyValue(LegacyIAccessiblePattern.StateProperty, _isCached));
188 | }
189 | }
190 |
191 | public string Value
192 | {
193 | get
194 | {
195 | return (string)this._el.GetPropertyValue(LegacyIAccessiblePattern.ValueProperty, _isCached);
196 | }
197 | }
198 | }
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/UiaComWrapperX/MultipleViewPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class MultipleViewPattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationMultipleViewPattern _pattern;
20 | public static readonly AutomationPattern Pattern = MultipleViewPatternIdentifiers.Pattern;
21 | public static readonly AutomationProperty CurrentViewProperty = MultipleViewPatternIdentifiers.CurrentViewProperty;
22 | public static readonly AutomationProperty SupportedViewsProperty = MultipleViewPatternIdentifiers.SupportedViewsProperty;
23 |
24 |
25 | private MultipleViewPattern(AutomationElement el, UIAutomationClient.IUIAutomationMultipleViewPattern pattern, bool cached)
26 | : base(el, cached)
27 | {
28 | Debug.Assert(pattern != null);
29 | this._pattern = pattern;
30 | }
31 |
32 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
33 | {
34 | return (pattern == null) ? null : new MultipleViewPattern(el, (UIAutomationClient.IUIAutomationMultipleViewPattern)pattern, cached);
35 | }
36 |
37 | public string GetViewName(int viewId)
38 | {
39 | try
40 | {
41 | return this._pattern.GetViewName(viewId);
42 | }
43 | catch (System.Runtime.InteropServices.COMException e)
44 | {
45 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
46 | }
47 | }
48 |
49 | public void SetCurrentView(int viewId)
50 | {
51 | try
52 | {
53 | this._pattern.SetCurrentView(viewId);
54 | }
55 | catch (System.Runtime.InteropServices.COMException e)
56 | {
57 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
58 | }
59 | }
60 |
61 |
62 | public MultipleViewPatternInformation Cached
63 | {
64 | get
65 | {
66 | Utility.ValidateCached(this._cached);
67 | return new MultipleViewPatternInformation(this._el, true);
68 | }
69 | }
70 |
71 | public MultipleViewPatternInformation Current
72 | {
73 | get
74 | {
75 | return new MultipleViewPatternInformation(this._el, false);
76 | }
77 | }
78 |
79 |
80 | [StructLayout(LayoutKind.Sequential)]
81 | public struct MultipleViewPatternInformation
82 | {
83 | private AutomationElement _el;
84 | private bool _isCached;
85 | internal MultipleViewPatternInformation(AutomationElement element, bool isCached)
86 | {
87 | this._el = element;
88 | this._isCached = isCached;
89 | }
90 |
91 | public int CurrentView
92 | {
93 | get
94 | {
95 | return (int)this._el.GetPropertyValue(MultipleViewPattern.CurrentViewProperty, _isCached);
96 | }
97 | }
98 | public int[] GetSupportedViews()
99 | {
100 | return (int[])this._el.GetPropertyValue(MultipleViewPattern.SupportedViewsProperty, _isCached);
101 | }
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/UiaComWrapperX/ObjectModelPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 | using System;
8 | using System.Collections;
9 | using System.Diagnostics;
10 | using System.Runtime.InteropServices;
11 | using UIAComWrapperInternal;
12 |
13 | namespace System.Windows.Automation
14 | {
15 | public class ObjectModelPattern : BasePattern
16 | {
17 | private UIAutomationClient.IUIAutomationObjectModelPattern _pattern;
18 | public static readonly AutomationPattern Pattern = ObjectModelPatternIdentifiers.Pattern;
19 |
20 | private ObjectModelPattern(AutomationElement el, UIAutomationClient.IUIAutomationObjectModelPattern pattern, bool cached)
21 | : base(el, cached)
22 | {
23 | Debug.Assert(pattern != null);
24 | this._pattern = pattern;
25 | }
26 |
27 | public object GetUnderlyingObjectModel()
28 | {
29 | try
30 | {
31 | return this._pattern.GetUnderlyingObjectModel();
32 | }
33 | catch (System.Runtime.InteropServices.COMException e)
34 | {
35 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
36 | }
37 | }
38 |
39 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
40 | {
41 | return (pattern == null) ? null : new ObjectModelPattern(el, (UIAutomationClient.IUIAutomationObjectModelPattern)pattern, cached);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/UiaComWrapperX/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Michael Bernstein, 2009.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 | using System.Reflection;
7 | using System.Runtime.CompilerServices;
8 | using System.Runtime.InteropServices;
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 | [assembly: AssemblyTitle("UIAComWrapperX")]
14 | [assembly: AssemblyDescription("")]
15 | [assembly: AssemblyConfiguration("")]
16 | [assembly: AssemblyCompany("")]
17 | [assembly: AssemblyProduct("UIAComWrapperX")]
18 | [assembly: AssemblyCopyright("Copyright © 2018 Techno Scavenger")]
19 | [assembly: AssemblyTrademark("")]
20 | [assembly: AssemblyCulture("")]
21 |
22 | // Setting ComVisible to false makes the types in this assembly not visible
23 | // to COM components. If you need to access a type in this assembly from
24 | // COM, set the ComVisible attribute to true on that type.
25 | [assembly: ComVisible(false)]
26 |
27 | // The following GUID is for the ID of the typelib if this project is exposed to COM
28 | [assembly: Guid("74f2db3d-156a-4160-a401-011f601e1b56")]
29 |
30 | // Version information for an assembly consists of the following four values:
31 | //
32 | // Major Version
33 | // Minor Version
34 | // Build Number
35 | // Revision
36 | //
37 | // You can specify all the values or you can default the Build and Revision Numbers
38 | // by using the '*' as shown below:
39 | // [assembly: AssemblyVersion("1.0.*")]
40 | [assembly: AssemblyVersion("1.1.0.16")]
41 | [assembly: AssemblyFileVersion("1.1.0.16")]
42 |
43 | [assembly: InternalsVisibleTo("UIAComWrapperXTests, PublicKey=00240000048000009400000006020000002400005253413100040000010001002b12949bc42c9ceccdc8e98f99a849017c9f4ffd19d656191727a431f00bd283848493e5318e3dee94636edd27b08c59ee3d1d4e0948a197341eb3e238cc08660d23191faecf5dd9566e9c2b1ca4fd89ee04fb220ef096cc6b0f1f51a278cc37f9ffc0d89015032ef0ab6196c374b407e0e6ca4ece4b90e52bd636f22b9342ee")]
--------------------------------------------------------------------------------
/UiaComWrapperX/ScrollPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class ScrollPattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationScrollPattern _pattern;
20 | public static readonly AutomationPattern Pattern = ScrollPatternIdentifiers.Pattern;
21 | public static readonly AutomationProperty HorizontallyScrollableProperty = ScrollPatternIdentifiers.HorizontallyScrollableProperty;
22 | public static readonly AutomationProperty HorizontalScrollPercentProperty = ScrollPatternIdentifiers.HorizontalScrollPercentProperty;
23 | public static readonly AutomationProperty HorizontalViewSizeProperty = ScrollPatternIdentifiers.HorizontalViewSizeProperty;
24 | public const double NoScroll = -1.0;
25 | public static readonly AutomationProperty VerticallyScrollableProperty = ScrollPatternIdentifiers.VerticallyScrollableProperty;
26 | public static readonly AutomationProperty VerticalScrollPercentProperty = ScrollPatternIdentifiers.VerticalScrollPercentProperty;
27 | public static readonly AutomationProperty VerticalViewSizeProperty = ScrollPatternIdentifiers.VerticalViewSizeProperty;
28 |
29 |
30 |
31 | private ScrollPattern(AutomationElement el, UIAutomationClient.IUIAutomationScrollPattern pattern, bool cached)
32 | : base(el, cached)
33 | {
34 | Debug.Assert(pattern != null);
35 | this._pattern = pattern;
36 | }
37 |
38 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
39 | {
40 | return (pattern == null) ? null : new ScrollPattern(el, (UIAutomationClient.IUIAutomationScrollPattern)pattern, cached);
41 | }
42 |
43 | public void Scroll(ScrollAmount horizontalAmount, ScrollAmount verticalAmount)
44 | {
45 | try
46 | {
47 | this._pattern.Scroll((UIAutomationClient.ScrollAmount)horizontalAmount, (UIAutomationClient.ScrollAmount)verticalAmount);
48 | }
49 | catch (System.Runtime.InteropServices.COMException e)
50 | {
51 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
52 | }
53 | }
54 |
55 | public void ScrollHorizontal(ScrollAmount amount)
56 | {
57 | try
58 | {
59 | this._pattern.Scroll((UIAutomationClient.ScrollAmount)amount, UIAutomationClient.ScrollAmount.ScrollAmount_NoAmount);
60 | }
61 | catch (System.Runtime.InteropServices.COMException e)
62 | {
63 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
64 | }
65 | }
66 |
67 | public void ScrollVertical(ScrollAmount amount)
68 | {
69 | try
70 | {
71 | this._pattern.Scroll(UIAutomationClient.ScrollAmount.ScrollAmount_NoAmount, (UIAutomationClient.ScrollAmount)amount);
72 | }
73 | catch (System.Runtime.InteropServices.COMException e)
74 | {
75 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
76 | }
77 | }
78 |
79 | public void SetScrollPercent(double horizontalPercent, double verticalPercent)
80 | {
81 | try
82 | {
83 | this._pattern.SetScrollPercent(horizontalPercent, verticalPercent);
84 | }
85 | catch (System.Runtime.InteropServices.COMException e)
86 | {
87 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
88 | }
89 | }
90 |
91 |
92 | public ScrollPatternInformation Cached
93 | {
94 | get
95 | {
96 | Utility.ValidateCached(this._cached);
97 | return new ScrollPatternInformation(this._el, true);
98 | }
99 | }
100 |
101 | public ScrollPatternInformation Current
102 | {
103 | get
104 | {
105 | return new ScrollPatternInformation(this._el, false);
106 | }
107 | }
108 |
109 |
110 | [StructLayout(LayoutKind.Sequential)]
111 | public struct ScrollPatternInformation
112 | {
113 | private AutomationElement _el;
114 | private bool _isCached;
115 | internal ScrollPatternInformation(AutomationElement element, bool isCached)
116 | {
117 | this._el = element;
118 | this._isCached = isCached;
119 | }
120 |
121 | public double HorizontalScrollPercent
122 | {
123 | get
124 | {
125 | return (double)this._el.GetPropertyValue(ScrollPattern.HorizontalScrollPercentProperty, _isCached);
126 | }
127 | }
128 | public double VerticalScrollPercent
129 | {
130 | get
131 | {
132 | return (double)this._el.GetPropertyValue(ScrollPattern.VerticalScrollPercentProperty, _isCached);
133 | }
134 | }
135 | public double HorizontalViewSize
136 | {
137 | get
138 | {
139 | return (double)this._el.GetPropertyValue(ScrollPattern.HorizontalViewSizeProperty, _isCached);
140 | }
141 | }
142 | public double VerticalViewSize
143 | {
144 | get
145 | {
146 | return (double)this._el.GetPropertyValue(ScrollPattern.VerticalViewSizeProperty, _isCached);
147 | }
148 | }
149 | public bool HorizontallyScrollable
150 | {
151 | get
152 | {
153 | return (bool)this._el.GetPropertyValue(ScrollPattern.HorizontallyScrollableProperty, _isCached);
154 | }
155 | }
156 | public bool VerticallyScrollable
157 | {
158 | get
159 | {
160 | return (bool)this._el.GetPropertyValue(ScrollPattern.VerticallyScrollableProperty, _isCached);
161 | }
162 | }
163 | }
164 | }
165 |
166 |
167 | public class ScrollItemPattern : BasePattern
168 | {
169 |
170 | private UIAutomationClient.IUIAutomationScrollItemPattern _pattern;
171 | public static readonly AutomationPattern Pattern = ScrollItemPatternIdentifiers.Pattern;
172 |
173 |
174 | private ScrollItemPattern(AutomationElement el, UIAutomationClient.IUIAutomationScrollItemPattern pattern, bool cached)
175 | : base(el, cached)
176 | {
177 | Debug.Assert(pattern != null);
178 | this._pattern = pattern;
179 | }
180 |
181 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
182 | {
183 | return (pattern == null) ? null : new ScrollItemPattern(el, (UIAutomationClient.IUIAutomationScrollItemPattern)pattern, cached);
184 | }
185 |
186 | public void ScrollIntoView()
187 | {
188 | try
189 | {
190 | this._pattern.ScrollIntoView();
191 | }
192 | catch (System.Runtime.InteropServices.COMException e)
193 | {
194 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
195 | }
196 | }
197 | }
198 | }
--------------------------------------------------------------------------------
/UiaComWrapperX/SelectionPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class SelectionPattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationSelectionPattern _pattern;
20 | public static readonly AutomationPattern Pattern = SelectionPatternIdentifiers.Pattern;
21 | public static readonly AutomationProperty CanSelectMultipleProperty = SelectionPatternIdentifiers.CanSelectMultipleProperty;
22 | public static readonly AutomationEvent InvalidatedEvent = SelectionPatternIdentifiers.InvalidatedEvent;
23 | public static readonly AutomationProperty IsSelectionRequiredProperty = SelectionPatternIdentifiers.IsSelectionRequiredProperty;
24 | public static readonly AutomationProperty SelectionProperty = SelectionPatternIdentifiers.SelectionProperty;
25 |
26 |
27 | private SelectionPattern(AutomationElement el, UIAutomationClient.IUIAutomationSelectionPattern pattern, bool cached)
28 | : base(el, cached)
29 | {
30 | Debug.Assert(pattern != null);
31 | this._pattern = pattern;
32 | }
33 |
34 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
35 | {
36 | return (pattern == null) ? null : new SelectionPattern(el, (UIAutomationClient.IUIAutomationSelectionPattern)pattern, cached);
37 | }
38 |
39 |
40 | public SelectionPatternInformation Cached
41 | {
42 | get
43 | {
44 | Utility.ValidateCached(this._cached);
45 | return new SelectionPatternInformation(this._el, true);
46 | }
47 | }
48 |
49 | public SelectionPatternInformation Current
50 | {
51 | get
52 | {
53 | return new SelectionPatternInformation(this._el, false);
54 | }
55 | }
56 |
57 |
58 | [StructLayout(LayoutKind.Sequential)]
59 | public struct SelectionPatternInformation
60 | {
61 | private AutomationElement _el;
62 | private bool _isCached;
63 | internal SelectionPatternInformation(AutomationElement element, bool isCached)
64 | {
65 | this._el = element;
66 | this._isCached = isCached;
67 | }
68 |
69 | public AutomationElement[] GetSelection()
70 | {
71 | return (AutomationElement[])this._el.GetPropertyValue(SelectionPattern.SelectionProperty, _isCached);
72 | }
73 |
74 | public bool CanSelectMultiple
75 | {
76 | get
77 | {
78 | return (bool)this._el.GetPropertyValue(SelectionPattern.CanSelectMultipleProperty, _isCached);
79 | }
80 | }
81 | public bool IsSelectionRequired
82 | {
83 | get
84 | {
85 | return (bool)this._el.GetPropertyValue(SelectionPattern.IsSelectionRequiredProperty, _isCached);
86 | }
87 | }
88 | }
89 | }
90 |
91 | public class SelectionItemPattern : BasePattern
92 | {
93 |
94 | private UIAutomationClient.IUIAutomationSelectionItemPattern _pattern;
95 | public static readonly AutomationPattern Pattern = SelectionItemPatternIdentifiers.Pattern;
96 | public static readonly AutomationEvent ElementAddedToSelectionEvent = SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent;
97 | public static readonly AutomationEvent ElementRemovedFromSelectionEvent = SelectionItemPatternIdentifiers.ElementRemovedFromSelectionEvent;
98 | public static readonly AutomationEvent ElementSelectedEvent = SelectionItemPatternIdentifiers.ElementSelectedEvent;
99 | public static readonly AutomationProperty IsSelectedProperty = SelectionItemPatternIdentifiers.IsSelectedProperty;
100 | public static readonly AutomationProperty SelectionContainerProperty = SelectionItemPatternIdentifiers.SelectionContainerProperty;
101 |
102 |
103 |
104 | private SelectionItemPattern(AutomationElement el, UIAutomationClient.IUIAutomationSelectionItemPattern pattern, bool cached)
105 | : base(el, cached)
106 | {
107 | Debug.Assert(pattern != null);
108 | this._pattern = pattern;
109 | }
110 |
111 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
112 | {
113 | return (pattern == null) ? null : new SelectionItemPattern(el, (UIAutomationClient.IUIAutomationSelectionItemPattern)pattern, cached);
114 | }
115 |
116 | public void AddToSelection()
117 | {
118 | try
119 | {
120 | this._pattern.AddToSelection();
121 | }
122 | catch (System.Runtime.InteropServices.COMException e)
123 | {
124 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
125 | }
126 | }
127 |
128 | public void RemoveFromSelection()
129 | {
130 | try
131 | {
132 | this._pattern.RemoveFromSelection();
133 | }
134 | catch (System.Runtime.InteropServices.COMException e)
135 | {
136 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
137 | }
138 | }
139 |
140 | public void Select()
141 | {
142 | try
143 | {
144 | this._pattern.Select();
145 | }
146 | catch (System.Runtime.InteropServices.COMException e)
147 | {
148 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
149 | }
150 | }
151 |
152 |
153 | public SelectionItemPatternInformation Cached
154 | {
155 | get
156 | {
157 | Utility.ValidateCached(this._cached);
158 | return new SelectionItemPatternInformation(this._el, true);
159 | }
160 | }
161 |
162 | public SelectionItemPatternInformation Current
163 | {
164 | get
165 | {
166 | return new SelectionItemPatternInformation(this._el, false);
167 | }
168 | }
169 |
170 |
171 | [StructLayout(LayoutKind.Sequential)]
172 | public struct SelectionItemPatternInformation
173 | {
174 | private AutomationElement _el;
175 | private bool _isCached;
176 | internal SelectionItemPatternInformation(AutomationElement element, bool isCached)
177 | {
178 | this._el = element;
179 | this._isCached = isCached;
180 | }
181 |
182 | public bool IsSelected
183 | {
184 | get
185 | {
186 | return (bool)this._el.GetPropertyValue(SelectionItemPattern.IsSelectedProperty, _isCached);
187 | }
188 | }
189 |
190 | public AutomationElement SelectionContainer
191 | {
192 | get
193 | {
194 | return (AutomationElement)this._el.GetPropertyValue(SelectionItemPattern.SelectionContainerProperty, _isCached);
195 | }
196 | }
197 | }
198 | }
199 | }
--------------------------------------------------------------------------------
/UiaComWrapperX/SpreadsheetPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 | using System;
8 | using System.Collections;
9 | using System.Diagnostics;
10 | using System.Runtime.InteropServices;
11 | using UIAComWrapperInternal;
12 |
13 | namespace System.Windows.Automation
14 | {
15 | public class SpreadsheetPattern : BasePattern
16 | {
17 |
18 | private UIAutomationClient.IUIAutomationSpreadsheetPattern _pattern;
19 | public static readonly AutomationPattern Pattern = SpreadsheetPatternIdentifiers.Pattern;
20 |
21 | private SpreadsheetPattern(AutomationElement el, UIAutomationClient.IUIAutomationSpreadsheetPattern pattern, bool cached)
22 | : base(el, cached)
23 | {
24 | Debug.Assert(pattern != null);
25 | this._pattern = pattern;
26 | }
27 |
28 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
29 | {
30 | return (pattern == null) ? null : new SpreadsheetPattern(el, (UIAutomationClient.IUIAutomationSpreadsheetPattern)pattern, cached);
31 | }
32 |
33 | public AutomationElement GetItemByName(string name)
34 | {
35 | try
36 | {
37 | return AutomationElement.Wrap(
38 | this._pattern.GetItemByName(name));
39 | }
40 | catch (System.Runtime.InteropServices.COMException e)
41 | {
42 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
43 | }
44 | }
45 | }
46 |
47 | public class SpreadsheetItemPattern : BasePattern
48 | {
49 |
50 | private UIAutomationClient.IUIAutomationSpreadsheetItemPattern _pattern;
51 | public static readonly AutomationPattern Pattern = SpreadsheetItemPatternIdentifiers.Pattern;
52 | public static readonly AutomationProperty FormulaProperty = SpreadsheetItemPatternIdentifiers.FormulaProperty;
53 | public static readonly AutomationProperty AnnotationObjectsProperty = SpreadsheetItemPatternIdentifiers.AnnotationObjectsProperty;
54 | public static readonly AutomationProperty AnnotationTypesProperty = SpreadsheetItemPatternIdentifiers.AnnotationTypesProperty;
55 |
56 | private SpreadsheetItemPattern(AutomationElement el, UIAutomationClient.IUIAutomationSpreadsheetItemPattern pattern, bool cached)
57 | : base(el, cached)
58 | {
59 | Debug.Assert(pattern != null);
60 | this._pattern = pattern;
61 | }
62 |
63 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
64 | {
65 | return (pattern == null) ? null : new SpreadsheetItemPattern(el, (UIAutomationClient.IUIAutomationSpreadsheetItemPattern)pattern, cached);
66 | }
67 |
68 | public SpreadsheetItemPatternInformation Cached
69 | {
70 | get
71 | {
72 | Utility.ValidateCached(this._cached);
73 | return new SpreadsheetItemPatternInformation(this._el, true);
74 | }
75 | }
76 |
77 | public SpreadsheetItemPatternInformation Current
78 | {
79 | get
80 | {
81 | return new SpreadsheetItemPatternInformation(this._el, false);
82 | }
83 | }
84 |
85 |
86 | [StructLayout(LayoutKind.Sequential)]
87 | public struct SpreadsheetItemPatternInformation
88 | {
89 | private AutomationElement _el;
90 | private bool _isCached;
91 | internal SpreadsheetItemPatternInformation(AutomationElement element, bool isCached)
92 | {
93 | this._el = element;
94 | this._isCached = isCached;
95 | }
96 |
97 | public string Formula
98 | {
99 | get
100 | {
101 | return (string)this._el.GetPropertyValue(SpreadsheetItemPattern.FormulaProperty, _isCached);
102 | }
103 | }
104 |
105 | public AutomationElement[] GetAnnotationObjects()
106 | {
107 | return (AutomationElement[])this._el.GetPropertyValue(SpreadsheetItemPattern.AnnotationObjectsProperty, _isCached);
108 | }
109 |
110 | public AnnotationType[] GetAnnotationTypes()
111 | {
112 | return (AnnotationType[])this._el.GetPropertyValue(SpreadsheetItemPattern.AnnotationTypesProperty, _isCached);
113 | }
114 | }
115 | }
116 | }
--------------------------------------------------------------------------------
/UiaComWrapperX/StylesPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 | using System;
8 | using System.Collections;
9 | using System.Diagnostics;
10 | using System.Runtime.InteropServices;
11 | using UIAComWrapperInternal;
12 |
13 | namespace System.Windows.Automation
14 | {
15 | public class StylesPattern : BasePattern
16 | {
17 |
18 | private UIAutomationClient.IUIAutomationStylesPattern _pattern;
19 | public static readonly AutomationProperty StyleIdProperty = StylesPatternIdentifiers.StyleIdProperty;
20 | public static readonly AutomationProperty StyleNameProperty = StylesPatternIdentifiers.StyleNameProperty;
21 | public static readonly AutomationProperty FillColorProperty = StylesPatternIdentifiers.FillColorProperty;
22 | public static readonly AutomationProperty FillPatternStyleProperty = StylesPatternIdentifiers.FillPatternStyleProperty;
23 | public static readonly AutomationProperty ShapeProperty = StylesPatternIdentifiers.ShapeProperty;
24 | public static readonly AutomationProperty FillPatternColorProperty = StylesPatternIdentifiers.FillPatternColorProperty;
25 | public static readonly AutomationProperty ExtendedPropertiesProperty = StylesPatternIdentifiers.ExtendedPropertiesProperty;
26 | public static readonly AutomationPattern Pattern = StylesPatternIdentifiers.Pattern;
27 |
28 |
29 | private StylesPattern(AutomationElement el, UIAutomationClient.IUIAutomationStylesPattern pattern, bool cached)
30 | : base(el, cached)
31 | {
32 | Debug.Assert(pattern != null);
33 | this._pattern = pattern;
34 | }
35 |
36 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
37 | {
38 | return (pattern == null) ? null : new StylesPattern(el, (UIAutomationClient.IUIAutomationStylesPattern)pattern, cached);
39 | }
40 |
41 |
42 | public StylesPatternInformation Cached
43 | {
44 | get
45 | {
46 | Utility.ValidateCached(this._cached);
47 | return new StylesPatternInformation(this._el, true);
48 | }
49 | }
50 |
51 | public StylesPatternInformation Current
52 | {
53 | get
54 | {
55 | return new StylesPatternInformation(this._el, false);
56 | }
57 | }
58 |
59 |
60 | [StructLayout(LayoutKind.Sequential)]
61 | public struct StylesPatternInformation
62 | {
63 | private AutomationElement _el;
64 | private bool _isCached;
65 | internal StylesPatternInformation(AutomationElement element, bool isCached)
66 | {
67 | this._el = element;
68 | this._isCached = isCached;
69 | }
70 |
71 | public StyleId StyleId
72 | {
73 | get
74 | {
75 | return (StyleId)(int)this._el.GetPropertyValue(StylesPattern.StyleIdProperty, _isCached);
76 | }
77 | }
78 |
79 | public string StyleName
80 | {
81 | get
82 | {
83 | return (string)this._el.GetPropertyValue(StylesPattern.StyleNameProperty, _isCached);
84 | }
85 | }
86 |
87 | public int FillColor
88 | {
89 | get
90 | {
91 | return (int)this._el.GetPropertyValue(StylesPattern.FillColorProperty, _isCached);
92 | }
93 | }
94 |
95 | public string FillPatternStyle
96 | {
97 | get
98 | {
99 | return (string)this._el.GetPropertyValue(StylesPattern.FillPatternStyleProperty, _isCached);
100 | }
101 | }
102 |
103 | public string Shape
104 | {
105 | get
106 | {
107 | return (string)this._el.GetPropertyValue(StylesPattern.ShapeProperty, _isCached);
108 | }
109 | }
110 |
111 | public int FillPatternColor
112 | {
113 | get
114 | {
115 | return (int)this._el.GetPropertyValue(StylesPattern.FillPatternColorProperty, _isCached);
116 | }
117 | }
118 |
119 | public string ExtendedProperties
120 | {
121 | get
122 | {
123 | return (string)this._el.GetPropertyValue(StylesPattern.ExtendedPropertiesProperty, _isCached);
124 | }
125 | }
126 |
127 |
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/UiaComWrapperX/SynchronizedInput.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class SynchronizedInputPattern : BasePattern
17 | {
18 | private UIAutomationClient.IUIAutomationSynchronizedInputPattern _pattern;
19 | public static readonly AutomationEvent InputReachedTargetEvent = SynchronizedInputPatternIdentifiers.InputReachedTargetEvent;
20 | public static readonly AutomationEvent InputReachedOtherElementEvent = SynchronizedInputPatternIdentifiers.InputReachedOtherElementEvent;
21 | public static readonly AutomationEvent InputDiscardedEvent = SynchronizedInputPatternIdentifiers.InputDiscardedEvent;
22 | public static readonly AutomationPattern Pattern = SynchronizedInputPatternIdentifiers.Pattern;
23 |
24 | private SynchronizedInputPattern(AutomationElement el, UIAutomationClient.IUIAutomationSynchronizedInputPattern pattern, bool cached)
25 | : base(el, cached)
26 | {
27 | Debug.Assert(pattern != null);
28 | this._pattern = pattern;
29 | }
30 |
31 | public void Cancel()
32 | {
33 | try
34 | {
35 | this._pattern.Cancel();
36 | }
37 | catch (System.Runtime.InteropServices.COMException e)
38 | {
39 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
40 | }
41 | }
42 |
43 | public void StartListening(SynchronizedInputType type)
44 | {
45 | try
46 | {
47 | this._pattern.StartListening((UIAutomationClient.SynchronizedInputType)type);
48 | }
49 | catch (System.Runtime.InteropServices.COMException e)
50 | {
51 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
52 | }
53 | }
54 |
55 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
56 | {
57 | return (pattern == null) ? null : new SynchronizedInputPattern(el, (UIAutomationClient.IUIAutomationSynchronizedInputPattern)pattern, cached);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/UiaComWrapperX/TablePattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class TablePattern : GridPattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationTablePattern _pattern;
20 | public new static readonly AutomationPattern Pattern = TablePatternIdentifiers.Pattern;
21 | public static readonly AutomationProperty ColumnHeadersProperty = TablePatternIdentifiers.ColumnHeadersProperty;
22 | public static readonly AutomationProperty RowHeadersProperty = TablePatternIdentifiers.RowHeadersProperty;
23 | public static readonly AutomationProperty RowOrColumnMajorProperty = TablePatternIdentifiers.RowOrColumnMajorProperty;
24 |
25 |
26 |
27 | private TablePattern(AutomationElement el, UIAutomationClient.IUIAutomationTablePattern tablePattern, UIAutomationClient.IUIAutomationGridPattern gridPattern, bool cached)
28 | : base(el, gridPattern, cached)
29 | {
30 | Debug.Assert(tablePattern != null);
31 | this._pattern = tablePattern;
32 | }
33 |
34 | internal new static object Wrap(AutomationElement el, object pattern, bool cached)
35 | {
36 | TablePattern result = null;
37 | if (pattern != null)
38 | {
39 | UIAutomationClient.IUIAutomationGridPattern gridPattern =
40 | (UIAutomationClient.IUIAutomationGridPattern)el.GetRawPattern(GridPattern.Pattern, cached);
41 | if (gridPattern != null)
42 | {
43 | result = new TablePattern(el, (UIAutomationClient.IUIAutomationTablePattern)pattern,
44 | gridPattern, cached);
45 | }
46 | }
47 | return result;
48 | }
49 |
50 |
51 | public new TablePatternInformation Cached
52 | {
53 | get
54 | {
55 | Utility.ValidateCached(this._cached);
56 | return new TablePatternInformation(this._el, true);
57 | }
58 | }
59 |
60 | public new TablePatternInformation Current
61 | {
62 | get
63 | {
64 | return new TablePatternInformation(this._el, false);
65 | }
66 | }
67 |
68 |
69 |
70 | [StructLayout(LayoutKind.Sequential)]
71 | public struct TablePatternInformation
72 | {
73 | private AutomationElement _el;
74 | private bool _isCached;
75 | internal TablePatternInformation(AutomationElement element, bool isCached)
76 | {
77 | this._el = element;
78 | this._isCached = isCached;
79 | }
80 |
81 | public AutomationElement[] GetRowHeaders()
82 | {
83 | return (AutomationElement[])this._el.GetPropertyValue(TablePattern.RowHeadersProperty, _isCached);
84 | }
85 |
86 | public AutomationElement[] GetColumnHeaders()
87 | {
88 | return (AutomationElement[])this._el.GetPropertyValue(TablePattern.ColumnHeadersProperty, _isCached);
89 | }
90 |
91 | public int RowCount
92 | {
93 | get
94 | {
95 | return (int)this._el.GetPropertyValue(TablePattern.RowCountProperty, _isCached);
96 | }
97 | }
98 | public int ColumnCount
99 | {
100 | get
101 | {
102 | return (int)this._el.GetPropertyValue(TablePattern.ColumnCountProperty, _isCached);
103 | }
104 | }
105 | public RowOrColumnMajor RowOrColumnMajor
106 | {
107 | get
108 | {
109 | return (RowOrColumnMajor)this._el.GetPropertyValue(TablePattern.RowOrColumnMajorProperty, _isCached);
110 | }
111 | }
112 | }
113 | }
114 |
115 | public class TableItemPattern : GridItemPattern
116 | {
117 |
118 | private UIAutomationClient.IUIAutomationTableItemPattern _pattern;
119 | public new static readonly AutomationPattern Pattern = TableItemPatternIdentifiers.Pattern;
120 | public static readonly AutomationProperty ColumnHeaderItemsProperty = TableItemPatternIdentifiers.ColumnHeaderItemsProperty;
121 | public static readonly AutomationProperty RowHeaderItemsProperty = TableItemPatternIdentifiers.RowHeaderItemsProperty;
122 |
123 |
124 | private TableItemPattern(AutomationElement el, UIAutomationClient.IUIAutomationTableItemPattern tablePattern, UIAutomationClient.IUIAutomationGridItemPattern gridPattern, bool cached)
125 | : base(el, gridPattern, cached)
126 | {
127 | Debug.Assert(tablePattern != null);
128 | this._pattern = tablePattern;
129 | }
130 |
131 | internal new static object Wrap(AutomationElement el, object pattern, bool cached)
132 | {
133 | TableItemPattern result = null;
134 | if (pattern != null)
135 | {
136 | UIAutomationClient.IUIAutomationGridItemPattern gridPattern =
137 | (UIAutomationClient.IUIAutomationGridItemPattern)el.GetRawPattern(GridItemPattern.Pattern, cached);
138 | if (gridPattern != null)
139 | {
140 | result = new TableItemPattern(el, (UIAutomationClient.IUIAutomationTableItemPattern)pattern,
141 | gridPattern, cached);
142 | }
143 | }
144 | return result;
145 | }
146 |
147 |
148 | public new TableItemPatternInformation Cached
149 | {
150 | get
151 | {
152 | Utility.ValidateCached(this._cached);
153 | return new TableItemPatternInformation(this._el, true);
154 | }
155 | }
156 |
157 | public new TableItemPatternInformation Current
158 | {
159 | get
160 | {
161 | return new TableItemPatternInformation(this._el, false);
162 | }
163 | }
164 |
165 |
166 |
167 | [StructLayout(LayoutKind.Sequential)]
168 | public struct TableItemPatternInformation
169 | {
170 | private AutomationElement _el;
171 | private bool _isCached;
172 | internal TableItemPatternInformation(AutomationElement element, bool isCached)
173 | {
174 | this._el = element;
175 | this._isCached = isCached;
176 | }
177 |
178 | public int Row
179 | {
180 | get
181 | {
182 | return (int)this._el.GetPropertyValue(TableItemPattern.RowProperty, _isCached);
183 | }
184 | }
185 | public int Column
186 | {
187 | get
188 | {
189 | return (int)this._el.GetPropertyValue(TableItemPattern.ColumnProperty, _isCached);
190 | }
191 | }
192 | public int RowSpan
193 | {
194 | get
195 | {
196 | return (int)this._el.GetPropertyValue(TableItemPattern.RowSpanProperty, _isCached);
197 | }
198 | }
199 | public int ColumnSpan
200 | {
201 | get
202 | {
203 | return (int)this._el.GetPropertyValue(TableItemPattern.ColumnSpanProperty, _isCached);
204 | }
205 | }
206 | public AutomationElement ContainingGrid
207 | {
208 | get
209 | {
210 | return (AutomationElement)this._el.GetPropertyValue(TableItemPattern.ContainingGridProperty, _isCached);
211 | }
212 | }
213 |
214 | public AutomationElement[] GetRowHeaderItems()
215 | {
216 | return (AutomationElement[])this._el.GetPropertyValue(TableItemPattern.RowHeaderItemsProperty, _isCached);
217 | }
218 |
219 | public AutomationElement[] GetColumnHeaderItems()
220 | {
221 | return (AutomationElement[])this._el.GetPropertyValue(TableItemPattern.ColumnHeaderItemsProperty, _isCached);
222 | }
223 | }
224 | }
225 | }
--------------------------------------------------------------------------------
/UiaComWrapperX/TextChildPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 | using System;
8 | using System.Collections;
9 | using System.Diagnostics;
10 | using System.Runtime.InteropServices;
11 | using System.Windows.Automation.Text;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class TextChildPattern : BasePattern
17 | {
18 | private UIAutomationClient.IUIAutomationTextChildPattern _pattern;
19 | public static readonly AutomationPattern Pattern = TextChildPatternIdentifiers.Pattern;
20 |
21 | private TextChildPattern(AutomationElement el, UIAutomationClient.IUIAutomationTextChildPattern pattern, bool cached)
22 | : base(el, cached)
23 | {
24 | Debug.Assert(pattern != null);
25 | this._pattern = pattern;
26 | }
27 |
28 | public AutomationElement TextContainer
29 | {
30 | get
31 | {
32 | try
33 | {
34 | return AutomationElement.Wrap(this._pattern.TextContainer);
35 | }
36 | catch (System.Runtime.InteropServices.COMException e)
37 | {
38 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
39 | }
40 | }
41 | }
42 |
43 | public TextPatternRange TextRange
44 | {
45 | get
46 | {
47 | try
48 | {
49 | AutomationElement textContainer = this.TextContainer;
50 | TextPattern textPattern = (TextPattern)textContainer.GetCurrentPattern(TextPattern.Pattern);
51 | return TextPatternRange.Wrap(this._pattern.TextRange, textPattern);
52 | }
53 | catch (System.Runtime.InteropServices.COMException e)
54 | {
55 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
56 | }
57 | }
58 | }
59 |
60 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
61 | {
62 | return (pattern == null) ? null : new TextChildPattern(el, (UIAutomationClient.IUIAutomationTextChildPattern)pattern, cached);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/UiaComWrapperX/TextTypes.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Runtime.InteropServices;
10 |
11 | namespace System.Windows.Automation.Text
12 | {
13 | [Guid("B6C08F15-AA5E-4754-9E4C-AA279D3F36D4")]
14 | [ComVisible(true)]
15 | public enum AnimationStyle
16 | {
17 | None = 0,
18 | LasVegasLights = 1,
19 | BlinkingBackground = 2,
20 | SparkleText = 3,
21 | MarchingBlackAnts = 4,
22 | MarchingRedAnts = 5,
23 | Shimmer = 6,
24 | Other = -1,
25 | }
26 |
27 | [Guid("814FAC6C-F8DE-4682-AF5F-37C4F720990C")]
28 | [ComVisible(true)]
29 | public enum BulletStyle
30 | {
31 | None = 0,
32 | HollowRoundBullet = 1,
33 | FilledRoundBullet = 2,
34 | HollowSquareBullet = 3,
35 | FilledSquareBullet = 4,
36 | DashBullet = 5,
37 | Other = -1
38 | }
39 |
40 | [Guid("4E33C74B-7848-4f1e-B819-A0D866C2EA1F")]
41 | [ComVisible(true)]
42 | public enum CapStyle
43 | {
44 | None = 0,
45 | SmallCap = 1,
46 | AllCap = 2,
47 | AllPetiteCaps = 3,
48 | PetiteCaps = 4,
49 | Unicase = 5,
50 | Titling = 6,
51 | Other = -1,
52 | }
53 |
54 | [Guid("2E22CC6B-7C34-4002-91AA-E103A09D1027")]
55 | [Flags]
56 | [ComVisible(true)]
57 | public enum FlowDirections
58 | {
59 | Default = 0,
60 | RightToLeft = 1,
61 | BottomToTop = 2,
62 | Vertical = 4
63 | }
64 |
65 | [Guid("1FBE7021-A1E4-4e9b-BE94-2C7DFA59D5DD")]
66 | [ComVisible(true)]
67 | public enum HorizontalTextAlignment
68 | {
69 | Left,
70 | Centered,
71 | Right,
72 | Justified
73 | }
74 |
75 | [Guid("1F57B37D-CB59-43f4-95E0-7C9E40DB427E")]
76 | [ComVisible(true)]
77 | [Flags]
78 | public enum OutlineStyles
79 | {
80 | None = 0,
81 | Outline = 1,
82 | Shadow = 2,
83 | Engraved = 4,
84 | Embossed = 8,
85 | }
86 |
87 | [Guid("909D8633-2941-428e-A549-C752E2FC078C")]
88 | [ComVisible(true)]
89 | public enum TextDecorationLineStyle
90 | {
91 | None = 0,
92 | Single = 1,
93 | WordsOnly = 2,
94 | Double = 3,
95 | Dot = 4,
96 | Dash = 5,
97 | DashDot = 6,
98 | DashDotDot = 7,
99 | Wavy = 8,
100 | ThickSingle = 9,
101 | DoubleWavy = 11,
102 | ThickWavy = 12,
103 | LongDash = 13,
104 | ThickDash = 14,
105 | ThickDashDot = 15,
106 | ThickDashDotDot = 16,
107 | ThickDot = 17,
108 | ThickLongDash = 18,
109 | Other = -1,
110 | }
111 |
112 | [Guid("62242CAC-9CD0-4364-813D-4F0A36DD842D")]
113 | [ComVisible(true)]
114 | public enum TextPatternRangeEndpoint
115 | {
116 | Start,
117 | End
118 | }
119 |
120 | [ComVisible(true)]
121 | [Guid("A044E5C8-FC20-4747-8CC8-1487F9CBB680")]
122 | public enum TextUnit
123 | {
124 | Character,
125 | Format,
126 | Word,
127 | Line,
128 | Paragraph,
129 | Page,
130 | Document
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/UiaComWrapperX/TogglePattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class TogglePattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationTogglePattern _pattern;
20 | public static readonly AutomationPattern Pattern = TogglePatternIdentifiers.Pattern;
21 | public static readonly AutomationProperty ToggleStateProperty = TogglePatternIdentifiers.ToggleStateProperty;
22 |
23 |
24 | private TogglePattern(AutomationElement el, UIAutomationClient.IUIAutomationTogglePattern pattern, bool cached)
25 | : base(el, cached)
26 | {
27 | Debug.Assert(pattern != null);
28 | this._pattern = pattern;
29 | }
30 |
31 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
32 | {
33 | return (pattern == null) ? null : new TogglePattern(el, (UIAutomationClient.IUIAutomationTogglePattern)pattern, cached);
34 | }
35 |
36 | public void Toggle()
37 | {
38 | try
39 | {
40 | this._pattern.Toggle();
41 | }
42 | catch (System.Runtime.InteropServices.COMException e)
43 | {
44 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
45 | }
46 | }
47 |
48 |
49 | public TogglePatternInformation Cached
50 | {
51 | get
52 | {
53 | Utility.ValidateCached(this._cached);
54 | return new TogglePatternInformation(this._el, true);
55 | }
56 | }
57 |
58 | public TogglePatternInformation Current
59 | {
60 | get
61 | {
62 | return new TogglePatternInformation(this._el, false);
63 | }
64 | }
65 |
66 |
67 |
68 | [StructLayout(LayoutKind.Sequential)]
69 | public struct TogglePatternInformation
70 | {
71 | private AutomationElement _el;
72 | private bool _isCached;
73 | internal TogglePatternInformation(AutomationElement element, bool isCached)
74 | {
75 | this._el = element;
76 | this._isCached = isCached;
77 | }
78 |
79 | public ToggleState ToggleState
80 | {
81 | get
82 | {
83 | return (ToggleState)this._el.GetPropertyValue(TogglePattern.ToggleStateProperty, _isCached);
84 | }
85 | }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/UiaComWrapperX/TreeWalker.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public sealed class TreeWalker
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationTreeWalker _obj;
20 | public static readonly TreeWalker ContentViewWalker = new TreeWalker(System.Windows.Automation.Automation.ContentViewCondition);
21 | public static readonly TreeWalker ControlViewWalker = new TreeWalker(System.Windows.Automation.Automation.ControlViewCondition);
22 | public static readonly TreeWalker RawViewWalker = new TreeWalker(System.Windows.Automation.Automation.RawViewCondition);
23 |
24 |
25 | public TreeWalker(Condition condition)
26 | {
27 | // This is an unusual situation - a direct constructor.
28 | // We have to go create the native tree walker, which might throw.
29 | Utility.ValidateArgumentNonNull(condition, "condition");
30 | try
31 | {
32 | this._obj = Automation.Factory.CreateTreeWalker(condition.NativeCondition);
33 | }
34 | catch (System.Runtime.InteropServices.COMException e)
35 | {
36 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
37 | }
38 | }
39 |
40 | internal TreeWalker(UIAutomationClient.IUIAutomationTreeWalker obj)
41 | {
42 | Debug.Assert(obj != null);
43 | _obj = obj;
44 | }
45 |
46 | internal TreeWalker Wrap(UIAutomationClient.IUIAutomationTreeWalker obj)
47 | {
48 | return (obj == null) ? null : Wrap(obj);
49 | }
50 |
51 | public AutomationElement GetFirstChild(AutomationElement element)
52 | {
53 | return GetFirstChild(element, CacheRequest.Current);
54 | }
55 |
56 | public AutomationElement GetFirstChild(AutomationElement element, CacheRequest request)
57 | {
58 | Utility.ValidateArgumentNonNull(element, "element");
59 | Utility.ValidateArgumentNonNull(request, "request");
60 | try
61 | {
62 | return AutomationElement.Wrap(this._obj.GetFirstChildElementBuildCache(
63 | element.NativeElement,
64 | request.NativeCacheRequest));
65 | }
66 | catch (System.Runtime.InteropServices.COMException e)
67 | {
68 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
69 | }
70 | }
71 |
72 | public AutomationElement GetLastChild(AutomationElement element)
73 | {
74 | return GetLastChild(element, CacheRequest.Current);
75 | }
76 |
77 | public AutomationElement GetLastChild(AutomationElement element, CacheRequest request)
78 | {
79 | Utility.ValidateArgumentNonNull(element, "element");
80 | Utility.ValidateArgumentNonNull(request, "request");
81 | try
82 | {
83 | return AutomationElement.Wrap(this._obj.GetLastChildElementBuildCache(
84 | element.NativeElement,
85 | request.NativeCacheRequest));
86 | }
87 | catch (System.Runtime.InteropServices.COMException e)
88 | {
89 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
90 | }
91 | }
92 |
93 | public AutomationElement GetNextSibling(AutomationElement element)
94 | {
95 | return GetNextSibling(element, CacheRequest.Current);
96 | }
97 |
98 | public AutomationElement GetNextSibling(AutomationElement element, CacheRequest request)
99 | {
100 | Utility.ValidateArgumentNonNull(element, "element");
101 | Utility.ValidateArgumentNonNull(request, "request");
102 | try
103 | {
104 | return AutomationElement.Wrap(this._obj.GetNextSiblingElementBuildCache(
105 | element.NativeElement,
106 | request.NativeCacheRequest));
107 | }
108 | catch (System.Runtime.InteropServices.COMException e)
109 | {
110 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
111 | }
112 | }
113 |
114 | public AutomationElement GetParent(AutomationElement element)
115 | {
116 | return GetParent(element, CacheRequest.Current);
117 | }
118 |
119 | public AutomationElement GetParent(AutomationElement element, CacheRequest request)
120 | {
121 | Utility.ValidateArgumentNonNull(element, "element");
122 | Utility.ValidateArgumentNonNull(request, "request");
123 | try
124 | {
125 | return AutomationElement.Wrap(this._obj.GetParentElementBuildCache(
126 | element.NativeElement,
127 | request.NativeCacheRequest));
128 | }
129 | catch (System.Runtime.InteropServices.COMException e)
130 | {
131 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
132 | }
133 | }
134 |
135 | public AutomationElement GetPreviousSibling(AutomationElement element)
136 | {
137 | return GetPreviousSibling(element, CacheRequest.Current);
138 | }
139 |
140 | public AutomationElement GetPreviousSibling(AutomationElement element, CacheRequest request)
141 | {
142 | Utility.ValidateArgumentNonNull(element, "element");
143 | Utility.ValidateArgumentNonNull(request, "request");
144 | try
145 | {
146 | return AutomationElement.Wrap(this._obj.GetPreviousSiblingElementBuildCache(
147 | element.NativeElement,
148 | request.NativeCacheRequest));
149 | }
150 | catch (System.Runtime.InteropServices.COMException e)
151 | {
152 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
153 | }
154 | }
155 |
156 | public AutomationElement Normalize(AutomationElement element)
157 | {
158 | return Normalize(element, CacheRequest.Current);
159 | }
160 |
161 | public AutomationElement Normalize(AutomationElement element, CacheRequest request)
162 | {
163 | Utility.ValidateArgumentNonNull(element, "element");
164 | Utility.ValidateArgumentNonNull(request, "request");
165 | try
166 | {
167 | return AutomationElement.Wrap(this._obj.NormalizeElementBuildCache(
168 | element.NativeElement,
169 | request.NativeCacheRequest));
170 | }
171 | catch (System.Runtime.InteropServices.COMException e)
172 | {
173 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
174 | }
175 | }
176 |
177 |
178 | public Condition Condition
179 | {
180 | get
181 | {
182 | try
183 | {
184 | return Condition.Wrap(_obj.condition);
185 | }
186 | catch (System.Runtime.InteropServices.COMException e)
187 | {
188 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
189 | }
190 | }
191 | }
192 | }
193 | }
--------------------------------------------------------------------------------
/UiaComWrapperX/UIAComWrapper.ncrunchproject:
--------------------------------------------------------------------------------
1 |
2 | false
3 | false
4 | false
5 | true
6 | false
7 | false
8 | false
9 | false
10 | true
11 | true
12 | false
13 | true
14 | true
15 | 60000
16 |
17 |
18 |
19 | AutoDetect
20 | STA
21 | x86
22 |
--------------------------------------------------------------------------------
/UiaComWrapperX/UIAComWrapper.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/technoscavenger/UIAComWrapperX/94171c31c78386b5180e347cfc7baae1f5d25b12/UiaComWrapperX/UIAComWrapper.snk
--------------------------------------------------------------------------------
/UiaComWrapperX/UIAComWrapperX.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | AnyCPU
5 | Debug
6 | 9.0.30729
7 | 2.0
8 | {1DD63894-DBB9-40EF-BFF2-55624CB285AF}
9 | Library
10 | Properties
11 | UIAComWrapperX
12 | UIAComWrapperX
13 | v4.5.2
14 | 512
15 | 3.5
16 |
17 | publish\
18 | true
19 | Disk
20 | false
21 | Foreground
22 | 7
23 | Days
24 | false
25 | false
26 | true
27 | 0
28 | 1.0.0.%2a
29 | false
30 | false
31 | true
32 |
33 |
34 | true
35 | full
36 | false
37 | bin\debug\
38 | DEBUG;TRACE
39 | prompt
40 | 4
41 | false
42 |
43 |
44 | pdbonly
45 | true
46 | bin\release\
47 | TRACE
48 | prompt
49 | 4
50 | false
51 |
52 |
53 | true
54 |
55 |
56 | UIAComWrapper.snk
57 |
58 |
59 |
60 |
61 | False
62 | False
63 | ..\Libs\Interop.UIAutomationClient.dll
64 |
65 |
66 |
67 | 3.5
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | True
102 | True
103 | StringTable.resx
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1 Client Profile
129 | false
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | true
135 |
136 |
137 |
138 |
139 | ResXFileCodeGenerator
140 | StringTable.Designer.cs
141 | Designer
142 |
143 |
144 |
145 |
146 | Always
147 |
148 |
149 | Always
150 | Designer
151 |
152 |
153 |
154 |
155 |
162 |
--------------------------------------------------------------------------------
/UiaComWrapperX/UIAComWrapperX.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | UIAComWrapperX
5 | 1.1.0.16
6 | UIAComWrapperX
7 | Techno Scavenger
8 | Michael Bernstein, Jake Ginnivan
9 | https://github.com/technoscavenger/UIAComWrapperX
10 | MIT
11 | false
12 | The UI Automation COM-to-.NET Adapter makes it possible to use the new Windows Automation API 3.0 COM interfaces, with their improved reliability and performance, while still using the same System.Windows.Automation classes as in earlier versions of UI Automation
13 | Copyright Techno Scavenger 2019
14 | UIA
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/UiaComWrapperX/UiaCoreProviderApi.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Runtime.InteropServices;
10 | using System.Security;
11 | using System.Windows.Automation.Providers;
12 | using UIAutomationClient;
13 |
14 | namespace UIAComWrapperInternal
15 | {
16 | ///
17 | /// P/Invoke definitions for flat UI Automation Core functions
18 | ///
19 | internal static class UiaCoreProviderApi
20 | {
21 | // Methods
22 | private static void CheckError(int hr)
23 | {
24 | if (hr < 0)
25 | {
26 | Marshal.ThrowExceptionForHR(hr);
27 | }
28 | }
29 |
30 | [SuppressUnmanagedCodeSecurity, SecurityCritical, DllImport("UIAutomationCore.dll", EntryPoint = "UiaClientsAreListening", CharSet = CharSet.Unicode)]
31 | private static extern bool RawUiaClientsAreListening();
32 |
33 | [SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("UIAutomationCore.dll", EntryPoint = "UiaHostProviderFromHwnd", CharSet = CharSet.Unicode)]
34 | private static extern int RawUiaHostProviderFromHwnd(IntPtr hwnd, [MarshalAs(UnmanagedType.Interface)] out IRawElementProviderSimple provider);
35 |
36 | [SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("UIAutomationCore.dll", EntryPoint = "UiaRaiseAsyncContentLoadedEvent", CharSet = CharSet.Unicode)]
37 | private static extern int RawUiaRaiseAsyncContentLoadedEvent(IRawElementProviderSimple provider, System.Windows.Automation.AsyncContentLoadedState asyncContentLoadedState, double PercentComplete);
38 |
39 | [SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("UIAutomationCore.dll", EntryPoint = "UiaRaiseAutomationEvent", CharSet = CharSet.Unicode)]
40 | private static extern int RawUiaRaiseAutomationEvent(IRawElementProviderSimple provider, int id);
41 |
42 | [SuppressUnmanagedCodeSecurity, SecurityCritical, DllImport("UIAutomationCore.dll", EntryPoint = "UiaRaiseAutomationPropertyChangedEvent", CharSet = CharSet.Unicode)]
43 | private static extern int RawUiaRaiseAutomationPropertyChangedEvent(IRawElementProviderSimple provider, int id, object oldValue, object newValue);
44 |
45 | [SuppressUnmanagedCodeSecurity, SecurityCritical, DllImport("UIAutomationCore.dll", EntryPoint = "UiaRaiseStructureChangedEvent", CharSet = CharSet.Unicode)]
46 | private static extern int RawUiaRaiseStructureChangedEvent(IRawElementProviderSimple provider, StructureChangeType structureChangeType, int[] runtimeId, int runtimeIdLen);
47 |
48 | [SecurityCritical, SuppressUnmanagedCodeSecurity, DllImport("UIAutomationCore.dll", EntryPoint = "UiaReturnRawElementProvider", CharSet = CharSet.Unicode)]
49 | private static extern IntPtr RawUiaReturnRawElementProvider(IntPtr hwnd, IntPtr wParam, IntPtr lParam, IRawElementProviderSimple el);
50 |
51 | [SecurityCritical, SecuritySafeCritical]
52 | internal static bool UiaClientsAreListening()
53 | {
54 | return RawUiaClientsAreListening();
55 | }
56 |
57 | [SecuritySafeCritical, SecurityCritical]
58 | internal static IRawElementProviderSimple UiaHostProviderFromHwnd(IntPtr hwnd)
59 | {
60 | IRawElementProviderSimple simple;
61 | CheckError(RawUiaHostProviderFromHwnd(hwnd, out simple));
62 | return simple;
63 | }
64 |
65 | [SecuritySafeCritical, SecurityCritical]
66 | internal static void UiaRaiseAsyncContentLoadedEvent(IRawElementProviderSimple provider, System.Windows.Automation.AsyncContentLoadedState asyncContentLoadedState, double PercentComplete)
67 | {
68 | CheckError(RawUiaRaiseAsyncContentLoadedEvent(provider, asyncContentLoadedState, PercentComplete));
69 | }
70 |
71 | [SecurityCritical, SecuritySafeCritical]
72 | internal static void UiaRaiseAutomationEvent(IRawElementProviderSimple provider, int eventId)
73 | {
74 | CheckError(RawUiaRaiseAutomationEvent(provider, eventId));
75 | }
76 |
77 | [SecurityCritical, SecuritySafeCritical]
78 | internal static void UiaRaiseAutomationPropertyChangedEvent(IRawElementProviderSimple provider, int propertyId, object oldValue, object newValue)
79 | {
80 | CheckError(RawUiaRaiseAutomationPropertyChangedEvent(provider, propertyId, oldValue, newValue));
81 | }
82 |
83 | [SecuritySafeCritical, SecurityCritical]
84 | internal static void UiaRaiseStructureChangedEvent(IRawElementProviderSimple provider, StructureChangeType structureChangeType, int[] runtimeId)
85 | {
86 | CheckError(RawUiaRaiseStructureChangedEvent(provider, structureChangeType, runtimeId, (runtimeId == null) ? 0 : runtimeId.Length));
87 | }
88 |
89 | [SecurityCritical, SecuritySafeCritical]
90 | internal static IntPtr UiaReturnRawElementProvider(IntPtr hwnd, IntPtr wParam, IntPtr lParam, IRawElementProviderSimple el)
91 | {
92 | return RawUiaReturnRawElementProvider(hwnd, wParam, lParam, el);
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/UiaComWrapperX/ValuePattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class RangeValuePattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationRangeValuePattern _pattern;
20 | public static readonly AutomationPattern Pattern = RangeValuePatternIdentifiers.Pattern;
21 | public static readonly AutomationProperty IsReadOnlyProperty = RangeValuePatternIdentifiers.IsReadOnlyProperty;
22 | public static readonly AutomationProperty LargeChangeProperty = RangeValuePatternIdentifiers.LargeChangeProperty;
23 | public static readonly AutomationProperty MaximumProperty = RangeValuePatternIdentifiers.MaximumProperty;
24 | public static readonly AutomationProperty MinimumProperty = RangeValuePatternIdentifiers.MinimumProperty;
25 | public static readonly AutomationProperty SmallChangeProperty = RangeValuePatternIdentifiers.SmallChangeProperty;
26 | public static readonly AutomationProperty ValueProperty = RangeValuePatternIdentifiers.ValueProperty;
27 |
28 |
29 | private RangeValuePattern(AutomationElement el, UIAutomationClient.IUIAutomationRangeValuePattern pattern, bool cached)
30 | : base(el, cached)
31 | {
32 | Debug.Assert(pattern != null);
33 | this._pattern = pattern;
34 | }
35 |
36 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
37 | {
38 | return (pattern == null) ? null : new RangeValuePattern(el, (UIAutomationClient.IUIAutomationRangeValuePattern)pattern, cached);
39 | }
40 |
41 | public void SetValue(double value)
42 | {
43 | try
44 | {
45 | this._pattern.SetValue(value);
46 | }
47 | catch (System.Runtime.InteropServices.COMException e)
48 | {
49 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
50 | }
51 | }
52 |
53 |
54 | public RangeValuePatternInformation Cached
55 | {
56 | get
57 | {
58 | Utility.ValidateCached(this._cached);
59 | return new RangeValuePatternInformation(this._el, true);
60 | }
61 | }
62 |
63 | public RangeValuePatternInformation Current
64 | {
65 | get
66 | {
67 | return new RangeValuePatternInformation(this._el, false);
68 | }
69 | }
70 |
71 | [StructLayout(LayoutKind.Sequential)]
72 | public struct RangeValuePatternInformation
73 | {
74 | private AutomationElement _el;
75 | private bool _isCached;
76 | internal RangeValuePatternInformation(AutomationElement element, bool isCached)
77 | {
78 | this._el = element;
79 | this._isCached = isCached;
80 | }
81 |
82 | public double Value
83 | {
84 | get
85 | {
86 | return (double)this._el.GetPropertyValue(RangeValuePattern.ValueProperty, _isCached);
87 | }
88 | }
89 | public bool IsReadOnly
90 | {
91 | get
92 | {
93 | return (bool)this._el.GetPropertyValue(RangeValuePattern.IsReadOnlyProperty, _isCached);
94 | }
95 | }
96 | public double Maximum
97 | {
98 | get
99 | {
100 | return (double)this._el.GetPropertyValue(RangeValuePattern.MaximumProperty, _isCached);
101 | }
102 | }
103 | public double Minimum
104 | {
105 | get
106 | {
107 | return (double)this._el.GetPropertyValue(RangeValuePattern.MinimumProperty, _isCached);
108 | }
109 | }
110 | public double LargeChange
111 | {
112 | get
113 | {
114 | return (double)this._el.GetPropertyValue(RangeValuePattern.LargeChangeProperty, _isCached);
115 | }
116 | }
117 | public double SmallChange
118 | {
119 | get
120 | {
121 | return (double)this._el.GetPropertyValue(RangeValuePattern.SmallChangeProperty, _isCached);
122 | }
123 | }
124 | }
125 | }
126 |
127 | public class ValuePattern : BasePattern
128 | {
129 |
130 | private UIAutomationClient.IUIAutomationValuePattern _pattern;
131 | public static readonly AutomationPattern Pattern = ValuePatternIdentifiers.Pattern;
132 | public static readonly AutomationProperty IsReadOnlyProperty = ValuePatternIdentifiers.IsReadOnlyProperty;
133 | public static readonly AutomationProperty ValueProperty = ValuePatternIdentifiers.ValueProperty;
134 |
135 |
136 |
137 | private ValuePattern(AutomationElement el, UIAutomationClient.IUIAutomationValuePattern pattern, bool cached)
138 | : base(el, cached)
139 | {
140 | Debug.Assert(pattern != null);
141 | this._pattern = pattern;
142 | }
143 |
144 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
145 | {
146 | return (pattern == null) ? null : new ValuePattern(el, (UIAutomationClient.IUIAutomationValuePattern)pattern, cached);
147 | }
148 |
149 | public void SetValue(string value)
150 | {
151 | try
152 | {
153 | this._pattern.SetValue(value);
154 | }
155 | catch (System.Runtime.InteropServices.COMException e)
156 | {
157 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
158 | }
159 | }
160 |
161 |
162 | public ValuePatternInformation Cached
163 | {
164 | get
165 | {
166 | Utility.ValidateCached(this._cached);
167 | return new ValuePatternInformation(this._el, true);
168 | }
169 | }
170 |
171 | public ValuePatternInformation Current
172 | {
173 | get
174 | {
175 | return new ValuePatternInformation(this._el, false);
176 | }
177 | }
178 |
179 |
180 |
181 | [StructLayout(LayoutKind.Sequential)]
182 | public struct ValuePatternInformation
183 | {
184 | private AutomationElement _el;
185 | private bool _isCached;
186 | internal ValuePatternInformation(AutomationElement element, bool isCached)
187 | {
188 | this._el = element;
189 | this._isCached = isCached;
190 | }
191 |
192 | public string Value
193 | {
194 | get
195 | {
196 | return (string)this._el.GetPropertyValue(ValuePattern.ValueProperty, _isCached);
197 | }
198 | }
199 |
200 | public bool IsReadOnly
201 | {
202 | get
203 | {
204 | return (bool)this._el.GetPropertyValue(ValuePattern.IsReadOnlyProperty, _isCached);
205 | }
206 | }
207 | }
208 | }
209 | }
210 |
--------------------------------------------------------------------------------
/UiaComWrapperX/VirtualizedPatterns.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class ItemContainerPattern : BasePattern
17 | {
18 | private UIAutomationClient.IUIAutomationItemContainerPattern _pattern;
19 | public static readonly AutomationPattern Pattern = ItemContainerPatternIdentifiers.Pattern;
20 |
21 | private ItemContainerPattern(AutomationElement el, UIAutomationClient.IUIAutomationItemContainerPattern pattern, bool cached)
22 | : base(el, cached)
23 | {
24 | Debug.Assert(pattern != null);
25 | this._pattern = pattern;
26 | }
27 |
28 | public AutomationElement FindItemByProperty(AutomationElement startAfter, AutomationProperty property, object value)
29 | {
30 | try
31 | {
32 | return AutomationElement.Wrap(
33 | this._pattern.FindItemByProperty(
34 | (startAfter == null) ? null : startAfter.NativeElement,
35 | (property == null) ? 0 : property.Id,
36 | Utility.UnwrapObject(value)));
37 | }
38 | catch (System.Runtime.InteropServices.COMException e)
39 | {
40 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
41 | }
42 | }
43 |
44 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
45 | {
46 | return (pattern == null) ? null : new ItemContainerPattern(el, (UIAutomationClient.IUIAutomationItemContainerPattern)pattern, cached);
47 | }
48 | }
49 |
50 | public class VirtualizedItemPattern : BasePattern
51 | {
52 | private UIAutomationClient.IUIAutomationVirtualizedItemPattern _pattern;
53 | public static readonly AutomationPattern Pattern = VirtualizedItemPatternIdentifiers.Pattern;
54 |
55 | private VirtualizedItemPattern(AutomationElement el, UIAutomationClient.IUIAutomationVirtualizedItemPattern pattern, bool cached)
56 | : base(el, cached)
57 | {
58 | Debug.Assert(pattern != null);
59 | this._pattern = pattern;
60 | }
61 |
62 | public void Realize()
63 | {
64 | try
65 | {
66 | this._pattern.Realize();
67 | }
68 | catch (System.Runtime.InteropServices.COMException e)
69 | {
70 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
71 | }
72 | }
73 |
74 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
75 | {
76 | return (pattern == null) ? null : new VirtualizedItemPattern(el, (UIAutomationClient.IUIAutomationVirtualizedItemPattern)pattern, cached);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/UiaComWrapperX/WindowPattern.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft, 2012.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 |
7 |
8 | using System;
9 | using System.Collections;
10 | using System.Diagnostics;
11 | using System.Runtime.InteropServices;
12 | using UIAComWrapperInternal;
13 |
14 | namespace System.Windows.Automation
15 | {
16 | public class WindowPattern : BasePattern
17 | {
18 |
19 | private UIAutomationClient.IUIAutomationWindowPattern _pattern;
20 | public static readonly AutomationPattern Pattern = WindowPatternIdentifiers.Pattern;
21 | public static readonly AutomationProperty CanMaximizeProperty = WindowPatternIdentifiers.CanMaximizeProperty;
22 | public static readonly AutomationProperty CanMinimizeProperty = WindowPatternIdentifiers.CanMinimizeProperty;
23 | public static readonly AutomationProperty IsModalProperty = WindowPatternIdentifiers.IsModalProperty;
24 | public static readonly AutomationProperty IsTopmostProperty = WindowPatternIdentifiers.IsTopmostProperty;
25 | public static readonly AutomationEvent WindowClosedEvent = WindowPatternIdentifiers.WindowClosedEvent;
26 | public static readonly AutomationProperty WindowInteractionStateProperty = WindowPatternIdentifiers.WindowInteractionStateProperty;
27 | public static readonly AutomationEvent WindowOpenedEvent = WindowPatternIdentifiers.WindowOpenedEvent;
28 | public static readonly AutomationProperty WindowVisualStateProperty = WindowPatternIdentifiers.WindowVisualStateProperty;
29 |
30 |
31 | private WindowPattern(AutomationElement el, UIAutomationClient.IUIAutomationWindowPattern pattern, bool cached)
32 | : base(el, cached)
33 | {
34 | Debug.Assert(pattern != null);
35 | this._pattern = pattern;
36 | }
37 |
38 | internal static object Wrap(AutomationElement el, object pattern, bool cached)
39 | {
40 | return (pattern == null) ? null : new WindowPattern(el, (UIAutomationClient.IUIAutomationWindowPattern)pattern, cached);
41 | }
42 |
43 | public void Close()
44 | {
45 | try
46 | {
47 | this._pattern.Close();
48 | }
49 | catch (System.Runtime.InteropServices.COMException e)
50 | {
51 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
52 | }
53 | }
54 |
55 | public void SetWindowVisualState(WindowVisualState state)
56 | {
57 | try
58 | {
59 | this._pattern.SetWindowVisualState((UIAutomationClient.WindowVisualState)state);
60 | }
61 | catch (System.Runtime.InteropServices.COMException e)
62 | {
63 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
64 | }
65 | }
66 |
67 | public bool WaitForInputIdle(int milliseconds)
68 | {
69 | try
70 | {
71 | return (0 != this._pattern.WaitForInputIdle(milliseconds));
72 | }
73 | catch (System.Runtime.InteropServices.COMException e)
74 | {
75 | Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
76 | }
77 | }
78 |
79 | public WindowPatternInformation Cached
80 | {
81 | get
82 | {
83 | Utility.ValidateCached(this._cached);
84 | return new WindowPatternInformation(this._el, true);
85 | }
86 | }
87 |
88 | public WindowPatternInformation Current
89 | {
90 | get
91 | {
92 | return new WindowPatternInformation(this._el, false);
93 | }
94 | }
95 |
96 | [StructLayout(LayoutKind.Sequential)]
97 | public struct WindowPatternInformation
98 | {
99 | private AutomationElement _el;
100 | private bool _isCached;
101 | internal WindowPatternInformation(AutomationElement element, bool isCached)
102 | {
103 | this._el = element;
104 | this._isCached = isCached;
105 | }
106 |
107 | public bool CanMaximize
108 | {
109 | get
110 | {
111 | return (bool)this._el.GetPropertyValue(WindowPattern.CanMaximizeProperty, _isCached);
112 | }
113 | }
114 |
115 | public bool CanMinimize
116 | {
117 | get
118 | {
119 | return (bool)this._el.GetPropertyValue(WindowPattern.CanMinimizeProperty, _isCached);
120 | }
121 | }
122 |
123 | public bool IsModal
124 | {
125 | get
126 | {
127 | return (bool)this._el.GetPropertyValue(WindowPattern.IsModalProperty, _isCached);
128 | }
129 | }
130 |
131 | public WindowVisualState WindowVisualState
132 | {
133 | get
134 | {
135 | return (WindowVisualState)this._el.GetPropertyValue(WindowPattern.WindowVisualStateProperty, _isCached);
136 | }
137 | }
138 |
139 | public WindowInteractionState WindowInteractionState
140 | {
141 | get
142 | {
143 | return (WindowInteractionState)this._el.GetPropertyValue(WindowPattern.WindowInteractionStateProperty, _isCached);
144 | }
145 | }
146 |
147 | public bool IsTopmost
148 | {
149 | get
150 | {
151 | return (bool)this._el.GetPropertyValue(WindowPattern.IsTopmostProperty, _isCached);
152 | }
153 | }
154 | }
155 | }
156 | }
--------------------------------------------------------------------------------
/UiaComWrapperX/install.ps1:
--------------------------------------------------------------------------------
1 | param($installPath, $toolsPath, $package, $project)
2 |
3 | $frameworkVersionString = $project.Properties.Item('TargetFrameworkMoniker').Value
4 | $frameworkVersionString -match 'Version=(v\d\.\d)'
5 | $frameworkVersion = $matches[1]
6 | $project.Save();
7 |
8 | if ($frameworkVersion -ge 'v4.0')
9 | {
10 | $project.Object.References | Where-Object { $_.EmbedInteropTypes -eq $true -and $_.Name -eq "Interop.UIAutomationClient" } | ForEach-Object { $_.EmbedInteropTypes = $false }
11 | }
12 |
13 | $project.Save()
--------------------------------------------------------------------------------
/UiaComWrapperXTests/AppHost.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Globalization;
4 | using System.Runtime.InteropServices;
5 | using System.Windows.Automation;
6 |
7 | namespace UIAComWrapperTests
8 | {
9 | public class AppHost : IDisposable
10 | {
11 | private Process _process;
12 | private IntPtr _hwnd;
13 | private AutomationElement _element;
14 | private WindowPattern _windowPattern;
15 |
16 | public AppHost(string program, string args)
17 | {
18 | // Start up the program and find it
19 | _process = Process.Start(program, args);
20 | _hwnd = ActiveWaitForHwnd(_process.Id);
21 | if (_hwnd == IntPtr.Zero)
22 | {
23 | throw new InvalidOperationException("app never stabilized");
24 | }
25 |
26 | // Find it
27 | _element = AutomationElement.FromHandle(_hwnd);
28 | if (_element == null)
29 | {
30 | throw new InvalidOperationException();
31 | }
32 |
33 | _windowPattern = (WindowPattern)_element.GetCurrentPattern(WindowPattern.Pattern);
34 | }
35 |
36 | public AutomationElement Element
37 | {
38 | get
39 | {
40 | return this._element;
41 | }
42 | }
43 |
44 | [DllImport("user32.dll")]
45 | private static extern IntPtr GetDesktopWindow();
46 |
47 | [DllImport("user32.dll")]
48 | private static extern IntPtr GetWindow( IntPtr hwnd, int dir );
49 |
50 | [DllImport("user32.dll")]
51 | private static extern int GetWindowThreadProcessId( IntPtr hwnd, out int pid );
52 |
53 | [DllImport("user32.dll")]
54 | private static extern IntPtr PostMessage( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam );
55 |
56 | [DllImport("user32.dll")]
57 | private static extern IntPtr SendMessage( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam );
58 |
59 | [DllImport("user32.dll")]
60 | private static extern int GetClassName( IntPtr hwnd, System.Text.StringBuilder str, int nMaxCount );
61 |
62 | [DllImport("user32.dll")]
63 | private static extern int WaitForInputIdle( IntPtr hProcess, int dwMilliseconds );
64 |
65 | [DllImport("user32.dll")]
66 | private static extern int GetWindowText( IntPtr hwnd, System.Text.StringBuilder str, int nMaxCount );
67 |
68 | [DllImport("user32.dll")]
69 | private static extern bool IsWindowVisible( IntPtr hwnd );
70 |
71 |
72 | const int GW_HWNDNEXT = 2;
73 | const int GW_CHILD = 5;
74 | const int WM_CLOSE = 0x0010;
75 |
76 | private IntPtr ActiveWaitForHwnd(int pid)
77 | {
78 | for( int attempt = 0 ; attempt < 240 ; attempt++ )
79 | {
80 | IntPtr hwnd = TryFindWindowNow( pid, null /* className */, null /*windowTitle*/ );
81 | if( hwnd != IntPtr.Zero )
82 | {
83 | return hwnd;
84 | }
85 | System.Threading.Thread.Sleep( 500 );
86 | }
87 | return IntPtr.Zero;
88 | }
89 |
90 | private IntPtr TryFindWindowNow( int pid, string className, string windowTitle )
91 | {
92 | // Loop through top-level windows
93 | IntPtr hwnd = GetDesktopWindow();
94 | IntPtr hwndChild = GetWindow( hwnd, GW_CHILD );
95 | for( ; hwndChild != IntPtr.Zero ; hwndChild = GetWindow( hwndChild, GW_HWNDNEXT ) )
96 | {
97 | // Screen out non-matching PIDs
98 | if( pid != 0 )
99 | {
100 | int id;
101 | GetWindowThreadProcessId( hwndChild, out id );
102 | if( id != pid )
103 | {
104 | continue;
105 | }
106 | }
107 |
108 | // Gotta be visible
109 | if( ! IsWindowVisible( hwndChild ) )
110 | {
111 | continue;
112 | }
113 |
114 | // No consoles need apply
115 | System.Text.StringBuilder realClassName = new System.Text.StringBuilder( 64 );
116 | GetClassName(hwndChild, realClassName, 64);
117 | if (String.Compare(realClassName.ToString(), "ConsoleWindowClass", true) == 0)
118 | {
119 | continue;
120 | }
121 |
122 | // Check classname, if requested
123 | if( className != null )
124 | {
125 | if (String.Compare(className, realClassName.ToString(), true, CultureInfo.InvariantCulture) != 0)
126 | {
127 | continue;
128 | }
129 | }
130 |
131 | // Check title, if requested
132 | if( windowTitle != null )
133 | {
134 | System.Text.StringBuilder testWindowTitle = new System.Text.StringBuilder( 64 );
135 | GetWindowText( hwndChild, testWindowTitle, 64 );
136 | if (String.Compare(windowTitle, testWindowTitle.ToString(), true, CultureInfo.InvariantCulture) != 0)
137 | {
138 | continue;
139 | }
140 | }
141 |
142 | // We have a match!
143 | return hwndChild;
144 | }
145 | return IntPtr.Zero;
146 | }
147 |
148 | #region IDisposable Members
149 |
150 | void System.IDisposable.Dispose()
151 | {
152 | if (_windowPattern != null)
153 | {
154 | _windowPattern.Close();
155 | _windowPattern = null;
156 | }
157 | if (_process != null)
158 | {
159 | _process.WaitForExit();
160 | _process = null;
161 | }
162 | }
163 |
164 | #endregion
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/AutomationElementCollectionTest.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Automation;
2 | using System.Collections;
3 | using NUnit.Framework;
4 |
5 | namespace UIAComWrapperTests
6 | {
7 | ///
8 | ///This is a test class for AutomationElementCollectionTest and is intended
9 | ///to contain all AutomationElementCollectionTest Unit Tests
10 | ///
11 | [TestFixture]
12 | public class AutomationElementCollectionTest
13 | {
14 | private AutomationElementCollection testColl;
15 |
16 | [SetUp]
17 | public void MyTestInitialize()
18 | {
19 | // Get all children of the desktop for our target collection
20 | CacheRequest cacheReq = new CacheRequest();
21 | cacheReq.Add(AutomationElement.NameProperty);
22 | cacheReq.Add(AutomationElement.NativeWindowHandleProperty);
23 | using (cacheReq.Activate())
24 | {
25 | this.testColl = AutomationElement.RootElement.FindAll(
26 | TreeScope.Children,
27 | Condition.TrueCondition);
28 | Assert.IsNotNull(this.testColl);
29 | Assert.IsTrue(this.testColl.Count > 0);
30 | }
31 | }
32 |
33 | ///
34 | ///A test for Item
35 | ///
36 | [Test]
37 | public void ItemTest()
38 | {
39 | AutomationElement actual = this.testColl[0];
40 | Assert.IsNotNull(actual);
41 | }
42 |
43 | ///
44 | ///A test for Count
45 | ///
46 | [Test]
47 | public void CountTest()
48 | {
49 | Assert.IsTrue(this.testColl.Count > 0);
50 | }
51 |
52 | ///
53 | ///A test for GetEnumerator
54 | ///
55 | [Test]
56 | public void GetEnumeratorTest()
57 | {
58 | IEnumerator actual = this.testColl.GetEnumerator();
59 | int count = 0;
60 | while (actual.MoveNext())
61 | {
62 | AutomationElement elem = (AutomationElement)actual.Current;
63 | Assert.IsNotNull(elem);
64 | ++count;
65 | }
66 |
67 | actual.Reset();
68 | actual.MoveNext();
69 | Assert.AreEqual(actual.Current, this.testColl[0]);
70 | }
71 |
72 | ///
73 | ///A test for CopyTo
74 | ///
75 | [Test]
76 | public void CopyToTest()
77 | {
78 | AutomationElement[] array = new AutomationElement[this.testColl.Count+1];
79 | this.testColl.CopyTo(array, 1);
80 | for (int i = 0; i < this.testColl.Count; ++i)
81 | {
82 | Assert.AreEqual(this.testColl[i], array[i + 1]);
83 | }
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/CacheRequestTest.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Automation;
2 | using NUnit.Framework;
3 |
4 | namespace UIAComWrapperTests
5 | {
6 |
7 |
8 | ///
9 | ///This is a test class for CacheRequestTest and is intended
10 | ///to contain all CacheRequestTest Unit Tests
11 | ///
12 | [TestFixture]
13 | public class CacheRequestTest
14 | {
15 | ///
16 | ///A test for TreeScope
17 | ///
18 | [Test]
19 | public void TreeScopeTest()
20 | {
21 | CacheRequest target = new CacheRequest();
22 | TreeScope expected = TreeScope.Subtree;
23 | TreeScope actual;
24 | target.TreeScope = expected;
25 | actual = target.TreeScope;
26 | Assert.AreEqual(expected, actual);
27 | }
28 |
29 | ///
30 | ///A test for TreeFilter
31 | ///
32 | [Test]
33 | public void TreeFilterTest()
34 | {
35 | CacheRequest target = new CacheRequest();
36 | PropertyCondition expected = new PropertyCondition(AutomationElement.NameProperty, "foo");
37 | PropertyCondition actual;
38 | target.TreeFilter = expected;
39 | actual = (PropertyCondition)target.TreeFilter;
40 | Assert.AreEqual(expected.Flags, actual.Flags);
41 | Assert.AreEqual(expected.Property, actual.Property);
42 | Assert.AreEqual(expected.Value, actual.Value);
43 | }
44 |
45 | ///
46 | ///A test for Current
47 | ///
48 | [Test]
49 | public void CurrentTest()
50 | {
51 | // We expect the Current one at this point to be the Default one
52 | CacheRequest actual;
53 | actual = CacheRequest.Current;
54 | Assert.IsNotNull(actual);
55 | Assert.AreEqual(actual.AutomationElementMode, AutomationElementMode.Full);
56 | Assert.AreEqual(actual.TreeScope, TreeScope.Element);
57 | Assert.IsNotNull(actual.TreeFilter);
58 |
59 | Assert.IsTrue(actual.TreeFilter is NotCondition);
60 | NotCondition notCond = (NotCondition)actual.TreeFilter;
61 | Assert.IsTrue(notCond.Condition is PropertyCondition);
62 | PropertyCondition propCond = (PropertyCondition)notCond.Condition;
63 | Assert.AreEqual(propCond.Property, AutomationElement.IsControlElementProperty);
64 | Assert.AreEqual(propCond.Value, false);
65 | }
66 |
67 | ///
68 | ///A test for AutomationElementMode
69 | ///
70 | [Test]
71 | public void AutomationElementModeTest()
72 | {
73 | CacheRequest target = new CacheRequest();
74 | target.AutomationElementMode = AutomationElementMode.Full;
75 | AutomationElementMode actual = target.AutomationElementMode;
76 | Assert.AreEqual(AutomationElementMode.Full, actual);
77 | }
78 |
79 | ///
80 | ///A test for Push and Pop
81 | ///
82 | [Test]
83 | public void PushPopTest()
84 | {
85 | CacheRequest defaultCR = CacheRequest.Current;
86 | CacheRequest target = new CacheRequest();
87 | target.TreeScope = TreeScope.Children;
88 | target.Push();
89 | CacheRequest target2 = new CacheRequest();
90 | target2.TreeScope = TreeScope.Subtree;
91 | target2.Push();
92 |
93 | // Try to change target2 - this should fail
94 | try
95 | {
96 | target2.TreeScope = TreeScope.Descendants;
97 |
98 | Assert.Fail("exception expected");
99 | }
100 | catch (System.InvalidOperationException)
101 | {
102 | }
103 |
104 | target2.Pop();
105 | target.Pop();
106 | Assert.AreEqual(CacheRequest.Current, defaultCR);
107 | }
108 |
109 | ///
110 | ///A test for Clone
111 | ///
112 | [Test]
113 | public void CloneTest()
114 | {
115 | CacheRequest target = new CacheRequest();
116 | target.TreeScope = TreeScope.Subtree;
117 | CacheRequest actual;
118 | actual = target.Clone();
119 | Assert.AreEqual(target.TreeScope, actual.TreeScope);
120 | }
121 |
122 | ///
123 | ///A test for Add
124 | ///
125 | [Test]
126 | public void AddTest()
127 | {
128 | CacheRequest target = new CacheRequest();
129 | target.Add(AutomationElement.HelpTextProperty);
130 | target.Add(ExpandCollapsePatternIdentifiers.Pattern);
131 | }
132 |
133 | ///
134 | ///A test for Activate
135 | ///
136 | [Test]
137 | public void ActivateTest()
138 | {
139 | CacheRequest target = new CacheRequest();
140 | Assert.AreNotEqual(CacheRequest.Current, target);
141 | using (target.Activate())
142 | {
143 | Assert.AreEqual(CacheRequest.Current, target);
144 | CacheRequest target2 = new CacheRequest();
145 | using (target2.Activate())
146 | {
147 | Assert.AreNotEqual(CacheRequest.Current, target);
148 | }
149 | }
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/ClientSideProvidersTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Automation;
3 | using System.Windows.Automation.Providers;
4 | using NUnit.Framework;
5 | using UIAutomationClient;
6 |
7 | namespace UIAComWrapperTests
8 | {
9 | [System.Runtime.InteropServices.ComVisible(true)]
10 | public class SampleButtonProvider : IRawElementProviderSimple
11 | {
12 | private IntPtr _hwnd;
13 | static public readonly string ButtonName = "TestButton";
14 |
15 | public SampleButtonProvider(IntPtr hwnd)
16 | {
17 | _hwnd = hwnd;
18 | }
19 |
20 | #region IRawElementProviderSimple Members
21 |
22 | public UIAutomationClient.ProviderOptions ProviderOptions
23 | {
24 | get
25 | {
26 | return UIAutomationClient.ProviderOptions.ProviderOptions_ClientSideProvider;
27 | }
28 | }
29 |
30 | public object GetPatternProvider(int patternId)
31 | {
32 | return null;
33 | }
34 |
35 | public object GetPropertyValue(int propertyId)
36 | {
37 | if (propertyId == AutomationElement.NameProperty.Id)
38 | {
39 | return ButtonName;
40 | }
41 | return null;
42 | }
43 |
44 | public IRawElementProviderSimple HostRawElementProvider
45 | {
46 | get
47 | {
48 | return AutomationInteropProvider.HostProviderFromHandle(this._hwnd);
49 | }
50 | }
51 |
52 | #endregion
53 |
54 | public static IRawElementProviderSimple ButtonFactory(IntPtr hwnd, int idChild, int idObject)
55 | {
56 | return new SampleButtonProvider(hwnd);
57 | }
58 | }
59 |
60 | ///
61 | /// Summary description for ClientSideProvidersTest
62 | ///
63 | [TestFixture]
64 | public class ClientSideProvidersTest
65 | {
66 | private IntPtr startButtonHwnd;
67 |
68 | [SetUp]
69 | public void MyTestInitialize()
70 | {
71 | // Find the Start button, which will be our target
72 | AutomationElement trueStartButton = AutomationElementTest.GetTaskbar();
73 | this.startButtonHwnd = (IntPtr)trueStartButton.Current.NativeWindowHandle;
74 | }
75 |
76 | [Test]
77 | public void TestButtonClientSideProvider()
78 | {
79 | // Create the provider
80 | ClientSideProviderDescription provider = new ClientSideProviderDescription(
81 | new ClientSideProviderFactoryCallback(SampleButtonProvider.ButtonFactory), "Shell_TrayWnd");
82 | ClientSideProviderDescription[] providers = new ClientSideProviderDescription[1] { provider };
83 |
84 | try
85 | {
86 | // Register it
87 | ClientSettings.RegisterClientSideProviders(providers);
88 |
89 | // Get the overridden element
90 | AutomationElement startButton = AutomationElement.FromHandle(this.startButtonHwnd);
91 |
92 | // Validate that it is ours
93 | Assert.AreEqual(SampleButtonProvider.ButtonName, startButton.Current.Name);
94 |
95 | // Unregister it
96 | ClientSettings.RegisterClientSideProviders(new ClientSideProviderDescription[0]);
97 |
98 | // Get the overridden element
99 | startButton = AutomationElement.FromHandle(this.startButtonHwnd);
100 |
101 | // Validate that it is not ours
102 | Assert.AreNotEqual(SampleButtonProvider.ButtonName, startButton.Current.Name);
103 | }
104 | finally
105 | {
106 | // Restore the status quo ante
107 | ClientSettings.RegisterClientSideProviders(new ClientSideProviderDescription[0]);
108 | }
109 | }
110 |
111 | [Test]
112 | public void TestPartialNameMatch()
113 | {
114 | // Create the provider
115 | ClientSideProviderDescription provider = new ClientSideProviderDescription(
116 | new ClientSideProviderFactoryCallback(
117 | SampleButtonProvider.ButtonFactory),
118 | "Shell_",
119 | null /* image name */,
120 | ClientSideProviderMatchIndicator.AllowSubstringMatch);
121 | ClientSideProviderDescription[] providers = new ClientSideProviderDescription[1] { provider };
122 |
123 | try
124 | {
125 | // Register it
126 | ClientSettings.RegisterClientSideProviders(providers);
127 |
128 | // Get the overridden element
129 | AutomationElement startButton = AutomationElement.FromHandle(this.startButtonHwnd);
130 |
131 | // Validate that it is ours
132 | Assert.AreEqual(SampleButtonProvider.ButtonName, startButton.Current.Name);
133 | }
134 | finally
135 | {
136 | // Restore the status quo ante
137 | ClientSettings.RegisterClientSideProviders(new ClientSideProviderDescription[0]);
138 | }
139 | }
140 |
141 | [Test]
142 | public void TestPartialMatchNotPermitted()
143 | {
144 | // Create the provider
145 | ClientSideProviderDescription provider = new ClientSideProviderDescription(
146 | new ClientSideProviderFactoryCallback(
147 | SampleButtonProvider.ButtonFactory),
148 | "Shell_",
149 | null /* image name */,
150 | ClientSideProviderMatchIndicator.None);
151 | ClientSideProviderDescription[] providers = new ClientSideProviderDescription[1] { provider };
152 |
153 | try
154 | {
155 | // Register it
156 | ClientSettings.RegisterClientSideProviders(providers);
157 |
158 | // Get the overridden element
159 | AutomationElement startButton = AutomationElement.FromHandle(this.startButtonHwnd);
160 |
161 | // Validate that it is not ours
162 | Assert.AreNotEqual(SampleButtonProvider.ButtonName, startButton.Current.Name);
163 | }
164 | finally
165 | {
166 | // Restore the status quo ante
167 | ClientSettings.RegisterClientSideProviders(new ClientSideProviderDescription[0]);
168 | }
169 | }
170 |
171 | [Test]
172 | public void TestImageMatch()
173 | {
174 | // Create the provider
175 | ClientSideProviderDescription provider = new ClientSideProviderDescription(
176 | new ClientSideProviderFactoryCallback(
177 | SampleButtonProvider.ButtonFactory),
178 | "Shell_TrayWnd",
179 | "EXPLORER.EXE",
180 | ClientSideProviderMatchIndicator.None);
181 | ClientSideProviderDescription[] providers = new ClientSideProviderDescription[1] { provider };
182 |
183 | try
184 | {
185 | // Register it
186 | ClientSettings.RegisterClientSideProviders(providers);
187 |
188 | // Get the overridden element
189 | AutomationElement startButton = AutomationElement.FromHandle(this.startButtonHwnd);
190 |
191 | // Validate that it is ours
192 | Assert.AreEqual(SampleButtonProvider.ButtonName, startButton.Current.Name);
193 | }
194 | finally
195 | {
196 | // Restore the status quo ante
197 | ClientSettings.RegisterClientSideProviders(new ClientSideProviderDescription[0]);
198 | }
199 | }
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/ConditionTest.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Automation;
2 | using NUnit.Framework;
3 |
4 | namespace UIAComWrapperTests
5 | {
6 | ///
7 | ///This is a test class for Conditions and is intended
8 | ///to contain all Conditions Unit Tests
9 | ///
10 | [TestFixture]
11 | public class ConditionTests
12 | {
13 | ///
14 | ///A test for AndCondition
15 | ///
16 | [Test]
17 | public void AndConditionTest()
18 | {
19 | // Positive test
20 | Condition condition = Condition.TrueCondition;
21 | Condition condition2 = Condition.FalseCondition;
22 | AndCondition target = new AndCondition(condition, condition2);
23 | Condition[] actual;
24 | actual = target.GetConditions();
25 | Assert.IsNotNull(actual);
26 | Assert.AreEqual(actual.Length, 2);
27 |
28 | // Negative test - include a null
29 | try
30 | {
31 | target = new AndCondition(condition, null);
32 |
33 | Assert.Fail("expected exception");
34 | }
35 | catch (System.ArgumentException)
36 | {
37 | }
38 | }
39 |
40 | ///
41 | ///A test for GetConditions
42 | ///
43 | [Test]
44 | public void OrConditionTest()
45 | {
46 | Condition condition = Condition.TrueCondition;
47 | Condition condition2 = OrCondition.FalseCondition;
48 | OrCondition target = new OrCondition(condition, condition2);
49 | Condition[] actual;
50 | actual = target.GetConditions();
51 | Assert.IsNotNull(actual);
52 | Assert.AreEqual(actual.Length, 2);
53 |
54 | // Negative test - include a null
55 | try
56 | {
57 | target = new OrCondition(condition, null);
58 |
59 | Assert.Fail("expected exception");
60 | }
61 | catch (System.ArgumentException)
62 | {
63 | }
64 | }
65 |
66 | ///
67 | ///A test for NotCondition
68 | ///
69 | [Test]
70 | public void NotConditionTest()
71 | {
72 | Condition condition = Condition.TrueCondition;
73 | NotCondition target = new NotCondition(condition);
74 | Assert.IsNotNull(target);
75 | Condition child = target.Condition;
76 | Assert.IsNotNull(child);
77 | }
78 |
79 | ///
80 | ///A test for PropertyCondition
81 | ///
82 | [Test]
83 | public void PropertyConditionTest()
84 | {
85 | PropertyCondition cond1 = new PropertyCondition(
86 | AutomationElement.NameProperty,
87 | "foo");
88 | Assert.IsNotNull(cond1);
89 | Assert.AreEqual(cond1.Value, "foo");
90 | Assert.AreEqual(cond1.Property.ProgrammaticName, "AutomationElementIdentifiers.NameProperty");
91 |
92 | System.Windows.Rect rect = new System.Windows.Rect(0, 0, 20, 20);
93 | PropertyCondition cond2 = new PropertyCondition(
94 | AutomationElement.BoundingRectangleProperty,
95 | rect);
96 | Assert.IsNotNull(cond2);
97 | object value = cond2.Value;
98 | Assert.IsInstanceOf(value);
99 | Assert.AreEqual(((double[])value).Length, 4);
100 | Assert.AreEqual(cond2.Property.ProgrammaticName, "AutomationElementIdentifiers.BoundingRectangleProperty");
101 |
102 | PropertyCondition cond3 = new PropertyCondition(
103 | AutomationElement.ClickablePointProperty,
104 | new System.Windows.Point(0, 0));
105 | Assert.IsNotNull(cond3);
106 | value = cond3.Value;
107 | Assert.IsInstanceOf(value);
108 | Assert.AreEqual(((double[])value).Length, 2);
109 | Assert.AreEqual(cond3.Property.ProgrammaticName, "AutomationElementIdentifiers.ClickablePointProperty");
110 |
111 | // Negative case
112 | try
113 | {
114 | PropertyCondition cond4 = new PropertyCondition(
115 | null, null);
116 |
117 | Assert.Fail("expected exception");
118 | }
119 | catch (System.ArgumentException)
120 | {
121 | }
122 |
123 |
124 |
125 | }
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/EventTests.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Automation;
2 | using NUnit.Framework;
3 |
4 | namespace UIAComWrapperTests
5 | {
6 | public class EventHandlerBase
7 | {
8 | private System.Threading.ManualResetEvent _syncEvent = new System.Threading.ManualResetEvent(false);
9 | private AutomationElement _eventSource;
10 | private uint _receivedEventCount;
11 |
12 | protected void OnMatchingEvent(AutomationElement sender)
13 | {
14 | _eventSource = sender;
15 | _receivedEventCount++;
16 | _syncEvent.Set();
17 | }
18 |
19 | public EventHandlerBase()
20 | {
21 | }
22 |
23 | public void Start()
24 | {
25 | _receivedEventCount = 0;
26 | _eventSource = null;
27 | }
28 |
29 | public bool Confirm()
30 | {
31 | return this._syncEvent.WaitOne(3000 /* ms */);
32 | }
33 |
34 | public AutomationElement EventSource
35 | {
36 | get
37 | {
38 | return this._eventSource;
39 | }
40 | }
41 |
42 | public uint ReceivedEventCount
43 | {
44 | get
45 | {
46 | return this._receivedEventCount;
47 | }
48 | }
49 | }
50 |
51 | public class FocusChangeHandler : EventHandlerBase
52 | {
53 | public void HandleEvent(object sender, AutomationFocusChangedEventArgs e)
54 | {
55 | OnMatchingEvent((AutomationElement)sender);
56 | }
57 | }
58 |
59 | public class BasicChangeHandler : EventHandlerBase
60 | {
61 | public void HandleEvent(object sender, AutomationEventArgs e)
62 | {
63 | OnMatchingEvent((AutomationElement)sender);
64 | }
65 | }
66 |
67 | public class PropertyChangeHandler : EventHandlerBase
68 | {
69 | public void HandleEvent(object sender, AutomationPropertyChangedEventArgs e)
70 | {
71 | OnMatchingEvent((AutomationElement)sender);
72 | }
73 | }
74 |
75 | public class StructureChangeHandler : EventHandlerBase
76 | {
77 | public void HandleEvent(object sender, StructureChangedEventArgs e)
78 | {
79 | OnMatchingEvent((AutomationElement)sender);
80 | }
81 | }
82 |
83 | ///
84 | /// Summary description for EventTests
85 | ///
86 | [TestFixture]
87 | public class EventTests
88 | {
89 | [Test]
90 | public void TestFocusChange()
91 | {
92 | // Launch a notepad and set focus to it
93 | using (AppHost host1 = new AppHost("notepad.exe", ""))
94 | {
95 | host1.Element.SetFocus();
96 |
97 | FocusChangeHandler handler = new FocusChangeHandler();
98 | Automation.AddAutomationFocusChangedEventHandler(
99 | new AutomationFocusChangedEventHandler(handler.HandleEvent));
100 | handler.Start();
101 |
102 | // Launch a new notepad and set focus to it
103 | using (AppHost host2 = new AppHost("notepad.exe", ""))
104 | {
105 | host2.Element.SetFocus();
106 |
107 | Assert.IsTrue(handler.Confirm());
108 | Assert.IsNotNull(handler.EventSource);
109 | }
110 |
111 | Automation.RemoveAutomationFocusChangedEventHandler(
112 | new AutomationFocusChangedEventHandler(handler.HandleEvent));
113 | }
114 | }
115 |
116 | [Test]
117 | [Ignore]
118 | // Test is not working on Windows 8 due to the Start Button being removed
119 | public void TestInvokeEvent()
120 | {
121 | AutomationElement startButton = AutomationElementTest.GetStartButton();
122 | BasicChangeHandler handler = new BasicChangeHandler();
123 | Automation.AddAutomationEventHandler(
124 | InvokePattern.InvokedEvent,
125 | startButton,
126 | TreeScope.Element,
127 | new AutomationEventHandler(handler.HandleEvent));
128 | handler.Start();
129 | InvokePattern invoke = (InvokePattern)startButton.GetCurrentPattern(InvokePattern.Pattern);
130 | invoke.Invoke();
131 | System.Windows.Forms.SendKeys.SendWait("{ESC}");
132 | Assert.IsTrue(handler.Confirm());
133 | Assert.IsNotNull(handler.EventSource);
134 | Automation.RemoveAutomationEventHandler(
135 | InvokePattern.InvokedEvent,
136 | startButton,
137 | new AutomationEventHandler(handler.HandleEvent));
138 | }
139 |
140 | [Test]
141 | public void TestPropChangeEvent()
142 | {
143 | using (AppHost host = new AppHost("notepad.exe", ""))
144 | {
145 | TransformPattern transformPattern = (TransformPattern)host.Element.GetCurrentPattern(TransformPattern.Pattern);
146 |
147 | PropertyChangeHandler handler = new PropertyChangeHandler();
148 | Automation.AddAutomationPropertyChangedEventHandler(
149 | host.Element,
150 | TreeScope.Element,
151 | new AutomationPropertyChangedEventHandler(handler.HandleEvent),
152 | AutomationElement.BoundingRectangleProperty);
153 | handler.Start();
154 | System.Threading.Thread.Sleep(100 /* ms */);
155 | transformPattern.Move(200, 200);
156 | Assert.IsTrue(handler.Confirm());
157 | Assert.IsNotNull(handler.EventSource);
158 | Assert.AreEqual(host.Element, handler.EventSource);
159 | Automation.RemoveAutomationPropertyChangedEventHandler(
160 | host.Element,
161 | new AutomationPropertyChangedEventHandler(handler.HandleEvent));
162 | }
163 | }
164 |
165 | [Test]
166 | public void TestStructureChangeEvent()
167 | {
168 | StructureChangeHandler handler = new StructureChangeHandler();
169 | Automation.AddStructureChangedEventHandler(
170 | AutomationElement.RootElement,
171 | TreeScope.Subtree,
172 | new StructureChangedEventHandler(handler.HandleEvent));
173 | handler.Start();
174 |
175 | // Start Notepad to get a structure change event
176 | using (AppHost host = new AppHost("notepad.exe", ""))
177 | {
178 | }
179 |
180 | Assert.IsTrue(handler.Confirm());
181 | Assert.IsNotNull(handler.EventSource);
182 | Automation.RemoveStructureChangedEventHandler(
183 | AutomationElement.RootElement,
184 | new StructureChangedEventHandler(handler.HandleEvent));
185 | }
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/ExplorerHost.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Automation;
3 |
4 | namespace UIAComWrapperTests
5 | {
6 | public class ExplorerHost : IDisposable
7 | {
8 | private AutomationElement _element;
9 | private WindowPattern _windowPattern;
10 | private int _hwnd;
11 |
12 | public ExplorerHost()
13 | {
14 | // Start up Explorer and find it
15 | System.Diagnostics.Process.Start("cmd.exe", "/c start %SystemDrive%\\windows\\system32");
16 |
17 | // Wait briefly
18 | System.Threading.Thread.Sleep(2000 /* ms */);
19 |
20 | // Find it
21 | _element = AutomationElement.RootElement.FindFirst(TreeScope.Children,
22 | new PropertyCondition(AutomationElement.NameProperty, "system32"));
23 | if (_element == null)
24 | {
25 | throw new InvalidOperationException();
26 | }
27 |
28 | _hwnd = _element.Current.NativeWindowHandle;
29 |
30 | _windowPattern = (WindowPattern)_element.GetCurrentPattern(WindowPattern.Pattern);
31 | }
32 |
33 | ~ExplorerHost()
34 | {
35 | if (_windowPattern != null)
36 | {
37 | _windowPattern.Close();
38 | _windowPattern = null;
39 | }
40 | }
41 |
42 | public AutomationElement Element
43 | {
44 | get
45 | {
46 | AutomationElement element = AutomationElement.FromHandle((IntPtr)this._hwnd);
47 | if (element == null)
48 | {
49 | throw new InvalidOperationException();
50 | }
51 | return element;
52 | }
53 | }
54 |
55 | #region IDisposable Members
56 |
57 | void System.IDisposable.Dispose()
58 | {
59 | if (_windowPattern != null)
60 | {
61 | _windowPattern.Close();
62 | _windowPattern = null;
63 | }
64 | _element = null;
65 | _hwnd = 0;
66 | }
67 |
68 | #endregion
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/Internal_ObjectConverterTest.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Automation;
2 | using NUnit.Framework;
3 | using UIAComWrapperInternal;
4 |
5 | namespace UIAComWrapperXTests
6 | {
7 | public struct ObjectTestMapping
8 | {
9 | public AutomationProperty property;
10 | public object input;
11 | public object expected;
12 |
13 | public ObjectTestMapping(AutomationProperty property, object input, object expected)
14 | {
15 | this.property = property;
16 | this.input = input;
17 | this.expected = expected;
18 | }
19 | };
20 |
21 | ///
22 | /// Tests for the ObjectConverter system that 'polishes' returned objects
23 | /// into the right types for this API.
24 | ///
25 | [TestFixture]
26 | public class ObjectConverterTest
27 | {
28 | [Test]
29 | public void TestObjectConverter()
30 | {
31 | ObjectTestMapping[] testMap = new ObjectTestMapping[] {
32 | new ObjectTestMapping(AutomationElement.BoundingRectangleProperty, new double[] {1, 2, 3, 4}, new System.Windows.Rect(1, 2, 3, 4)),
33 | new ObjectTestMapping(AutomationElement.ControlTypeProperty, (int)50000, ControlType.Button),
34 | new ObjectTestMapping(AutomationElement.ClickablePointProperty, new double[] {1, 2}, new System.Windows.Point(1, 2)),
35 | new ObjectTestMapping(AutomationElement.CultureProperty, 0x0409, new System.Globalization.CultureInfo(0x0409)),
36 | new ObjectTestMapping(AutomationElement.CultureProperty, 0, System.Globalization.CultureInfo.InvariantCulture),
37 | new ObjectTestMapping(AutomationElement.LabeledByProperty, null, null),
38 | new ObjectTestMapping(AutomationElement.LabeledByProperty, Automation.Factory.GetRootElement(), AutomationElement.RootElement),
39 | new ObjectTestMapping(AutomationElement.OrientationProperty, 2, OrientationType.Vertical),
40 | new ObjectTestMapping(DockPattern.DockPositionProperty, 4, DockPosition.Fill),
41 | new ObjectTestMapping(ExpandCollapsePattern.ExpandCollapseStateProperty, 2, ExpandCollapseState.PartiallyExpanded),
42 | new ObjectTestMapping(WindowPattern.WindowVisualStateProperty, 2, WindowVisualState.Minimized),
43 | new ObjectTestMapping(WindowPattern.WindowInteractionStateProperty, 1, WindowInteractionState.Closing),
44 | new ObjectTestMapping(TablePattern.RowOrColumnMajorProperty, 2, RowOrColumnMajor.Indeterminate),
45 | new ObjectTestMapping(TogglePattern.ToggleStateProperty, 1, ToggleState.On)
46 | };
47 |
48 | foreach (ObjectTestMapping mapping in testMap)
49 | {
50 | PropertyTypeInfo info;
51 | Schema.GetPropertyTypeInfo(mapping.property, out info);
52 | object output = mapping.input;
53 | if (info != null && info.ObjectConverter != null)
54 | {
55 | output = info.ObjectConverter(mapping.input);
56 | }
57 | else
58 | {
59 | output = Utility.WrapObjectAsProperty(mapping.property, mapping.input);
60 | }
61 | Assert.IsTrue(output == null || info == null || output.GetType() == info.Type);
62 | Assert.AreEqual(output, mapping.expected);
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Michael Bernstein, 2009.
2 | // This source is subject to the Microsoft Permissive License.
3 | // See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
4 | // All other rights reserved.
5 |
6 | using System.Reflection;
7 | using System.Runtime.CompilerServices;
8 | using System.Runtime.InteropServices;
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 | [assembly: AssemblyTitle("UIAComWrapperXTests")]
14 | [assembly: AssemblyDescription("")]
15 | [assembly: AssemblyConfiguration("")]
16 | [assembly: AssemblyCompany("")]
17 | [assembly: AssemblyProduct("UIAComWrapperXTests")]
18 | [assembly: AssemblyCopyright("Copyright © 2018 Techno Scavenger")]
19 | [assembly: AssemblyTrademark("")]
20 | [assembly: AssemblyCulture("")]
21 |
22 | // Setting ComVisible to false makes the types in this assembly not visible
23 | // to COM componenets. If you need to access a type in this assembly from
24 | // COM, set the ComVisible attribute to true on that type.
25 | [assembly: ComVisible(false)]
26 |
27 | // The following GUID is for the ID of the typelib if this project is exposed to COM
28 | [assembly: Guid("d10c2580-145b-4257-a9f6-03ef5ab06985")]
29 |
30 | // Version information for an assembly consists of the following four values:
31 | //
32 | // Major Version
33 | // Minor Version
34 | // Build Number
35 | // Revision
36 | //
37 | // You can specify all the values or you can default the Revision and Build Numbers
38 | // by using the '*' as shown below:
39 | [assembly: AssemblyVersion("1.0.0.0")]
40 | [assembly: AssemblyFileVersion("1.0.0.0")]
41 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/Test References/test.xps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/technoscavenger/UIAComWrapperX/94171c31c78386b5180e347cfc7baae1f5d25b12/UiaComWrapperXTests/Test References/test.xps
--------------------------------------------------------------------------------
/UiaComWrapperXTests/TreeWalkerTest.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Automation;
2 | using NUnit.Framework;
3 |
4 | namespace UIAComWrapperTests
5 | {
6 | ///
7 | /// Summary description for TreeWalker
8 | ///
9 | [TestFixture]
10 | public class TreeWalkerTest
11 | {
12 | [Test]
13 | public void PreDefinedConditionsTest()
14 | {
15 | Condition rawView = Automation.RawViewCondition;
16 | Assert.IsNotNull(rawView);
17 |
18 | Condition controlView = Automation.ControlViewCondition;
19 | Assert.IsInstanceOf(controlView);
20 | NotCondition notCond = (NotCondition)controlView;
21 | Assert.IsInstanceOf(notCond.Condition);
22 |
23 | Condition contentView = Automation.ContentViewCondition;
24 | Assert.IsInstanceOf(contentView);
25 | NotCondition notCond2 = (NotCondition)contentView;
26 | Assert.IsInstanceOf(notCond2.Condition);
27 | }
28 |
29 | //
30 | // TreeIterationTest moved to ExplorerTargetTests.
31 | //
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/UIAComWrapper.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/technoscavenger/UIAComWrapperX/94171c31c78386b5180e347cfc7baae1f5d25b12/UiaComWrapperXTests/UIAComWrapper.snk
--------------------------------------------------------------------------------
/UiaComWrapperXTests/UIAComWrapperTests.ncrunchproject:
--------------------------------------------------------------------------------
1 |
2 | false
3 | false
4 | false
5 | true
6 | false
7 | false
8 | false
9 | false
10 | true
11 | true
12 | false
13 | true
14 | true
15 | 60000
16 |
17 |
18 |
19 | AutoDetect
20 | STA
21 | x86
22 |
23 |
24 | .*
25 |
26 |
27 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/UIAComWrapperXTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {5BD04451-8FAC-475A-BD33-6FE2DD59FEE3}
9 | Library
10 | Properties
11 | UIAComWrapperXTests
12 | UIAComWrapperXTests
13 | v4.5.2
14 | 512
15 |
16 |
17 |
18 |
19 | 3.5
20 | publish\
21 | true
22 | Disk
23 | false
24 | Foreground
25 | 7
26 | Days
27 | false
28 | false
29 | true
30 | 0
31 | 1.0.0.%2a
32 | false
33 | false
34 | true
35 |
36 |
37 |
38 | true
39 | full
40 | false
41 | bin\Debug\
42 | DEBUG;TRACE
43 | prompt
44 | 4
45 | false
46 |
47 |
48 | pdbonly
49 | true
50 | bin\Release\
51 | TRACE
52 | prompt
53 | 4
54 | false
55 |
56 |
57 | true
58 |
59 |
60 | UIAComWrapper.snk
61 |
62 |
63 |
64 |
65 | False
66 | False
67 | ..\Libs\Interop.UIAutomationClient.dll
68 |
69 |
70 | ..\packages\NUnit.2.6.4\lib\nunit.framework.dll
71 | True
72 |
73 |
74 |
75 | 3.5
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | Code
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | {1DD63894-DBB9-40EF-BFF2-55624CB285AF}
103 | UIAComWrapperX
104 |
105 |
106 |
107 |
108 |
109 |
110 | Always
111 |
112 |
113 |
114 |
115 |
116 |
117 | False
118 | Microsoft .NET Framework 4 %28x86 and x64%29
119 | true
120 |
121 |
122 | False
123 | .NET Framework 3.5 SP1 Client Profile
124 | false
125 |
126 |
127 | False
128 | .NET Framework 3.5 SP1
129 | false
130 |
131 |
132 |
133 |
140 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/UiaComWrapperXTests/test.xps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/technoscavenger/UIAComWrapperX/94171c31c78386b5180e347cfc7baae1f5d25b12/UiaComWrapperXTests/test.xps
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | install:
2 | - choco install gitversion.portable -pre -y
3 | - choco install gitlink -y
4 | - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-desktop.ps1'))
5 |
6 | assembly_info:
7 | patch: false
8 |
9 | configuration:
10 | - Release
11 |
12 | platform:
13 | - Any CPU
14 |
15 | before_build:
16 | - nuget restore
17 | - ps: gitversion /l console /output buildserver /updateAssemblyInfo
18 |
19 | build_script:
20 | - cmd: msbuild UIAComWrapper.sln "/p:Configuration=%CONFIGURATION%;Platform=%PLATFORM%"
21 |
22 | - cmd: GitLink . -u https://github.com/TestStack/UIAComWrapper -c %CONFIGURATION%
23 |
24 | - cmd: ECHO nuget pack \.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
25 | - cmd: nuget pack UiaComWrapper\UIAComWrapper.nuspec -version "%GitVersion_NuGetVersion%" -BasePath "UiaComWrapper\bin\%CONFIGURATION%"
26 |
27 | - cmd: appveyor PushArtifact "UIAComWrapper.%GitVersion_NuGetVersion%.nupkg"
28 |
29 | cache:
30 | - packages -> **\packages.config
--------------------------------------------------------------------------------