├── src
└── UIAutomation
│ ├── Microsoft.UI.UIAutomation
│ ├── module.def
│ ├── packages.config
│ ├── pch.cpp
│ ├── pch.h
│ ├── dllmain.cpp
│ ├── MessageBuilder.h
│ ├── AutomationRemoteOperationResultSet.cpp
│ ├── MessageBuilder.cpp
│ ├── AutomationRemoteOperationResultSet.h
│ ├── AutomationRemoteOperationMethods.g.h
│ ├── RemoteOperationInstructionsVariantParams.g.h
│ ├── RemoteOperationGraph.h
│ ├── RemoteOperationInstructionSerializerMethods.g.h
│ ├── Microsoft.UI.UIAutomation.vcxproj.filters
│ ├── RemoteOperationInstructionEnumValuesArray.g.h
│ ├── AutomationRemoteElementMethods.g.h
│ ├── RemoteOperationInstructionSerialization.h
│ ├── AutomationRemoteAnyObjectMethods.g.h
│ ├── AutomationRemoteOperation.h
│ ├── RemoteOperationGraph.cpp
│ ├── RemoteOperationInstructionEnumValues.g.h
│ ├── RemoteOperationInstructionSerialization.g.cpp
│ └── AutomationRemoteOperation.cpp
│ ├── SharpConsoleAppDemo
│ ├── App.config
│ ├── SharpConsoleAppDemo.exe.manifest
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Program.cs
│ └── SharpConsoleAppDemo.csproj
│ ├── UiaOperationAbstraction
│ ├── pch.h
│ ├── packages.config
│ ├── pch.cpp
│ ├── SafeArrayUtil.cpp
│ ├── UiaOperationAbstraction.vcxproj.filters
│ ├── SafeArrayUtil.h
│ ├── UiaOperationAbstraction.vcxproj
│ └── UiaTypeAbstractionEnums.g.h
│ ├── FunctionalTests
│ ├── packages.config
│ ├── pch.cpp
│ ├── pch.h
│ ├── ModernApp.h
│ ├── FunctionalTests.vcxproj.filters
│ ├── TestUtils.h
│ ├── ModernApp.cpp
│ └── FunctionalTests.vcxproj
│ └── UIAutomation.sln
├── CODE_OF_CONDUCT.md
├── LICENSE
├── SECURITY.md
├── README.md
└── .gitignore
/src/UIAutomation/Microsoft.UI.UIAutomation/module.def:
--------------------------------------------------------------------------------
1 | EXPORTS
2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
4 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/UIAutomation/SharpConsoleAppDemo/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/UIAutomation/UiaOperationAbstraction/pch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | #include
7 | #include
8 | #include
9 | #include
--------------------------------------------------------------------------------
/src/UIAutomation/FunctionalTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/UIAutomation/UiaOperationAbstraction/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/UIAutomation/FunctionalTests/pch.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // pch.cpp: source file corresponding to the pre-compiled header
5 |
6 | #include "pch.h"
7 |
8 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
9 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/pch.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // pch.cpp: source file corresponding to the pre-compiled header
5 |
6 | #include "pch.h"
7 |
8 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
9 |
--------------------------------------------------------------------------------
/src/UIAutomation/UiaOperationAbstraction/pch.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // pch.cpp: source file corresponding to the pre-compiled header
5 |
6 | #include "pch.h"
7 |
8 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
9 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/pch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 | #include
16 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Microsoft Open Source Code of Conduct
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4 |
5 | Resources:
6 |
7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10 |
--------------------------------------------------------------------------------
/src/UIAutomation/SharpConsoleAppDemo/SharpConsoleAppDemo.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | // dllmain.cpp : Defines the entry point for the DLL application.
5 | #include "pch.h"
6 |
7 | BOOL APIENTRY DllMain( HMODULE /* hModule */,
8 | DWORD ul_reason_for_call,
9 | LPVOID /* lpReserved */
10 | )
11 | {
12 | switch (ul_reason_for_call)
13 | {
14 | case DLL_PROCESS_ATTACH:
15 | case DLL_THREAD_ATTACH:
16 | case DLL_THREAD_DETACH:
17 | case DLL_PROCESS_DETACH:
18 | break;
19 | }
20 | return TRUE;
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/src/UIAutomation/UiaOperationAbstraction/SafeArrayUtil.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #include "pch.h"
5 | #include "SafeArrayUtil.h"
6 |
7 | namespace SafeArrayUtil
8 | {
9 |
10 | HRESULT SafeArrayGetCount(_In_ SAFEARRAY* array, _Out_ long* size) noexcept try
11 | {
12 | *size = 0;
13 |
14 | long lowerBound = 0;
15 | long upperBound = 0;
16 | THROW_IF_FAILED(::SafeArrayGetLBound(array, 1 /* nDim */, &lowerBound));
17 | THROW_IF_FAILED(::SafeArrayGetUBound(array, 1 /* nDim */, &upperBound));
18 |
19 | *size = (upperBound - lowerBound + 1);
20 | return S_OK;
21 | }
22 | CATCH_RETURN();
23 |
24 | } // SafeArrayUtil
25 |
--------------------------------------------------------------------------------
/src/UIAutomation/FunctionalTests/pch.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | // The following macro tells the Windows header files to define GUIDs, not just declare them.
7 | // This is necessary for the UI Automation GUIDs that we use in GUID-related tests.
8 | // Normally this macro isn't necessary in application code, because the Windows SDK provides
9 | // static libraries that define all of the commonly used GUIDs. But none of those libraries
10 | // include this category of UI Automation GUID.
11 | #define INITGUID
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | #include
18 | #include
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #include
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/MessageBuilder.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A helper class that is used to build the byte buffer representation of Remote Operation bytecode.
11 | //
12 | // Contains helpers for serializing various primitives that can be encoded as part of that
13 | // representation of Remote Op bytecode.
14 | //
15 | // Exposes a method to retrieve the final serialized buffer.
16 | class MessageBuilder
17 | {
18 | public:
19 | MessageBuilder() = default;
20 |
21 | void WriteBool(bool);
22 | void WriteByte(uint8_t);
23 | void WriteChar(wchar_t);
24 | void WriteInt(int);
25 | void WriteUnsignedInt(unsigned int);
26 | void WriteDouble(double);
27 | void WriteString(std::wstring_view);
28 | void WriteGuid(const GUID&);
29 |
30 | // Takes ownership of the buffer that contains the serialized representation of all values
31 | // that have been written to the builder thus far.
32 | std::vector DetachBuffer();
33 |
34 | private:
35 | // A helper function that appends the given byte buffer to the end of the result buffer that
36 | // the builder is accumulating.
37 | void WriteBytes(_In_reads_(count) const uint8_t* bytes, size_t count);
38 |
39 | std::vector m_buffer;
40 | };
41 |
42 |
--------------------------------------------------------------------------------
/src/UIAutomation/SharpConsoleAppDemo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SharpConsoleAppDemo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SharpConsoleAppDemo")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("e7da5d8d-01c1-401e-8613-352a19e12538")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/UIAutomation/FunctionalTests/ModernApp.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | #include
7 | #include
8 |
9 | // Helper class for registering, starting, and terminating modern applications (AppX)
10 | class ModernApp
11 | {
12 | public:
13 | explicit ModernApp(_In_z_ const wchar_t* testAppAumid);
14 | ModernApp(_In_z_ const wchar_t* testAppAumid, _In_z_ const wchar_t* exeName);
15 | ~ModernApp() noexcept;
16 |
17 | ModernApp(const ModernApp&) = delete;
18 | ModernApp& operator=(const ModernApp&) = delete;
19 |
20 | ModernApp(ModernApp&&) = delete;
21 | ModernApp& operator=(ModernApp&&) = delete;
22 |
23 | // Helpers to install and remove AppX packages
24 | static bool RegisterTestAppx(_In_z_ const wchar_t* appxName);
25 | static void RemoveTestAppx(_In_z_ const wchar_t* packageName);
26 |
27 | void Activate(_In_opt_z_ const wchar_t* testAppArguments = nullptr);
28 | void Close();
29 |
30 | DWORD GetAppProcessId() noexcept;
31 | HWND GetMainWindow();
32 |
33 | private:
34 | DWORD m_appProcessId = 0;
35 | std::wstring m_testAppAumid;
36 | std::wstring m_exeName;
37 |
38 | // We don't want to own the lifetime of this window. It is still owned by the
39 | // activated application, so we should not destroy it when this object goes away.
40 | HWND m_hwnd = nullptr;
41 |
42 | void WaitForWindow(std::function checkIfWindowMatches);
43 | bool TryFindWindowNow(std::function checkIfWindowMatches);
44 | };
45 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/AutomationRemoteOperationResultSet.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #include "pch.h"
5 | #include "AutomationRemoteOperationResultSet.h"
6 |
7 | #include
8 |
9 | namespace winrt
10 | {
11 | using namespace winrt::Windows::UI::UIAutomation::Core;
12 | }
13 |
14 | namespace winrt::Microsoft::UI::UIAutomation::implementation
15 | {
16 | winrt::hresult AutomationRemoteOperationResultSet::OperationStatus()
17 | {
18 | const auto status = m_result.Status();
19 | if (status == winrt::AutomationRemoteOperationStatus::InstructionLimitExceeded)
20 | {
21 | return E_FAIL;
22 | }
23 | else
24 | {
25 | return m_result.ExtendedError();
26 | }
27 | }
28 |
29 | winrt::Windows::UI::UIAutomation::Core::AutomationRemoteOperationStatus AutomationRemoteOperationResultSet::Status()
30 | {
31 | return m_result.Status();
32 | }
33 |
34 | winrt::hresult AutomationRemoteOperationResultSet::ExtendedError()
35 | {
36 | return m_result.ExtendedError();
37 | }
38 |
39 | bool AutomationRemoteOperationResultSet::HasResult(Microsoft::UI::UIAutomation::AutomationRemoteOperationResponseToken const& token)
40 | {
41 | return m_result.HasOperand({ token.Value });
42 | }
43 |
44 | winrt::IInspectable AutomationRemoteOperationResultSet::GetResult(winrt::AutomationRemoteOperationResponseToken const& token)
45 | {
46 | return m_result.GetOperand({ token.Value });
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/UIAutomation/UiaOperationAbstraction/UiaOperationAbstraction.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 | Header Files
29 |
30 |
31 |
32 |
33 | Source Files
34 |
35 |
36 | Source Files
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/UIAutomation/FunctionalTests/FunctionalTests.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/MessageBuilder.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #include "pch.h"
5 | #include "MessageBuilder.h"
6 |
7 | void MessageBuilder::WriteBool(bool val)
8 | {
9 | WriteByte(val ? 1 : 0);
10 | }
11 |
12 | void MessageBuilder::WriteByte(uint8_t val)
13 | {
14 | static_assert(sizeof(uint8_t) == 1, "uint8_t expected to be 1 byte");
15 | WriteBytes(&val, sizeof(val));
16 | }
17 |
18 | void MessageBuilder::WriteChar(wchar_t val)
19 | {
20 | static_assert(sizeof(wchar_t) == 2, "wchar_t expected to be 2 bytes");
21 | WriteBytes(reinterpret_cast(&val), sizeof(val));
22 | }
23 |
24 | void MessageBuilder::WriteInt(int val)
25 | {
26 | static_assert(sizeof(int) == 4, "int expected to be 4 bytes");
27 | WriteBytes(reinterpret_cast(&val), sizeof(val));
28 | }
29 |
30 | void MessageBuilder::WriteUnsignedInt(unsigned int val)
31 | {
32 | static_assert(sizeof(unsigned int) == 4, "unsigned int expected to be 4 bytes");
33 | WriteBytes(reinterpret_cast(&val), sizeof(val));
34 | }
35 |
36 | void MessageBuilder::WriteDouble(double val)
37 | {
38 | static_assert(sizeof(double) == 8, "double expected to be 8 bytes");
39 | WriteBytes(reinterpret_cast(&val), sizeof(val));
40 | }
41 |
42 | void MessageBuilder::WriteString(std::wstring_view val)
43 | {
44 | static_assert(sizeof(wchar_t) == 2, "wchar_t expected to be 2 bytes");
45 | WriteInt(static_cast(val.size()));
46 | WriteBytes(reinterpret_cast(val.data()), val.size() * sizeof(wchar_t));
47 | }
48 |
49 | void MessageBuilder::WriteGuid(const GUID& val)
50 | {
51 | static_assert(sizeof(GUID) == 16, "GUID expected to be 16 bytes");
52 | WriteBytes(reinterpret_cast(&val), sizeof(val));
53 | }
54 |
55 | std::vector MessageBuilder::DetachBuffer()
56 | {
57 | return std::move(m_buffer);
58 | }
59 |
60 | void MessageBuilder::WriteBytes(_In_reads_(count) const uint8_t* bytes, size_t count)
61 | {
62 | std::copy(bytes, bytes + count, std::back_inserter(m_buffer));
63 | }
64 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/AutomationRemoteOperationResultSet.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 | #include "AutomationRemoteOperationResultSet.g.h"
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | namespace winrt
13 | {
14 | using namespace winrt::Microsoft::UI::UIAutomation;
15 | using namespace winrt::Windows::Foundation;
16 | using namespace winrt::Windows::Foundation::Collections;
17 | }
18 |
19 | namespace winrt::Microsoft::UI::UIAutomation::implementation
20 | {
21 | // This class represents the results that we get back after executing a RemoteOperation.
22 | //
23 | // It exposes an interface that allows callers to look up results based on ResponseTokens that were
24 | // previously produced by the remote operation.
25 | //
26 | // The result is always a generic IInspectable and the client needs to convert it to the appropriate local
27 | // representation that matches the remote stand-in object that was requested as a result.
28 | //
29 | // The client can also "interrogate" this type (QueryInterface) to work out what the local type really is.
30 | //
31 | // Scalar values (such as ints, doubles, Rects, Points, etc.) will be represented by a boxed IInspectable; the
32 | // client should simply unbox it.
33 | struct AutomationRemoteOperationResultSet : AutomationRemoteOperationResultSetT
34 | {
35 | explicit AutomationRemoteOperationResultSet(winrt::Windows::UI::UIAutomation::Core::AutomationRemoteOperationResult result) :
36 | m_result(std::move(result))
37 | {
38 | }
39 |
40 | winrt::hresult OperationStatus();
41 |
42 | winrt::Windows::UI::UIAutomation::Core::AutomationRemoteOperationStatus Status();
43 |
44 | winrt::hresult ExtendedError();
45 |
46 | bool HasResult(winrt::AutomationRemoteOperationResponseToken const& token);
47 | winrt::IInspectable GetResult(winrt::AutomationRemoteOperationResponseToken const& token);
48 |
49 | private:
50 | winrt::Windows::UI::UIAutomation::Core::AutomationRemoteOperationResult m_result;
51 | };
52 | }
53 |
--------------------------------------------------------------------------------
/src/UIAutomation/SharpConsoleAppDemo/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 |
6 | using Microsoft.UI.UIAutomation;
7 | using Windows.UI.UIAutomation.Core;
8 |
9 | namespace SharpConsoleAppDemo
10 | {
11 | class Program
12 | {
13 | static void Main(string[] args)
14 | {
15 | // Demonstrates how to activate the UIAutomation platform CoreAutomationRemoteOperation runtimeclass.
16 | // This is a lower-level API that Microsoft.UI.UIAutomation.AutomationRemoteOperation is built on top of.
17 | Console.WriteLine("Activating Windows.UI.UIAutomation.Core.CoreAutomationRemoteOperation...");
18 | try
19 | {
20 | CoreAutomationRemoteOperation coreOp = new CoreAutomationRemoteOperation();
21 | }
22 | catch (Exception)
23 | {
24 | Console.WriteLine("Failed to activate the platform runtimeclass. Are you running on a machine with the required platform support?");
25 | throw;
26 | }
27 | Console.WriteLine("Activated!");
28 |
29 | // Demonstrates activating the builder library's AutomationRemoteOperation. This is what most clients would want to use,
30 | // rather than the platform's CoreAutomationRemoteOperation.
31 | //
32 | // The helper will create a platform CoreAutomationRemoteOperation under the hood and use it to actually execute the
33 | // operation that is built up through its more convenient API.
34 | Console.WriteLine("Activating Microsoft.UI.UIAutomation.AutomationRemoteOperation...");
35 | try
36 | {
37 | AutomationRemoteOperation op = new AutomationRemoteOperation();
38 | }
39 | catch (System.TypeLoadException ex)
40 | {
41 | if (ex.InnerException.HResult == -2147221164)
42 | {
43 | Console.WriteLine("REGDB_E_CLASSNOTREG -- is the SxS manifest built?");
44 | }
45 | throw;
46 | }
47 | catch (System.IO.FileNotFoundException)
48 | {
49 | Console.WriteLine("FileNotFound -- is Microsoft.UI.UIAutomation.dll in the same dir as this exe?");
50 | throw;
51 | }
52 | catch (System.BadImageFormatException)
53 | {
54 | Console.WriteLine("BadImageFormat -- is Microsoft.UI.UIAutomation.dll of opposite bitness from this exe?");
55 | throw;
56 | }
57 |
58 | Console.WriteLine("Activated!");
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Security
4 |
5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6 |
7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
8 |
9 | ## Reporting Security Issues
10 |
11 | **Please do not report security vulnerabilities through public GitHub issues.**
12 |
13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
14 |
15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
16 |
17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
18 |
19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20 |
21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22 | * Full paths of source file(s) related to the manifestation of the issue
23 | * The location of the affected source code (tag/branch/commit or direct URL)
24 | * Any special configuration required to reproduce the issue
25 | * Step-by-step instructions to reproduce the issue
26 | * Proof-of-concept or exploit code (if possible)
27 | * Impact of the issue, including how an attacker might exploit the issue
28 |
29 | This information will help us triage your report more quickly.
30 |
31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
32 |
33 | ## Preferred Languages
34 |
35 | We prefer all communications to be in English.
36 |
37 | ## Policy
38 |
39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
40 |
41 |
--------------------------------------------------------------------------------
/src/UIAutomation/SharpConsoleAppDemo/SharpConsoleAppDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E7DA5D8D-01C1-401E-8613-352A19E12538}
8 | Exe
9 | SharpConsoleAppDemo
10 | SharpConsoleAppDemo
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | SharpConsoleAppDemo.exe.manifest
18 |
19 |
20 | AnyCPU
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | AnyCPU
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 | ..\Microsoft.UI.UIAutomation\Generated Files\winmd\Microsoft.UI.UIAutomation.winmd
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | ..\Microsoft.UI.UIAutomation\Generated Files\winmd\Windows.winmd
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/src/UIAutomation/FunctionalTests/TestUtils.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 |
6 | #include "CppUnitTest.h"
7 |
8 | #include
9 | #include "winrt/Microsoft.UI.UIAutomation.h"
10 |
11 | using namespace Microsoft::VisualStudio::CppUnitTestFramework;
12 |
13 | namespace winrt
14 | {
15 | using namespace winrt::Windows::UI::UIAutomation;
16 | using namespace winrt::Microsoft::UI::UIAutomation;
17 | }
18 |
19 |
20 | namespace Microsoft::VisualStudio::CppUnitTestFramework
21 | {
22 | // This template specialization is required to allow the
23 | // CppUnitTestFramework to compare `winrt::hstring`s in its assert macro.
24 | // The string returned here will be printed in the output of the assert.
25 | //
26 | // Suppress unused warning on ToString function. While it may not be used
27 | // in all .cpp files that include this header, it is still used in some.
28 | #pragma warning(push)
29 | #pragma warning(disable: 4505)
30 | template<>
31 | std::wstring ToString(const winrt::hstring& str)
32 | #pragma warning(pop)
33 | {
34 | return str.c_str();
35 | }
36 | }
37 |
38 | template
39 | void LogOutput(Args&&... args)
40 | {
41 | using namespace Microsoft::VisualStudio::CppUnitTestFramework;
42 |
43 | std::wostringstream oss;
44 | (oss << ... << args);
45 | oss << std::endl;
46 |
47 | auto res = oss.str();
48 | Logger::WriteMessage(res.c_str());
49 | }
50 |
51 | // Waits until the given element gains focus.
52 | // Fails if the element doesn't gain focus after the given number of retries.
53 | // Returns the found element on success.
54 | inline winrt::com_ptr WaitForElementFocus(const wchar_t* elementName, int retries = 100)
55 | {
56 | static constexpr DWORD c_sleepMilliseconds = 50;
57 | winrt::com_ptr automation;
58 | THROW_IF_FAILED(::CoCreateInstance(__uuidof(CUIAutomation8), nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(automation.put())));
59 |
60 | for (int i = 0; i < retries; ++i)
61 | {
62 | winrt::com_ptr element;
63 | const auto getFocusedElementHr = automation->GetFocusedElement(element.put());
64 | if (getFocusedElementHr == E_INVALIDARG)
65 | {
66 | LogOutput(L"GetFocusedElement returned E_INVALIDARG; retrying");
67 | Sleep(c_sleepMilliseconds);
68 | continue;
69 | }
70 | THROW_IF_FAILED(getFocusedElementHr);
71 |
72 | wil::unique_bstr name;
73 | THROW_IF_FAILED(element->get_CurrentName(&name));
74 | THROW_HR_IF_NULL(E_UNEXPECTED, name);
75 | LogOutput(L"Name: ", name.get());
76 | if (std::wstring(name.get()) == elementName)
77 | {
78 | LogOutput(L"Found element");
79 | return element;
80 | }
81 |
82 | ::Sleep(c_sleepMilliseconds);
83 | }
84 |
85 | LogOutput(L"Element never gained focus.");
86 | THROW_HR(E_FAIL);
87 | }
88 |
89 | inline void AssertSucceeded(const HRESULT hr)
90 | {
91 | Assert::IsTrue(SUCCEEDED(hr));
92 | }
93 |
94 | inline void AssertFailed(const HRESULT hr)
95 | {
96 | Assert::IsTrue(FAILED(hr));
97 | }
98 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/AutomationRemoteOperationMethods.g.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #pragma once
6 |
7 | winrt::AutomationRemoteActiveEnd NewEnum(AutomationActiveEnd initialValue);
8 | winrt::AutomationRemoteAnimationStyle NewEnum(AutomationAnimationStyle initialValue);
9 | winrt::AutomationRemoteAnnotationType NewEnum(AutomationAnnotationType initialValue);
10 | winrt::AutomationRemoteBulletStyle NewEnum(AutomationBulletStyle initialValue);
11 | winrt::AutomationRemoteCapStyle NewEnum(AutomationCapStyle initialValue);
12 | winrt::AutomationRemoteCaretBidiMode NewEnum(AutomationCaretBidiMode initialValue);
13 | winrt::AutomationRemoteCaretPosition NewEnum(AutomationCaretPosition initialValue);
14 | winrt::AutomationRemoteControlType NewEnum(AutomationControlType initialValue);
15 | winrt::AutomationRemoteDockPosition NewEnum(AutomationDockPosition initialValue);
16 | winrt::AutomationRemoteExpandCollapseState NewEnum(AutomationExpandCollapseState initialValue);
17 | winrt::AutomationRemoteFlowDirections NewEnum(AutomationFlowDirections initialValue);
18 | winrt::AutomationRemoteHeadingLevel NewEnum(AutomationHeadingLevel initialValue);
19 | winrt::AutomationRemoteHorizontalTextAlignment NewEnum(AutomationHorizontalTextAlignment initialValue);
20 | winrt::AutomationRemoteLandmarkType NewEnum(AutomationLandmarkType initialValue);
21 | winrt::AutomationRemoteLiveSetting NewEnum(AutomationLiveSetting initialValue);
22 | winrt::AutomationRemoteMetadata NewEnum(AutomationMetadata initialValue);
23 | winrt::AutomationRemoteNavigateDirection NewEnum(AutomationNavigateDirection initialValue);
24 | winrt::AutomationRemoteOrientationType NewEnum(AutomationOrientationType initialValue);
25 | winrt::AutomationRemoteOutlineStyles NewEnum(AutomationOutlineStyles initialValue);
26 | winrt::AutomationRemotePatternId NewEnum(AutomationPatternId initialValue);
27 | winrt::AutomationRemotePropertyId NewEnum(AutomationPropertyId initialValue);
28 | winrt::AutomationRemoteRowOrColumnMajor NewEnum(AutomationRowOrColumnMajor initialValue);
29 | winrt::AutomationRemoteSayAsInterpretAs NewEnum(AutomationSayAsInterpretAs initialValue);
30 | winrt::AutomationRemoteScrollAmount NewEnum(AutomationScrollAmount initialValue);
31 | winrt::AutomationRemoteStyleId NewEnum(AutomationStyleId initialValue);
32 | winrt::AutomationRemoteSupportedTextSelection NewEnum(AutomationSupportedTextSelection initialValue);
33 | winrt::AutomationRemoteSynchronizedInputType NewEnum(AutomationSynchronizedInputType initialValue);
34 | winrt::AutomationRemoteTextAttributeId NewEnum(AutomationTextAttributeId initialValue);
35 | winrt::AutomationRemoteTextDecorationLineStyle NewEnum(AutomationTextDecorationLineStyle initialValue);
36 | winrt::AutomationRemoteTextPatternRangeEndpoint NewEnum(AutomationTextPatternRangeEndpoint initialValue);
37 | winrt::AutomationRemoteTextUnit NewEnum(AutomationTextUnit initialValue);
38 | winrt::AutomationRemoteToggleState NewEnum(AutomationToggleState initialValue);
39 | winrt::AutomationRemoteWindowInteractionState NewEnum(AutomationWindowInteractionState initialValue);
40 | winrt::AutomationRemoteWindowVisualState NewEnum(AutomationWindowVisualState initialValue);
41 | winrt::AutomationRemoteZoomUnit NewEnum(AutomationZoomUnit initialValue);
42 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/RemoteOperationInstructionsVariantParams.g.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #pragma once
6 | ,
7 | GetInvokePattern,
8 | GetSelectionPattern,
9 | GetValuePattern,
10 | GetRangeValuePattern,
11 | GetScrollPattern,
12 | GetExpandCollapsePattern,
13 | GetGridPattern,
14 | GetGridItemPattern,
15 | GetMultipleViewPattern,
16 | GetWindowPattern,
17 | GetSelectionItemPattern,
18 | GetDockPattern,
19 | GetTablePattern,
20 | GetTableItemPattern,
21 | GetTextPattern,
22 | GetTogglePattern,
23 | GetTransformPattern,
24 | GetScrollItemPattern,
25 | GetLegacyIAccessiblePattern,
26 | GetItemContainerPattern,
27 | GetVirtualizedItemPattern,
28 | GetSynchronizedInputPattern,
29 | GetAnnotationPattern,
30 | GetTextPattern2,
31 | GetStylesPattern,
32 | GetSpreadsheetPattern,
33 | GetSpreadsheetItemPattern,
34 | GetTransformPattern2,
35 | GetTextChildPattern,
36 | GetDragPattern,
37 | GetDropTargetPattern,
38 | GetTextEditPattern,
39 | GetCustomNavigationPattern,
40 | GetSelectionPattern2,
41 | InvokePatternInvoke,
42 | ValuePatternSetValue,
43 | RangeValuePatternSetValue,
44 | ScrollPatternScroll,
45 | ScrollPatternSetScrollPercent,
46 | ExpandCollapsePatternExpand,
47 | ExpandCollapsePatternCollapse,
48 | GridPatternGetItem,
49 | MultipleViewPatternGetViewName,
50 | MultipleViewPatternSetCurrentView,
51 | WindowPatternClose,
52 | WindowPatternWaitForInputIdle,
53 | WindowPatternSetWindowVisualState,
54 | SelectionItemPatternSelect,
55 | SelectionItemPatternAddToSelection,
56 | SelectionItemPatternRemoveFromSelection,
57 | DockPatternSetDockPosition,
58 | TextPatternRangeFromPoint,
59 | TextPatternRangeFromChild,
60 | TextPatternGetSelection,
61 | TextPatternGetVisibleRanges,
62 | TextPatternGetDocumentRange,
63 | TextPatternGetSupportedTextSelection,
64 | TextRangeClone,
65 | TextRangeCompare,
66 | TextRangeCompareEndpoints,
67 | TextRangeExpandToEnclosingUnit,
68 | TextRangeFindAttribute,
69 | TextRangeFindText,
70 | TextRangeGetAttributeValue,
71 | TextRangeGetBoundingRectangles,
72 | TextRangeGetEnclosingElement,
73 | TextRangeGetText,
74 | TextRangeMove,
75 | TextRangeMoveEndpointByUnit,
76 | TextRangeMoveEndpointByRange,
77 | TextRangeSelect,
78 | TextRangeAddToSelection,
79 | TextRangeRemoveFromSelection,
80 | TextRangeScrollIntoView,
81 | TextRangeGetChildren,
82 | TextRangeShowContextMenu,
83 | TogglePatternToggle,
84 | TransformPatternMove,
85 | TransformPatternResize,
86 | TransformPatternRotate,
87 | ScrollItemPatternScrollIntoView,
88 | LegacyIAccessiblePatternSelect,
89 | LegacyIAccessiblePatternDoDefaultAction,
90 | LegacyIAccessiblePatternSetValue,
91 | ItemContainerPatternFindItemByProperty,
92 | VirtualizedItemPatternRealize,
93 | SynchronizedInputPatternStartListening,
94 | SynchronizedInputPatternCancel,
95 | TextPattern2RangeFromAnnotation,
96 | TextPattern2GetCaretRange,
97 | SpreadsheetPatternGetItemByName,
98 | TransformPattern2Zoom,
99 | TransformPattern2ZoomByUnit,
100 | TextChildPatternGetTextContainer,
101 | TextChildPatternGetTextRange,
102 | TextEditPatternGetActiveComposition,
103 | TextEditPatternGetConversionTarget,
104 | CustomNavigationPatternNavigate
105 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/RemoteOperationGraph.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | #pragma once
4 |
5 | #include
6 |
7 | #include "RemoteOperationInstructions.h"
8 |
9 | // A helper class that is used to build up a bytecode stream and serialize it to a byte buffer.
10 | class BytecodeBuilder
11 | {
12 | public:
13 | // Emit a bytecode instruction into the stream.
14 | void Emit(const bytecode::Instruction& instruction);
15 |
16 | // Copy the full bytecode stream from the given builder, by appending to the end of the target object.
17 | void CopyFromBuilder(const BytecodeBuilder& other);
18 |
19 | int GetInstructionCount() const;
20 |
21 | // Serializes the bytecode into a byte buffer.
22 | std::vector SerializeInstructionsToBuffer() const;
23 |
24 | private:
25 | std::vector m_bytecodeInstructions;
26 |
27 | // The current version of bytecode that this Builder emits.
28 | static constexpr unsigned int c_bytecodeCurrentVersion = 0u;
29 | };
30 |
31 | class RemoteOperationGraph
32 | {
33 | public:
34 | RemoteOperationGraph() = default;
35 |
36 | struct IfStatementSubgraphs
37 | {
38 | std::shared_ptr trueBlockSubgraph;
39 | std::shared_ptr falseBlockSubgraph;
40 | };
41 | IfStatementSubgraphs AddIfStatement(int operandId);
42 |
43 | struct WhileLoopSubgraphs
44 | {
45 | std::shared_ptr bodySubgraph;
46 | std::shared_ptr conditionUpdateSubgraph;
47 | };
48 | WhileLoopSubgraphs AddWhileLoop(int operandId);
49 |
50 | struct TryStatementSubgraphs
51 | {
52 | std::shared_ptr tryBodySubgraph;
53 | std::shared_ptr catchBodySubgraph;
54 | };
55 | TryStatementSubgraphs AddTryStatement();
56 |
57 | void AddInstruction(const bytecode::Instruction& instruction);
58 |
59 | std::vector Serialize() const;
60 |
61 | private:
62 | // Represents a single bytecode instruction.
63 | struct InstructionNode
64 | {
65 | bytecode::Instruction instruction;
66 |
67 | void SerializeToBuilder(BytecodeBuilder& builder) const;
68 | };
69 |
70 | // Represents an if statement node. Contains two subgraphs for the true and false blocks.
71 | // References an operand register ID, which should be the register that holds the boolean that the
72 | // if statement will switch on.
73 | struct IfStatementNode
74 | {
75 | int conditionOperandId;
76 | std::shared_ptr trueBody;
77 | std::shared_ptr falseBody;
78 |
79 | void SerializeToBuilder(BytecodeBuilder& builder) const;
80 | };
81 |
82 | // Represents a while loop node. Contains two subgraphs: the body of the loop and a "condition update"
83 | // graph. The latter are instructions that should be executed any time an iteration through the loop
84 | // is completed, before re-evaluating the condition.
85 | struct WhileLoopNode
86 | {
87 | int conditionOperandId;
88 | std::shared_ptr body;
89 | std::shared_ptr conditionUpdate;
90 |
91 | void SerializeToBuilder(BytecodeBuilder& builder) const;
92 | };
93 |
94 | // Represents a try statement. Contains two subgraphs: the body of the try block and the catch block.
95 | // Any failure that occurs in the try block will cause control flow to move to the catch block.
96 | struct TryStatementNode
97 | {
98 | std::shared_ptr tryBody;
99 | std::shared_ptr catchBody;
100 |
101 | void SerializeToBuilder(BytecodeBuilder& builder) const;
102 | };
103 |
104 | using Node = std::variant;
105 |
106 | BytecodeBuilder CompileBytecode() const;
107 |
108 | std::vector m_nodes;
109 | };
110 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/RemoteOperationInstructionSerializerMethods.g.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #pragma once
6 |
7 | void Write(const bytecode::InvokePatternInvoke&);
8 | void Write(const bytecode::ValuePatternSetValue&);
9 | void Write(const bytecode::RangeValuePatternSetValue&);
10 | void Write(const bytecode::ScrollPatternScroll&);
11 | void Write(const bytecode::ScrollPatternSetScrollPercent&);
12 | void Write(const bytecode::ExpandCollapsePatternExpand&);
13 | void Write(const bytecode::ExpandCollapsePatternCollapse&);
14 | void Write(const bytecode::GridPatternGetItem&);
15 | void Write(const bytecode::MultipleViewPatternGetViewName&);
16 | void Write(const bytecode::MultipleViewPatternSetCurrentView&);
17 | void Write(const bytecode::WindowPatternClose&);
18 | void Write(const bytecode::WindowPatternWaitForInputIdle&);
19 | void Write(const bytecode::WindowPatternSetWindowVisualState&);
20 | void Write(const bytecode::SelectionItemPatternSelect&);
21 | void Write(const bytecode::SelectionItemPatternAddToSelection&);
22 | void Write(const bytecode::SelectionItemPatternRemoveFromSelection&);
23 | void Write(const bytecode::DockPatternSetDockPosition&);
24 | void Write(const bytecode::TextPatternRangeFromPoint&);
25 | void Write(const bytecode::TextPatternRangeFromChild&);
26 | void Write(const bytecode::TextPatternGetSelection&);
27 | void Write(const bytecode::TextPatternGetVisibleRanges&);
28 | void Write(const bytecode::TextPatternGetDocumentRange&);
29 | void Write(const bytecode::TextPatternGetSupportedTextSelection&);
30 | void Write(const bytecode::TextRangeClone&);
31 | void Write(const bytecode::TextRangeCompare&);
32 | void Write(const bytecode::TextRangeCompareEndpoints&);
33 | void Write(const bytecode::TextRangeExpandToEnclosingUnit&);
34 | void Write(const bytecode::TextRangeFindAttribute&);
35 | void Write(const bytecode::TextRangeFindText&);
36 | void Write(const bytecode::TextRangeGetAttributeValue&);
37 | void Write(const bytecode::TextRangeGetBoundingRectangles&);
38 | void Write(const bytecode::TextRangeGetEnclosingElement&);
39 | void Write(const bytecode::TextRangeGetText&);
40 | void Write(const bytecode::TextRangeMove&);
41 | void Write(const bytecode::TextRangeMoveEndpointByUnit&);
42 | void Write(const bytecode::TextRangeMoveEndpointByRange&);
43 | void Write(const bytecode::TextRangeSelect&);
44 | void Write(const bytecode::TextRangeAddToSelection&);
45 | void Write(const bytecode::TextRangeRemoveFromSelection&);
46 | void Write(const bytecode::TextRangeScrollIntoView&);
47 | void Write(const bytecode::TextRangeGetChildren&);
48 | void Write(const bytecode::TextRangeShowContextMenu&);
49 | void Write(const bytecode::TogglePatternToggle&);
50 | void Write(const bytecode::TransformPatternMove&);
51 | void Write(const bytecode::TransformPatternResize&);
52 | void Write(const bytecode::TransformPatternRotate&);
53 | void Write(const bytecode::ScrollItemPatternScrollIntoView&);
54 | void Write(const bytecode::LegacyIAccessiblePatternSelect&);
55 | void Write(const bytecode::LegacyIAccessiblePatternDoDefaultAction&);
56 | void Write(const bytecode::LegacyIAccessiblePatternSetValue&);
57 | void Write(const bytecode::ItemContainerPatternFindItemByProperty&);
58 | void Write(const bytecode::VirtualizedItemPatternRealize&);
59 | void Write(const bytecode::SynchronizedInputPatternStartListening&);
60 | void Write(const bytecode::SynchronizedInputPatternCancel&);
61 | void Write(const bytecode::TextPattern2RangeFromAnnotation&);
62 | void Write(const bytecode::TextPattern2GetCaretRange&);
63 | void Write(const bytecode::SpreadsheetPatternGetItemByName&);
64 | void Write(const bytecode::TransformPattern2Zoom&);
65 | void Write(const bytecode::TransformPattern2ZoomByUnit&);
66 | void Write(const bytecode::TextChildPatternGetTextContainer&);
67 | void Write(const bytecode::TextChildPatternGetTextRange&);
68 | void Write(const bytecode::TextEditPatternGetActiveComposition&);
69 | void Write(const bytecode::TextEditPatternGetConversionTarget&);
70 | void Write(const bytecode::CustomNavigationPatternNavigate&);
71 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/Microsoft.UI.UIAutomation.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 | Header Files
29 |
30 |
31 | Header Files
32 |
33 |
34 | Header Files
35 |
36 |
37 | Header Files
38 |
39 |
40 | Header Files
41 |
42 |
43 | Header Files
44 |
45 |
46 | Header Files
47 |
48 |
49 | Header Files
50 |
51 |
52 | Header Files
53 |
54 |
55 | Header Files
56 |
57 |
58 | Header Files
59 |
60 |
61 | Header Files
62 |
63 |
64 | Header Files
65 |
66 |
67 | Header Files
68 |
69 |
70 |
71 |
72 | Source Files
73 |
74 |
75 | Source Files
76 |
77 |
78 | Source Files
79 |
80 |
81 | Source Files
82 |
83 |
84 | Source Files
85 |
86 |
87 | Source Files
88 |
89 |
90 | Source Files
91 |
92 |
93 | Source Files
94 |
95 |
96 | Source Files
97 |
98 |
99 | Source Files
100 |
101 |
102 | Source Files
103 |
104 |
105 |
106 |
107 | Source Files
108 |
109 |
110 |
111 |
112 | Source Files
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://dev.azure.com/ms/Microsoft-UI-UIAutomation/_build/latest?definitionId=378&branchName=main)
2 |
3 | # Windows UIAutomation platform utility libraries
4 |
5 | This repository contains utility libraries that simplify consuming [Windows UIAutomation](https://docs.microsoft.com/en-us/windows/win32/winauto/entry-uiauto-win32)
6 | APIs.
7 |
8 | ## UIAutomation Remote Operations
9 |
10 | Remote Operations is an upcoming API exposed by the Windows UIAutomation platform, that aims to give clients
11 | the flexibility to avoid the explosion of cross-process calls by giving them control over when cross-process
12 | work happens. This flexibility allows clients to build applications that perform fewer cross-process calls,
13 | reducing the overhead of cross-process communication latency.
14 |
15 | This library exposes an API that simplifies constructing and executing Remote Operations, by exposing a
16 | higher-level API that mirrors the existing/"classic" COM UIA APIs.
17 |
18 | The platform API is currently part of preview Windows builds and the preview SDK. It requires a Windows build
19 | `10.0.19613.0` or newer at runtime and a matching preview SDK to build the solution.
20 |
21 | Changes to the underlying platform APIs are still possible and as such this library itself might need to
22 | evolve alongside the platform.
23 |
24 | ### WinRT Builder API
25 |
26 | The bulk of the Remote Operations helper code is in a WinRT API exposed by the `Microsoft.UI.UIAutomation` DLL
27 | built from the project of the same name. This DLL exposes an API under the `Microsoft.UI.UIAutomation`
28 | namespace, which helps build up a Remote Operation by using a natural API, that closely mirrors classic
29 | UIA APIs.
30 |
31 | This API can be consumed from a wide variety of programming languages. For C++ consumers, we recommend
32 | using the [C++/WinRT projection](https://github.com/Microsoft/cppwinrt). See the functional tests project
33 | for an example.
34 |
35 | Other languages, such as Python or C# can also consume WinRT through language-specific projections.
36 | For instance, see the minimal C# demo that's included in the project.
37 |
38 | Please note that WinRT as the ABI technology of choice in no way precludes clients from consuming
39 | this API from plain Win32 processes. WinRT does not tie APIs to _only_ be usable from [Universal
40 | Windows Applications](https://docs.microsoft.com/en-us/windows/uwp/get-started/universal-application-platform-guide).
41 |
42 | ### C++ Abstraction
43 |
44 | The `UiaOperationAbstraction` project contains a static C++ library that consumers can use in their
45 | C++ client code. The goal of this library is to provide a C++ interface that lets users write code
46 | to express a UIAutomation algorithm that can then be executed as part of a single Remote Operation or
47 | in a "classic" approach where each call elicits a separate cross-process call.
48 |
49 | This allows clients to switch between the two "modes" dynamically, which can be helpful for interop
50 | with existing code that doesn't use Remote Operations or for simpler debugging of the logic in an
51 | algorithm.
52 |
53 | Note that this library isn't necessarily the best fit for every C++ consumer, as the ability to switch
54 | between these "modes" does come at a runtime cost.
55 |
56 | ### Building
57 |
58 | In order to build the solution, please make sure you have the [Windows Insider Preview SDK](https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewSDK)
59 | installed.
60 |
61 | The solution can then be built either from Visual Studio or simply from the Visual Studio Developer
62 | Console using `msbuild`. For instance:
63 |
64 | ```
65 | msbuild UIAutomation.sln /p:Configuration=Release,Platform=x64
66 | ```
67 |
68 | These projects target SDK version 10.0. Note that breaking changes can occur in preview SDKs, so if you install a new preview SDK there are no guarantees that the platform API will be unchanged and as such the projects might not build or they could work differently at runtime.
69 |
70 | # Contributing
71 |
72 | This project welcomes contributions and suggestions. Most contributions require you to agree to a
73 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
74 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
75 |
76 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide
77 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
78 | provided by the bot. You will only need to do this once across all repos using our CLA.
79 |
80 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
81 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
82 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
83 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/RemoteOperationInstructionEnumValuesArray.g.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #pragma once
6 |
7 | InstructionType::GetInvokePattern,
8 | InstructionType::GetSelectionPattern,
9 | InstructionType::GetValuePattern,
10 | InstructionType::GetRangeValuePattern,
11 | InstructionType::GetScrollPattern,
12 | InstructionType::GetExpandCollapsePattern,
13 | InstructionType::GetGridPattern,
14 | InstructionType::GetGridItemPattern,
15 | InstructionType::GetMultipleViewPattern,
16 | InstructionType::GetWindowPattern,
17 | InstructionType::GetSelectionItemPattern,
18 | InstructionType::GetDockPattern,
19 | InstructionType::GetTablePattern,
20 | InstructionType::GetTableItemPattern,
21 | InstructionType::GetTextPattern,
22 | InstructionType::GetTogglePattern,
23 | InstructionType::GetTransformPattern,
24 | InstructionType::GetScrollItemPattern,
25 | InstructionType::GetLegacyIAccessiblePattern,
26 | InstructionType::GetItemContainerPattern,
27 | InstructionType::GetVirtualizedItemPattern,
28 | InstructionType::GetSynchronizedInputPattern,
29 | InstructionType::GetAnnotationPattern,
30 | InstructionType::GetTextPattern2,
31 | InstructionType::GetStylesPattern,
32 | InstructionType::GetSpreadsheetPattern,
33 | InstructionType::GetSpreadsheetItemPattern,
34 | InstructionType::GetTransformPattern2,
35 | InstructionType::GetTextChildPattern,
36 | InstructionType::GetDragPattern,
37 | InstructionType::GetDropTargetPattern,
38 | InstructionType::GetTextEditPattern,
39 | InstructionType::GetCustomNavigationPattern,
40 | InstructionType::GetSelectionPattern2,
41 | InstructionType::InvokePatternInvoke,
42 | InstructionType::ValuePatternSetValue,
43 | InstructionType::RangeValuePatternSetValue,
44 | InstructionType::ScrollPatternScroll,
45 | InstructionType::ScrollPatternSetScrollPercent,
46 | InstructionType::ExpandCollapsePatternExpand,
47 | InstructionType::ExpandCollapsePatternCollapse,
48 | InstructionType::GridPatternGetItem,
49 | InstructionType::MultipleViewPatternGetViewName,
50 | InstructionType::MultipleViewPatternSetCurrentView,
51 | InstructionType::WindowPatternClose,
52 | InstructionType::WindowPatternWaitForInputIdle,
53 | InstructionType::WindowPatternSetWindowVisualState,
54 | InstructionType::SelectionItemPatternSelect,
55 | InstructionType::SelectionItemPatternAddToSelection,
56 | InstructionType::SelectionItemPatternRemoveFromSelection,
57 | InstructionType::DockPatternSetDockPosition,
58 | InstructionType::TextPatternRangeFromPoint,
59 | InstructionType::TextPatternRangeFromChild,
60 | InstructionType::TextPatternGetSelection,
61 | InstructionType::TextPatternGetVisibleRanges,
62 | InstructionType::TextPatternGetDocumentRange,
63 | InstructionType::TextPatternGetSupportedTextSelection,
64 | InstructionType::TextRangeClone,
65 | InstructionType::TextRangeCompare,
66 | InstructionType::TextRangeCompareEndpoints,
67 | InstructionType::TextRangeExpandToEnclosingUnit,
68 | InstructionType::TextRangeFindAttribute,
69 | InstructionType::TextRangeFindText,
70 | InstructionType::TextRangeGetAttributeValue,
71 | InstructionType::TextRangeGetBoundingRectangles,
72 | InstructionType::TextRangeGetEnclosingElement,
73 | InstructionType::TextRangeGetText,
74 | InstructionType::TextRangeMove,
75 | InstructionType::TextRangeMoveEndpointByUnit,
76 | InstructionType::TextRangeMoveEndpointByRange,
77 | InstructionType::TextRangeSelect,
78 | InstructionType::TextRangeAddToSelection,
79 | InstructionType::TextRangeRemoveFromSelection,
80 | InstructionType::TextRangeScrollIntoView,
81 | InstructionType::TextRangeGetChildren,
82 | InstructionType::TextRangeShowContextMenu,
83 | InstructionType::TogglePatternToggle,
84 | InstructionType::TransformPatternMove,
85 | InstructionType::TransformPatternResize,
86 | InstructionType::TransformPatternRotate,
87 | InstructionType::ScrollItemPatternScrollIntoView,
88 | InstructionType::LegacyIAccessiblePatternSelect,
89 | InstructionType::LegacyIAccessiblePatternDoDefaultAction,
90 | InstructionType::LegacyIAccessiblePatternSetValue,
91 | InstructionType::ItemContainerPatternFindItemByProperty,
92 | InstructionType::VirtualizedItemPatternRealize,
93 | InstructionType::SynchronizedInputPatternStartListening,
94 | InstructionType::SynchronizedInputPatternCancel,
95 | InstructionType::TextPattern2RangeFromAnnotation,
96 | InstructionType::TextPattern2GetCaretRange,
97 | InstructionType::SpreadsheetPatternGetItemByName,
98 | InstructionType::TransformPattern2Zoom,
99 | InstructionType::TransformPattern2ZoomByUnit,
100 | InstructionType::TextChildPatternGetTextContainer,
101 | InstructionType::TextChildPatternGetTextRange,
102 | InstructionType::TextEditPatternGetActiveComposition,
103 | InstructionType::TextEditPatternGetConversionTarget,
104 | InstructionType::CustomNavigationPatternNavigate,
105 |
--------------------------------------------------------------------------------
/src/UIAutomation/UIAutomation.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29920.165
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.UI.UIAutomation", "Microsoft.UI.UIAutomation\Microsoft.UI.UIAutomation.vcxproj", "{7D645239-F96E-4FBE-BAA4-B92838B9D361}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FunctionalTests", "FunctionalTests\FunctionalTests.vcxproj", "{ADC03671-2DB4-4130-BC73-B78314046BFB}"
9 | ProjectSection(ProjectDependencies) = postProject
10 | {7D645239-F96E-4FBE-BAA4-B92838B9D361} = {7D645239-F96E-4FBE-BAA4-B92838B9D361}
11 | EndProjectSection
12 | EndProject
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpConsoleAppDemo", "SharpConsoleAppDemo\SharpConsoleAppDemo.csproj", "{E7DA5D8D-01C1-401E-8613-352A19E12538}"
14 | ProjectSection(ProjectDependencies) = postProject
15 | {7D645239-F96E-4FBE-BAA4-B92838B9D361} = {7D645239-F96E-4FBE-BAA4-B92838B9D361}
16 | EndProjectSection
17 | EndProject
18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UiaOperationAbstraction", "UiaOperationAbstraction\UiaOperationAbstraction.vcxproj", "{A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}"
19 | ProjectSection(ProjectDependencies) = postProject
20 | {7D645239-F96E-4FBE-BAA4-B92838B9D361} = {7D645239-F96E-4FBE-BAA4-B92838B9D361}
21 | EndProjectSection
22 | EndProject
23 | Global
24 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
25 | Debug|Any CPU = Debug|Any CPU
26 | Debug|x64 = Debug|x64
27 | Debug|x86 = Debug|x86
28 | Release|Any CPU = Release|Any CPU
29 | Release|x64 = Release|x64
30 | Release|x86 = Release|x86
31 | EndGlobalSection
32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
33 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Debug|Any CPU.ActiveCfg = Debug|Win32
34 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Debug|x64.ActiveCfg = Debug|x64
35 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Debug|x64.Build.0 = Debug|x64
36 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Debug|x86.ActiveCfg = Debug|Win32
37 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Debug|x86.Build.0 = Debug|Win32
38 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Release|Any CPU.ActiveCfg = Release|Win32
39 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Release|x64.ActiveCfg = Release|x64
40 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Release|x64.Build.0 = Release|x64
41 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Release|x86.ActiveCfg = Release|Win32
42 | {7D645239-F96E-4FBE-BAA4-B92838B9D361}.Release|x86.Build.0 = Release|Win32
43 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Debug|Any CPU.ActiveCfg = Debug|Win32
44 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Debug|x64.ActiveCfg = Debug|x64
45 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Debug|x64.Build.0 = Debug|x64
46 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Debug|x86.ActiveCfg = Debug|Win32
47 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Debug|x86.Build.0 = Debug|Win32
48 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Release|Any CPU.ActiveCfg = Release|Win32
49 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Release|x64.ActiveCfg = Release|x64
50 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Release|x64.Build.0 = Release|x64
51 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Release|x86.ActiveCfg = Release|Win32
52 | {ADC03671-2DB4-4130-BC73-B78314046BFB}.Release|x86.Build.0 = Release|Win32
53 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Debug|Any CPU.Build.0 = Debug|Any CPU
55 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Debug|x64.ActiveCfg = Debug|Any CPU
56 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Debug|x64.Build.0 = Debug|Any CPU
57 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Debug|x86.ActiveCfg = Debug|Any CPU
58 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Debug|x86.Build.0 = Debug|Any CPU
59 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Release|Any CPU.Build.0 = Release|Any CPU
61 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Release|x64.ActiveCfg = Release|Any CPU
62 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Release|x64.Build.0 = Release|Any CPU
63 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Release|x86.ActiveCfg = Release|Any CPU
64 | {E7DA5D8D-01C1-401E-8613-352A19E12538}.Release|x86.Build.0 = Release|Any CPU
65 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Debug|Any CPU.ActiveCfg = Debug|Win32
66 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Debug|x64.ActiveCfg = Debug|x64
67 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Debug|x64.Build.0 = Debug|x64
68 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Debug|x86.ActiveCfg = Debug|Win32
69 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Debug|x86.Build.0 = Debug|Win32
70 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Release|Any CPU.ActiveCfg = Release|Win32
71 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Release|x64.ActiveCfg = Release|x64
72 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Release|x64.Build.0 = Release|x64
73 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Release|x86.ActiveCfg = Release|Win32
74 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}.Release|x86.Build.0 = Release|Win32
75 | EndGlobalSection
76 | GlobalSection(SolutionProperties) = preSolution
77 | HideSolutionNode = FALSE
78 | EndGlobalSection
79 | GlobalSection(ExtensibilityGlobals) = postSolution
80 | SolutionGuid = {85730654-4C85-4910-A69A-D9181B170E9F}
81 | EndGlobalSection
82 | EndGlobal
83 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/AutomationRemoteElementMethods.g.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #pragma once
6 |
7 | winrt::AutomationRemoteArray GetRuntimeId();
8 | winrt::AutomationRemoteInt GetProcessId();
9 | winrt::AutomationRemoteControlType GetControlType();
10 | winrt::AutomationRemoteString GetLocalizedControlType();
11 | winrt::AutomationRemoteString GetName();
12 | winrt::AutomationRemoteString GetAcceleratorKey();
13 | winrt::AutomationRemoteString GetAccessKey();
14 | winrt::AutomationRemoteBool GetHasKeyboardFocus();
15 | winrt::AutomationRemoteBool GetIsKeyboardFocusable();
16 | winrt::AutomationRemoteBool GetIsEnabled();
17 | winrt::AutomationRemoteString GetAutomationId();
18 | winrt::AutomationRemoteString GetClassName();
19 | winrt::AutomationRemoteString GetHelpText();
20 | winrt::AutomationRemoteInt GetCulture();
21 | winrt::AutomationRemoteBool GetIsControlElement();
22 | winrt::AutomationRemoteBool GetIsContentElement();
23 | winrt::AutomationRemoteBool GetIsPassword();
24 | winrt::AutomationRemoteInt GetNativeWindowHandle();
25 | winrt::AutomationRemoteString GetItemType();
26 | winrt::AutomationRemoteBool GetIsOffscreen();
27 | winrt::AutomationRemoteOrientationType GetOrientation();
28 | winrt::AutomationRemoteString GetFrameworkId();
29 | winrt::AutomationRemoteBool GetIsRequiredForForm();
30 | winrt::AutomationRemoteString GetItemStatus();
31 | winrt::AutomationRemoteRect GetBoundingRectangle();
32 | winrt::AutomationRemoteElement GetLabeledBy();
33 | winrt::AutomationRemoteString GetAriaRole();
34 | winrt::AutomationRemoteString GetAriaProperties();
35 | winrt::AutomationRemoteBool GetIsDataValidForForm();
36 | winrt::AutomationRemoteArray GetControllerFor();
37 | winrt::AutomationRemoteArray GetDescribedBy();
38 | winrt::AutomationRemoteArray GetFlowsTo();
39 | winrt::AutomationRemoteString GetProviderDescription();
40 | winrt::AutomationRemoteBool GetOptimizeForVisualContent();
41 | winrt::AutomationRemoteLiveSetting GetLiveSetting();
42 | winrt::AutomationRemoteArray GetFlowsFrom();
43 | winrt::AutomationRemoteBool GetIsPeripheral();
44 | winrt::AutomationRemoteInt GetPositionInSet();
45 | winrt::AutomationRemoteInt GetSizeOfSet();
46 | winrt::AutomationRemoteInt GetLevel();
47 | winrt::AutomationRemoteArray GetAnnotationTypes();
48 | winrt::AutomationRemoteArray GetAnnotationObjects();
49 | winrt::AutomationRemoteLandmarkType GetLandmarkType();
50 | winrt::AutomationRemoteString GetLocalizedLandmarkType();
51 | winrt::AutomationRemoteString GetFullDescription();
52 | winrt::AutomationRemoteHeadingLevel GetHeadingLevel();
53 | winrt::AutomationRemoteBool GetIsDialog();
54 | winrt::AutomationRemoteInvokePattern GetInvokePattern();
55 | winrt::AutomationRemoteSelectionPattern GetSelectionPattern();
56 | winrt::AutomationRemoteValuePattern GetValuePattern();
57 | winrt::AutomationRemoteRangeValuePattern GetRangeValuePattern();
58 | winrt::AutomationRemoteScrollPattern GetScrollPattern();
59 | winrt::AutomationRemoteExpandCollapsePattern GetExpandCollapsePattern();
60 | winrt::AutomationRemoteGridPattern GetGridPattern();
61 | winrt::AutomationRemoteGridItemPattern GetGridItemPattern();
62 | winrt::AutomationRemoteMultipleViewPattern GetMultipleViewPattern();
63 | winrt::AutomationRemoteWindowPattern GetWindowPattern();
64 | winrt::AutomationRemoteSelectionItemPattern GetSelectionItemPattern();
65 | winrt::AutomationRemoteDockPattern GetDockPattern();
66 | winrt::AutomationRemoteTablePattern GetTablePattern();
67 | winrt::AutomationRemoteTableItemPattern GetTableItemPattern();
68 | winrt::AutomationRemoteTextPattern GetTextPattern();
69 | winrt::AutomationRemoteTogglePattern GetTogglePattern();
70 | winrt::AutomationRemoteTransformPattern GetTransformPattern();
71 | winrt::AutomationRemoteScrollItemPattern GetScrollItemPattern();
72 | winrt::AutomationRemoteLegacyIAccessiblePattern GetLegacyIAccessiblePattern();
73 | winrt::AutomationRemoteItemContainerPattern GetItemContainerPattern();
74 | winrt::AutomationRemoteVirtualizedItemPattern GetVirtualizedItemPattern();
75 | winrt::AutomationRemoteSynchronizedInputPattern GetSynchronizedInputPattern();
76 | winrt::AutomationRemoteAnnotationPattern GetAnnotationPattern();
77 | winrt::AutomationRemoteTextPattern2 GetTextPattern2();
78 | winrt::AutomationRemoteStylesPattern GetStylesPattern();
79 | winrt::AutomationRemoteSpreadsheetPattern GetSpreadsheetPattern();
80 | winrt::AutomationRemoteSpreadsheetItemPattern GetSpreadsheetItemPattern();
81 | winrt::AutomationRemoteTransformPattern2 GetTransformPattern2();
82 | winrt::AutomationRemoteTextChildPattern GetTextChildPattern();
83 | winrt::AutomationRemoteDragPattern GetDragPattern();
84 | winrt::AutomationRemoteDropTargetPattern GetDropTargetPattern();
85 | winrt::AutomationRemoteTextEditPattern GetTextEditPattern();
86 | winrt::AutomationRemoteCustomNavigationPattern GetCustomNavigationPattern();
87 | winrt::AutomationRemoteSelectionPattern2 GetSelectionPattern2();
88 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/RemoteOperationInstructionSerialization.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | #pragma once
4 |
5 | #include "RemoteOperationInstructions.h"
6 | #include "MessageBuilder.h"
7 |
8 | // Implements the "serialization" layer of Remote Operations. It allows the conversion of any RemoteOperation Instruction
9 | // into an on-the-wire bytecode format that the UIAutomation platform can understand.
10 | struct RemoteOperationInstructionSerializer
11 | {
12 | public:
13 | explicit RemoteOperationInstructionSerializer(MessageBuilder& builder) : m_builder(builder) {}
14 |
15 | void Serialize(const bytecode::Instruction& instruction);
16 |
17 | private:
18 | // Serializes the given concrete Instruction.
19 | template
20 | void SerializeInstruction(const InstructionT& instruction);
21 |
22 | // A helper that writes the instruction "header". For now, that's just the instruction type.
23 | void WriteInstructionHeader(bytecode::InstructionType type);
24 |
25 | // Helpers for primitive types
26 | void Write(const bytecode::OperandId& operandId);
27 | void Write(bool value);
28 | void Write(int value);
29 | void Write(unsigned value);
30 | void Write(double value);
31 | void Write(wchar_t value);
32 | void Write(const std::wstring& value);
33 | void Write(const UiaPoint& value);
34 | void Write(const UiaRect& value);
35 | void Write(const GUID& value);
36 | void Write(const uint8_t& value);
37 |
38 | // Write the instructions themselves...
39 | void Write(const bytecode::Nop&);
40 | void Write(const bytecode::Set&);
41 | void Write(const bytecode::NewBool&);
42 | void Write(const bytecode::NewInt&);
43 | void Write(const bytecode::NewUint&);
44 | void Write(const bytecode::NewDouble&);
45 | void Write(const bytecode::NewChar&);
46 | void Write(const bytecode::NewString&);
47 | void Write(const bytecode::NewPoint&);
48 | void Write(const bytecode::NewRect&);
49 | void Write(const bytecode::NewGuid&);
50 | void Write(const bytecode::NewArray&);
51 | void Write(const bytecode::NewStringMap&);
52 | void Write(const bytecode::NewNull&);
53 | void Write(const bytecode::NewCacheRequest&);
54 | void Write(const bytecode::GetPointProperty&);
55 | void Write(const bytecode::GetRectProperty&);
56 | void Write(const bytecode::SetOperationStatus&);
57 | void Write(const bytecode::GetOperationStatus&);
58 |
59 | void Write(const bytecode::ForkIfTrue&);
60 | void Write(const bytecode::ForkIfFalse&);
61 | void Write(const bytecode::Fork&);
62 |
63 | void Write(const bytecode::NewLoopBlock&);
64 | void Write(const bytecode::EndLoopBlock&);
65 | void Write(const bytecode::BreakLoop&);
66 | void Write(const bytecode::ContinueLoop&);
67 |
68 | void Write(const bytecode::NewTryBlock&);
69 | void Write(const bytecode::EndTryBlock&);
70 |
71 | void Write(const bytecode::Halt&);
72 |
73 | void Write(const bytecode::RemoteArrayAppend&);
74 | void Write(const bytecode::RemoteArraySetAt&);
75 | void Write(const bytecode::RemoteArrayRemoveAt&);
76 | void Write(const bytecode::RemoteArrayGetAt&);
77 | void Write(const bytecode::RemoteArraySize&);
78 |
79 | void Write(const bytecode::RemoteStringMapInsert&);
80 | void Write(const bytecode::RemoteStringMapRemove&);
81 | void Write(const bytecode::RemoteStringMapHasKey&);
82 | void Write(const bytecode::RemoteStringMapLookup&);
83 | void Write(const bytecode::RemoteStringMapSize&);
84 |
85 | void Write(const bytecode::RemoteStringGetAt&);
86 | void Write(const bytecode::RemoteStringSubstr&);
87 | void Write(const bytecode::RemoteStringConcat&);
88 | void Write(const bytecode::RemoteStringSize&);
89 |
90 | void Write(const bytecode::Add&);
91 | void Write(const bytecode::Subtract&);
92 | void Write(const bytecode::Multiply&);
93 | void Write(const bytecode::Divide&);
94 |
95 | void Write(const bytecode::BinaryAdd&);
96 | void Write(const bytecode::BinarySubtract&);
97 | void Write(const bytecode::BinaryMultiply&);
98 | void Write(const bytecode::BinaryDivide&);
99 |
100 | void Write(const bytecode::InPlaceBoolNot&);
101 | void Write(const bytecode::InPlaceBoolAnd&);
102 | void Write(const bytecode::InPlaceBoolOr&);
103 |
104 | void Write(const bytecode::CacheRequestAddProperty&);
105 | void Write(const bytecode::CacheRequestAddPattern&);
106 |
107 | void Write(const bytecode::BoolNot&);
108 | void Write(const bytecode::BoolAnd&);
109 | void Write(const bytecode::BoolOr&);
110 | void Write(const bytecode::Compare&);
111 | void Write(const bytecode::GetPropertyValue&);
112 | void Write(const bytecode::Navigate&);
113 | void Write(const bytecode::PopulateCache&);
114 | void Write(const bytecode::GetMetadataValue&);
115 | void Write(const bytecode::LookupId&);
116 | void Write(const bytecode::LookupGuid&);
117 | void Write(const bytecode::Stringify&);
118 | void Write(const bytecode::CallExtension&);
119 | void Write(const bytecode::IsExtensionSupported&);
120 | void Write(const bytecode::IsExtensionTarget&);
121 | void Write(const bytecode::NewByteArray&);
122 |
123 | void Write(const bytecode::GetterBase&);
124 | #include "RemoteOperationInstructionSerializerMethods.g.h"
125 |
126 | MessageBuilder& m_builder;
127 | };
128 |
129 | template
130 | void RemoteOperationInstructionSerializer::SerializeInstruction(const InstructionT& instruction)
131 | {
132 | // Every instruction type should have a constexpr static associated with it providing the type.
133 | WriteInstructionHeader(InstructionT::type);
134 |
135 | // After writing the header, write the instruction itself.
136 | Write(instruction);
137 | }
138 |
139 |
--------------------------------------------------------------------------------
/src/UIAutomation/FunctionalTests/ModernApp.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #include "pch.h"
5 | #include "ModernApp.h"
6 |
7 | #include
8 | #include
9 |
10 | #include
11 |
12 | #include "winrt/Windows.Foundation.Collections.h"
13 | #include "winrt/windows.management.deployment.h"
14 |
15 | #include
16 | #include
17 |
18 | #include "TestUtils.h"
19 |
20 | namespace wrl = Microsoft::WRL;
21 |
22 | namespace
23 | {
24 | std::wstring MakeFilePath(_In_z_ const wchar_t* fileName)
25 | {
26 | std::array currentDirectory;
27 | ::GetCurrentDirectory(static_cast(currentDirectory.size()), currentDirectory.data());
28 | return std::wstring(currentDirectory.data()) + L"\\" + fileName;
29 | }
30 |
31 | DWORD GetPidFromHwnd(HWND hwnd) noexcept
32 | {
33 | DWORD childProcessId = 0;
34 | ::GetWindowThreadProcessId(hwnd, &childProcessId);
35 | return childProcessId;
36 | }
37 |
38 | bool IsConsoleWindow(HWND hwnd)
39 | {
40 | std::array testClassName{};
41 | ::GetClassName(hwnd, testClassName.data(), static_cast(testClassName.size()));
42 | return (::lstrcmpi(testClassName.data(), L"ConsoleWindowClass") == 0);
43 | }
44 |
45 | void TerminateProcess(DWORD processId)
46 | {
47 | wil::unique_handle processHandle { ::OpenProcess(PROCESS_TERMINATE, FALSE /* inheritHandle */, processId) };
48 | THROW_IF_WIN32_BOOL_FALSE(::TerminateProcess(processHandle.get(), 0xFFFFFFFF /* exitCode */));
49 | ::WaitForSingleObject(processHandle.get(), 10000);
50 | }
51 | }
52 |
53 | ModernApp::ModernApp(_In_z_ const wchar_t* testAppAumid) :
54 | m_testAppAumid(testAppAumid)
55 | {
56 | }
57 |
58 | ModernApp::ModernApp(_In_z_ const wchar_t* testAppAumid, _In_z_ const wchar_t* exeName) :
59 | m_testAppAumid(testAppAumid), m_exeName(exeName)
60 | {
61 | }
62 |
63 | ModernApp::~ModernApp() noexcept
64 | {
65 | // Ensure no exceptions are thrown by the destructor.
66 | // This way, we get the test failures rather than Watson dumps.
67 | try
68 | {
69 | Close();
70 | }
71 | catch (...)
72 | {
73 | }
74 | }
75 |
76 | /* static */
77 | bool ModernApp::RegisterTestAppx(_In_z_ const wchar_t* appxName)
78 | {
79 | auto path = MakeFilePath(appxName);
80 |
81 | winrt::Windows::Foundation::Uri uri(path.c_str());
82 | winrt::Windows::Management::Deployment::PackageManager packageManager;
83 | auto res = packageManager.AddPackageAsync(uri, {}, winrt::Windows::Management::Deployment::DeploymentOptions::ForceApplicationShutdown);
84 |
85 | const auto deploymentResult = res.get();
86 | if (deploymentResult.IsRegistered())
87 | {
88 | LogOutput(L"Successfully registered package: ", appxName);
89 | }
90 | else
91 | {
92 | LogOutput(L"Failed to register ", appxName);
93 | return false;
94 | }
95 |
96 | return true;
97 | }
98 |
99 | /* static */
100 | void ModernApp::RemoveTestAppx(_In_z_ const wchar_t* packageName)
101 | {
102 | LogOutput(L"Removing package: ", packageName);
103 |
104 | winrt::Windows::Management::Deployment::PackageManager packageManager;
105 | auto res = packageManager.RemovePackageAsync(packageName);
106 | auto deploymentResult = res.get();
107 | }
108 |
109 | void ModernApp::Activate(_In_opt_z_ const wchar_t* testAppArguments /* = nullptr */)
110 | {
111 | if (m_appProcessId == 0)
112 | {
113 | wrl::ComPtr activationManager;
114 | THROW_IF_FAILED(::CoCreateInstance(
115 | CLSID_ApplicationActivationManager,
116 | nullptr,
117 | CLSCTX_INPROC_SERVER,
118 | IID_PPV_ARGS(&activationManager)));
119 |
120 | // Sometimes, when run under stress, we are opening and closing the test app rapidly and we may fail
121 | // to activate it because it is "updating". This should eventually settle down, so to avoid seeing
122 | // test failures in this case, we'll try multiple times to activate the application.
123 | const int retries = 10;
124 | DWORD appProcessId = 0;
125 | HRESULT activateResult = S_OK;
126 | for (int i = 0; i < retries; ++i)
127 | {
128 | LogOutput(L"Attempting to activate: ", m_testAppAumid.c_str());
129 |
130 | activateResult = activationManager->ActivateApplication(m_testAppAumid.c_str(), testAppArguments, AO_NOERRORUI, &appProcessId);
131 | // Give the app time to settle, or have a delay between attempts to activate
132 | std::this_thread::sleep_for(std::chrono::milliseconds(1000));
133 |
134 | if (SUCCEEDED(activateResult))
135 | {
136 | break;
137 | }
138 | }
139 | THROW_IF_FAILED(activateResult);
140 | m_appProcessId = appProcessId;
141 | }
142 | // else we're already activated
143 | }
144 |
145 | void ModernApp::Close()
146 | {
147 | if (m_appProcessId != 0)
148 | {
149 | TerminateProcess(m_appProcessId);
150 | m_appProcessId = 0;
151 |
152 | // The process should be gone now, but if a test is being run under stress, then it may immediately try to
153 | // launch the same process again, and sometimes that does not work properly (the app will launch minimized).
154 | // Adding an artificial delay here to be extra certain that the app is gone alleviates the problem.
155 | std::this_thread::sleep_for(std::chrono::milliseconds(2000));
156 | }
157 | }
158 |
159 | DWORD ModernApp::GetAppProcessId() noexcept
160 | {
161 | return m_appProcessId;
162 | }
163 |
164 | void ModernApp::WaitForWindow(std::function checkIfWindowMatches)
165 | {
166 | // Give the app up to two minutes to start.
167 | for (int attempt = 0 ; attempt < 240 ; attempt++)
168 | {
169 | if (TryFindWindowNow(checkIfWindowMatches))
170 | {
171 | return;
172 | }
173 | ::Sleep(500);
174 | }
175 | }
176 |
177 | bool ModernApp::TryFindWindowNow(std::function checkIfWindowMatches)
178 | {
179 | HWND hwndChild = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
180 | while (hwndChild != nullptr)
181 | {
182 | const bool foundResult = checkIfWindowMatches(hwndChild);
183 | if (foundResult)
184 | {
185 | return true;
186 | }
187 |
188 | hwndChild = ::GetWindow(hwndChild, GW_HWNDNEXT);
189 | }
190 |
191 | return false;
192 | }
193 |
194 | HWND ModernApp::GetMainWindow()
195 | {
196 | if (!m_hwnd)
197 | {
198 | WaitForWindow([this](HWND hwnd)
199 | {
200 | // Ignore invisible worker windows and console windows
201 | if (!::IsWindowVisible(hwnd) || IsConsoleWindow(hwnd))
202 | {
203 | return false;
204 | }
205 | if (GetPidFromHwnd(hwnd) == m_appProcessId)
206 | {
207 | // Tada! Found my process.
208 | m_hwnd = hwnd;
209 | return true;
210 | }
211 |
212 | return false;
213 | });
214 | }
215 |
216 | return m_hwnd;
217 | }
218 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/AutomationRemoteAnyObjectMethods.g.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #pragma once
6 |
7 | winrt::AutomationRemoteBool IsInvokePattern();
8 | winrt::AutomationRemoteInvokePattern AsInvokePattern();
9 | winrt::AutomationRemoteBool IsSelectionPattern();
10 | winrt::AutomationRemoteSelectionPattern AsSelectionPattern();
11 | winrt::AutomationRemoteBool IsValuePattern();
12 | winrt::AutomationRemoteValuePattern AsValuePattern();
13 | winrt::AutomationRemoteBool IsRangeValuePattern();
14 | winrt::AutomationRemoteRangeValuePattern AsRangeValuePattern();
15 | winrt::AutomationRemoteBool IsScrollPattern();
16 | winrt::AutomationRemoteScrollPattern AsScrollPattern();
17 | winrt::AutomationRemoteBool IsExpandCollapsePattern();
18 | winrt::AutomationRemoteExpandCollapsePattern AsExpandCollapsePattern();
19 | winrt::AutomationRemoteBool IsGridPattern();
20 | winrt::AutomationRemoteGridPattern AsGridPattern();
21 | winrt::AutomationRemoteBool IsGridItemPattern();
22 | winrt::AutomationRemoteGridItemPattern AsGridItemPattern();
23 | winrt::AutomationRemoteBool IsMultipleViewPattern();
24 | winrt::AutomationRemoteMultipleViewPattern AsMultipleViewPattern();
25 | winrt::AutomationRemoteBool IsWindowPattern();
26 | winrt::AutomationRemoteWindowPattern AsWindowPattern();
27 | winrt::AutomationRemoteBool IsSelectionItemPattern();
28 | winrt::AutomationRemoteSelectionItemPattern AsSelectionItemPattern();
29 | winrt::AutomationRemoteBool IsDockPattern();
30 | winrt::AutomationRemoteDockPattern AsDockPattern();
31 | winrt::AutomationRemoteBool IsTablePattern();
32 | winrt::AutomationRemoteTablePattern AsTablePattern();
33 | winrt::AutomationRemoteBool IsTableItemPattern();
34 | winrt::AutomationRemoteTableItemPattern AsTableItemPattern();
35 | winrt::AutomationRemoteBool IsTextPattern();
36 | winrt::AutomationRemoteTextPattern AsTextPattern();
37 | winrt::AutomationRemoteBool IsTextRange();
38 | winrt::AutomationRemoteTextRange AsTextRange();
39 | winrt::AutomationRemoteConnectionBoundObject AsConnectionBoundObject();
40 | winrt::AutomationRemoteBool IsTogglePattern();
41 | winrt::AutomationRemoteTogglePattern AsTogglePattern();
42 | winrt::AutomationRemoteBool IsTransformPattern();
43 | winrt::AutomationRemoteTransformPattern AsTransformPattern();
44 | winrt::AutomationRemoteBool IsScrollItemPattern();
45 | winrt::AutomationRemoteScrollItemPattern AsScrollItemPattern();
46 | winrt::AutomationRemoteBool IsLegacyIAccessiblePattern();
47 | winrt::AutomationRemoteLegacyIAccessiblePattern AsLegacyIAccessiblePattern();
48 | winrt::AutomationRemoteBool IsItemContainerPattern();
49 | winrt::AutomationRemoteItemContainerPattern AsItemContainerPattern();
50 | winrt::AutomationRemoteBool IsVirtualizedItemPattern();
51 | winrt::AutomationRemoteVirtualizedItemPattern AsVirtualizedItemPattern();
52 | winrt::AutomationRemoteBool IsSynchronizedInputPattern();
53 | winrt::AutomationRemoteSynchronizedInputPattern AsSynchronizedInputPattern();
54 | winrt::AutomationRemoteBool IsAnnotationPattern();
55 | winrt::AutomationRemoteAnnotationPattern AsAnnotationPattern();
56 | winrt::AutomationRemoteBool IsTextPattern2();
57 | winrt::AutomationRemoteTextPattern2 AsTextPattern2();
58 | winrt::AutomationRemoteBool IsStylesPattern();
59 | winrt::AutomationRemoteStylesPattern AsStylesPattern();
60 | winrt::AutomationRemoteBool IsSpreadsheetPattern();
61 | winrt::AutomationRemoteSpreadsheetPattern AsSpreadsheetPattern();
62 | winrt::AutomationRemoteBool IsSpreadsheetItemPattern();
63 | winrt::AutomationRemoteSpreadsheetItemPattern AsSpreadsheetItemPattern();
64 | winrt::AutomationRemoteBool IsTransformPattern2();
65 | winrt::AutomationRemoteTransformPattern2 AsTransformPattern2();
66 | winrt::AutomationRemoteBool IsTextChildPattern();
67 | winrt::AutomationRemoteTextChildPattern AsTextChildPattern();
68 | winrt::AutomationRemoteBool IsDragPattern();
69 | winrt::AutomationRemoteDragPattern AsDragPattern();
70 | winrt::AutomationRemoteBool IsDropTargetPattern();
71 | winrt::AutomationRemoteDropTargetPattern AsDropTargetPattern();
72 | winrt::AutomationRemoteBool IsTextEditPattern();
73 | winrt::AutomationRemoteTextEditPattern AsTextEditPattern();
74 | winrt::AutomationRemoteBool IsCustomNavigationPattern();
75 | winrt::AutomationRemoteCustomNavigationPattern AsCustomNavigationPattern();
76 | winrt::AutomationRemoteBool IsSelectionPattern2();
77 | winrt::AutomationRemoteSelectionPattern2 AsSelectionPattern2();
78 | winrt::AutomationRemoteActiveEnd AsActiveEnd();
79 | winrt::AutomationRemoteAnimationStyle AsAnimationStyle();
80 | winrt::AutomationRemoteAnnotationType AsAnnotationType();
81 | winrt::AutomationRemoteBulletStyle AsBulletStyle();
82 | winrt::AutomationRemoteCapStyle AsCapStyle();
83 | winrt::AutomationRemoteCaretBidiMode AsCaretBidiMode();
84 | winrt::AutomationRemoteCaretPosition AsCaretPosition();
85 | winrt::AutomationRemoteControlType AsControlType();
86 | winrt::AutomationRemoteDockPosition AsDockPosition();
87 | winrt::AutomationRemoteExpandCollapseState AsExpandCollapseState();
88 | winrt::AutomationRemoteFlowDirections AsFlowDirections();
89 | winrt::AutomationRemoteHeadingLevel AsHeadingLevel();
90 | winrt::AutomationRemoteHorizontalTextAlignment AsHorizontalTextAlignment();
91 | winrt::AutomationRemoteLandmarkType AsLandmarkType();
92 | winrt::AutomationRemoteLiveSetting AsLiveSetting();
93 | winrt::AutomationRemoteMetadata AsMetadata();
94 | winrt::AutomationRemoteNavigateDirection AsNavigateDirection();
95 | winrt::AutomationRemoteOrientationType AsOrientationType();
96 | winrt::AutomationRemoteOutlineStyles AsOutlineStyles();
97 | winrt::AutomationRemotePatternId AsPatternId();
98 | winrt::AutomationRemotePropertyId AsPropertyId();
99 | winrt::AutomationRemoteRowOrColumnMajor AsRowOrColumnMajor();
100 | winrt::AutomationRemoteSayAsInterpretAs AsSayAsInterpretAs();
101 | winrt::AutomationRemoteScrollAmount AsScrollAmount();
102 | winrt::AutomationRemoteStyleId AsStyleId();
103 | winrt::AutomationRemoteSupportedTextSelection AsSupportedTextSelection();
104 | winrt::AutomationRemoteSynchronizedInputType AsSynchronizedInputType();
105 | winrt::AutomationRemoteTextAttributeId AsTextAttributeId();
106 | winrt::AutomationRemoteTextDecorationLineStyle AsTextDecorationLineStyle();
107 | winrt::AutomationRemoteTextPatternRangeEndpoint AsTextPatternRangeEndpoint();
108 | winrt::AutomationRemoteTextUnit AsTextUnit();
109 | winrt::AutomationRemoteToggleState AsToggleState();
110 | winrt::AutomationRemoteWindowInteractionState AsWindowInteractionState();
111 | winrt::AutomationRemoteWindowVisualState AsWindowVisualState();
112 | winrt::AutomationRemoteZoomUnit AsZoomUnit();
113 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/AutomationRemoteOperation.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #pragma once
5 | #include "AutomationRemoteOperation.g.h"
6 | #include "AutomationRemoteOperationResultSet.h"
7 |
8 | #include
9 | #include
10 |
11 | #include "RemoteOperationInstructions.h"
12 | #include "RemoteOperationGraph.h"
13 |
14 | #include
15 | #include
16 |
17 |
18 | namespace winrt::Microsoft::UI::UIAutomation::implementation
19 | {
20 | // This class represents the main entry point to Remote Operations.
21 | //
22 | // There are two primary ways to add new instructions to be executed as part of the remote operation:
23 | //
24 | // 1. Import an existing IUIAutomation{Element,TextRange,etc.} object, obtaining a local "stand-in"
25 | // for a remote object. Calling methods on the stand-in adds new instructions to the operation.
26 | // Most methods on the stand-in objects have a return value that represents a stand-in for the
27 | // object returned by that operation. This can be used to continue chaining operations.
28 | //
29 | // 2. Create a new remote object as part of the operation. This is done with methods like NewInt or
30 | // NewBool. These methods also return a stand-in, that exposes operations that can be triggered on
31 | // the object as part of the remote operation. The difference is that these objects alone aren't
32 | // tied to any particular provider process.
33 | //
34 | // Note that if the client imports objects that belong to different connections/processes, the operation
35 | // will return failure.
36 | struct AutomationRemoteOperation : AutomationRemoteOperationT
37 | {
38 | AutomationRemoteOperation();
39 |
40 | // Internal
41 |
42 | // Inserts a new instruction into the operation's current scope.
43 | // Ultimately, all "stand-in" objects eventually need to make a call to this
44 | // method to insert any useful work that should occur on the provider side.
45 | void InsertInstruction(const bytecode::Instruction& instruction);
46 | // Returns a brand new ID that can be used to identify operands in the remote
47 | // operation (e.g. to assign the result of an instruction to an operand).
48 | bytecode::OperandId GetNextId();
49 | // Requests that the operand with the given ID be marshaled back to the client
50 | // as part of the response.
51 | void RequestResponse(bytecode::OperandId remoteOperationId);
52 |
53 | // API
54 | winrt::AutomationRemoteBool NewBool(bool initialValue);
55 | winrt::AutomationRemoteInt NewInt(int32_t initialValue);
56 | winrt::AutomationRemoteUint NewUint(uint32_t initialValue);
57 | winrt::AutomationRemoteDouble NewDouble(double initialValue);
58 | winrt::AutomationRemoteChar NewChar(wchar_t initialValue);
59 | winrt::AutomationRemoteString NewString(hstring const& initialValue);
60 | winrt::AutomationRemotePoint NewPoint(Windows::Foundation::Point const& initialValue);
61 | winrt::AutomationRemoteRect NewRect(Windows::Foundation::Rect const& initialValue);
62 | bool IsGuidSupported() const;
63 | winrt::AutomationRemoteGuid NewGuid(const winrt::guid& initialValue);
64 | bool IsCacheRequestSupported() const;
65 | winrt::AutomationRemoteCacheRequest NewCacheRequest();
66 | winrt::AutomationRemoteArray NewArray();
67 | winrt::AutomationRemoteStringMap NewStringMap();
68 | winrt::AutomationRemoteAnyObject NewNull();
69 | winrt::AutomationRemoteAnyObject NewEmpty();
70 | winrt::AutomationRemoteByteArray NewByteArray(winrt::array_view initialValue);
71 |
72 | // Returns whether the given opcode is supported in the current remote
73 | // operation connection. Calls directly into the corresponding
74 | // CoreAutomationRemoteOperation API. Throws E_FAIL if no connection is
75 | // currently active.
76 | // TODO #77: Specify which Windows release we start throwing that error.
77 | bool IsOpcodeSupported(uint32_t opcode) const;
78 |
79 | winrt::AutomationRemoteElement ImportElement(winrt::Windows::UI::UIAutomation::AutomationElement const& element);
80 | winrt::AutomationRemoteTextRange ImportTextRange(winrt::Windows::UI::UIAutomation::AutomationTextRange const& textRange);
81 | winrt::AutomationRemoteConnectionBoundObject ImportConnectionBoundObject(winrt::Windows::UI::UIAutomation::AutomationConnectionBoundObject const& connectionBoundObject);
82 |
83 | AutomationRemoteOperationResponseToken RequestResponse(const winrt::AutomationRemoteObject& object);
84 |
85 | void IfBlock(
86 | const winrt::AutomationRemoteBool& condition,
87 | const AutomationRemoteOperationScopeHandler& trueHandler,
88 | const AutomationRemoteOperationScopeHandler& falseHandler = nullptr);
89 | void WhileBlock(
90 | const winrt::AutomationRemoteBool& condition,
91 | const AutomationRemoteOperationScopeHandler& loopBodyHandler,
92 | const AutomationRemoteOperationScopeHandler& loopConditionUpdateHandler = nullptr);
93 |
94 | void ReturnOperationStatus(winrt::hresult status);
95 | void ReturnOperationStatus(const winrt::AutomationRemoteInt& status);
96 |
97 | void BreakLoop();
98 | void ContinueLoop();
99 |
100 | void TryBlock(
101 | const AutomationRemoteOperationScopeHandler& tryBodyHandler);
102 |
103 | void TryBlock(
104 | const AutomationRemoteOperationScopeHandler& tryBodyHandler,
105 | const AutomationRemoteOperationScopeHandler& exceptBlockHandler);
106 |
107 | winrt::AutomationRemoteInt GetCurrentFailureCode();
108 |
109 | winrt::AutomationRemoteOperationResultSet Execute();
110 |
111 | #include "AutomationRemoteOperationMethods.g.h"
112 |
113 | private:
114 |
115 | // Members
116 |
117 | // The ID is incremented every time a new remote OperandId is requested. The remote operation
118 | // is the only "source of truth" for operand IDs; this way we get a unique ID for any operand
119 | // in the operation.
120 | int m_nextId = 1;
121 |
122 | // The root operation graph; operation "scopes" (such as if blocks) are going to be a subgraph of
123 | // the root graph.
124 | std::shared_ptr m_rootGraph = std::make_shared();
125 |
126 | // The scope that any newly added instructions are added into. This allows us to build up
127 | // different scopes independently, but using the same API, by simply changing which
128 | // scope is considered "current".
129 | std::shared_ptr m_currentScope;
130 |
131 | // The underlying platform Remote Operation that we're preparing for execution.
132 | winrt::Windows::UI::UIAutomation::Core::CoreAutomationRemoteOperation m_remoteOperation;
133 | };
134 | }
135 | namespace winrt::Microsoft::UI::UIAutomation::factory_implementation
136 | {
137 | struct AutomationRemoteOperation : AutomationRemoteOperationT
138 | {
139 | };
140 | }
141 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
352 | # SWP files (Vim swap data)
353 | *.swp
354 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/RemoteOperationGraph.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | #include "pch.h"
4 | #include "RemoteOperationGraph.h"
5 |
6 | #include "MessageBuilder.h"
7 | #include "RemoteOperationInstructionSerialization.h"
8 |
9 | void BytecodeBuilder::Emit(const bytecode::Instruction& instruction)
10 | {
11 | m_bytecodeInstructions.emplace_back(instruction);
12 | }
13 |
14 | void BytecodeBuilder::CopyFromBuilder(const BytecodeBuilder& other)
15 | {
16 | std::copy(other.m_bytecodeInstructions.begin(), other.m_bytecodeInstructions.end(), std::back_inserter(m_bytecodeInstructions));
17 | }
18 |
19 | int BytecodeBuilder::GetInstructionCount() const
20 | {
21 | return static_cast(m_bytecodeInstructions.size());
22 | }
23 |
24 | std::vector BytecodeBuilder::SerializeInstructionsToBuffer() const
25 | {
26 | MessageBuilder builder;
27 |
28 | // The first 4 bytes are the version of the bytecode format that follows. UIA currently only
29 | // supports one version, which is what we'll emit.
30 | builder.WriteUnsignedInt(c_bytecodeCurrentVersion);
31 |
32 | // Now serialize each instruction into the bytestream.
33 | RemoteOperationInstructionSerializer serializer(builder);
34 | for (const auto& instruction : m_bytecodeInstructions)
35 | {
36 | serializer.Serialize(instruction);
37 | }
38 |
39 | return builder.DetachBuffer();
40 | }
41 |
42 | RemoteOperationGraph::IfStatementSubgraphs RemoteOperationGraph::AddIfStatement(int operandId)
43 | {
44 | auto trueBody = std::make_shared();
45 | auto falseBody = std::make_shared();
46 | m_nodes.emplace_back(IfStatementNode{ operandId, trueBody, falseBody });
47 |
48 | return { std::move(trueBody), std::move(falseBody) };
49 | }
50 |
51 | RemoteOperationGraph::WhileLoopSubgraphs RemoteOperationGraph::AddWhileLoop(int operandId)
52 | {
53 | auto loopBody = std::make_shared();
54 | auto conditionUpdate = std::make_shared();
55 | m_nodes.emplace_back(WhileLoopNode{ operandId, loopBody, conditionUpdate });
56 |
57 | return { std::move(loopBody), std::move(conditionUpdate) };
58 | }
59 |
60 | RemoteOperationGraph::TryStatementSubgraphs RemoteOperationGraph::AddTryStatement()
61 | {
62 | auto tryBody = std::make_shared();
63 | auto catchBody = std::make_shared();
64 | m_nodes.emplace_back(TryStatementNode{ tryBody, catchBody });
65 |
66 | return { std::move(tryBody), std::move(catchBody) };
67 | }
68 |
69 | void RemoteOperationGraph::AddInstruction(const bytecode::Instruction& instruction)
70 | {
71 | m_nodes.emplace_back(InstructionNode{ instruction });
72 | }
73 |
74 | BytecodeBuilder RemoteOperationGraph::CompileBytecode() const
75 | {
76 | BytecodeBuilder builder;
77 | for (const auto& node : m_nodes)
78 | {
79 | std::visit([&](const auto& node)
80 | {
81 | node.SerializeToBuilder(builder);
82 | }, node);
83 | }
84 |
85 | return builder;
86 | }
87 |
88 | std::vector RemoteOperationGraph::Serialize() const
89 | {
90 | const auto bytecode = CompileBytecode();
91 | auto byteBuffer = bytecode.SerializeInstructionsToBuffer();
92 |
93 | return byteBuffer;
94 | }
95 |
96 | void RemoteOperationGraph::InstructionNode::SerializeToBuilder(BytecodeBuilder& builder) const
97 | {
98 | builder.Emit(instruction);
99 | }
100 |
101 | void RemoteOperationGraph::IfStatementNode::SerializeToBuilder(BytecodeBuilder& builder) const
102 | {
103 | // The bytecode that we build for an If-statement first includes a ForkIfFalse that evaluates
104 | // the condition operand. This is followed by the true block; after the true block we have an
105 | // unconditional jump to skip over the false block; finally, the false block is emitted.
106 | //
107 | // For instance, for an if statement that has 2 instructions in the true block and 3 instructions
108 | // in the false block:
109 | //
110 | // 0 ForkIfFalse +4 [2+2 --> target==4]
111 | // 1 true_instruction
112 | // 2 true_instruction
113 | // 3 Fork +4 [3+1 --> target==7]
114 | // 4 false_instruction
115 | // 5 false_instruction
116 | // 6 false_instruction
117 |
118 | BytecodeBuilder trueBytecode = trueBody->CompileBytecode();
119 | BytecodeBuilder falseBytecode = falseBody->CompileBytecode();
120 |
121 | // When the operand is false, jump to the fork block by skipping over all the instructions of the true block.
122 | builder.Emit(bytecode::ForkIfFalse{
123 | bytecode::OperandId{ conditionOperandId },
124 | trueBytecode.GetInstructionCount() + 2,
125 | });
126 |
127 | // Now emit the instructions from the true block...
128 | builder.CopyFromBuilder(trueBytecode);
129 | // ...including a jump that skips over everything in the upcoming false block.
130 | builder.Emit(bytecode::Fork{ falseBytecode.GetInstructionCount() + 1 });
131 |
132 | if (falseBytecode.GetInstructionCount() > 0)
133 | {
134 | builder.CopyFromBuilder(falseBytecode);
135 | }
136 | else
137 | {
138 | // Emit a no-op so that the conditional branch always has a target for the false case.
139 | builder.Emit(bytecode::Nop{});
140 | }
141 | }
142 |
143 | void RemoteOperationGraph::WhileLoopNode::SerializeToBuilder(BytecodeBuilder& builder) const
144 | {
145 | // The bytecode for a while loop first emits a NewLoopBlock instruction indicating that a new
146 | // loop should be pushed onto the stack. Then we emit a conditional to evaluate whether the
147 | // loop body should execute. The full bytecode body is then comprised of the body and condition
148 | // update subgraphs. After this, we unconditionally jump back to the loop evaluation condition.
149 | // Finally, if the loop evaluation condition is false, we'll jump to an EndLoopBlock instruction,
150 | // popping the loop block off the stack.
151 | //
152 | // For example, for a loop block with 3 instructions in the body and 1 instruction in the condition
153 | // update block, we emit:
154 | //
155 | // 0 NewLoopBlock +8 +5 [break_target==8; continue_target==5]
156 | // 1 ForkIfFalse +6 [target==7]
157 | // 2 body_instruction
158 | // 3 body_instruction
159 | // 4 body_instruction
160 | // 5 condition_update_instruction
161 | // 6 Fork -5 [target==1]
162 | // 7 EndLoopBlock
163 |
164 | BytecodeBuilder bodyBytecode = body->CompileBytecode();
165 | BytecodeBuilder conditionUpdateBytecode = conditionUpdate->CompileBytecode();
166 |
167 | const auto totalBodyInstructionCount = bodyBytecode.GetInstructionCount() + conditionUpdateBytecode.GetInstructionCount();
168 |
169 | // The loop block encompasses all the instructions until EndLoopBlock (including EndLoopBlock). So the break offset (i.e.
170 | // the instruction to jump to when a break is encountered) is just after EndLoopBlock.
171 | const int breakLoopOffset = totalBodyInstructionCount + 4;
172 | // We want the continue to be just after the "main" body of the loop, as that puts us to the condition update block.
173 | // The jump back to the top of the loop follows that, so this way we ensure to update and then re-evaluate the
174 | // condition when continue is encountered.
175 | const int continueLoopOffset = bodyBytecode.GetInstructionCount() + 2;
176 |
177 | builder.Emit(bytecode::NewLoopBlock{ breakLoopOffset, continueLoopOffset });
178 |
179 | // If the condition is false, skip the entire body of the loop.
180 | builder.Emit(bytecode::ForkIfFalse{
181 | bytecode::OperandId{ conditionOperandId },
182 | totalBodyInstructionCount + 2,
183 | });
184 |
185 | // Emit the body of the loop. Our API allows users to separately specify a "body" and a "condition update" block for
186 | // convenience, but ultimately these are simply concatenated into the body of the loop.
187 | builder.CopyFromBuilder(bodyBytecode);
188 | builder.CopyFromBuilder(conditionUpdateBytecode);
189 |
190 | // Now we jump back to the instruction that evaluates the condition of the loop. It's the first instruction before the
191 | // full body that we just emitted.
192 | builder.Emit(bytecode::Fork{ -(totalBodyInstructionCount + 1) });
193 |
194 | builder.Emit(bytecode::EndLoopBlock{});
195 | }
196 |
197 | void RemoteOperationGraph::TryStatementNode::SerializeToBuilder(BytecodeBuilder& builder) const
198 | {
199 | // The bytecode for a try block first emits a NewTryBlock instruction, pushing the try block to
200 | // the block stack. The try body follows. After this, we emit an EndTryBlock indicating that the
201 | // try body is successfully complete and popping the block off the stack. An unconditional jump
202 | // is then added so as to skip the catch body. Finally, we emit the catch body.
203 | //
204 | // For example, for a try block with 4 instructions in the try body and 2 instructions in the catch
205 | // body, we emit the following bytecode:
206 | //
207 | // 0 NewTryBlock +7 [catch_target==7]
208 | // 1 try_block_instruction
209 | // 2 try_block_instruction
210 | // 3 try_block_instruction
211 | // 4 try_block_instruction
212 | // 5 EndTryBlock
213 | // 6 Fork +3 [target==9]
214 | // 7 catch_instruction
215 | // 8 catch_instruction
216 |
217 | BytecodeBuilder tryBodyBytecode = tryBody->CompileBytecode();
218 | BytecodeBuilder catchBodyBytecode = catchBody->CompileBytecode();
219 |
220 | builder.Emit(bytecode::NewTryBlock{ tryBodyBytecode.GetInstructionCount() + 3 });
221 | builder.CopyFromBuilder(tryBodyBytecode);
222 | builder.Emit(bytecode::EndTryBlock{});
223 |
224 | // Skip the catch block if we manage to complete the try block successfully.
225 | builder.Emit(bytecode::Fork{ catchBodyBytecode.GetInstructionCount() + 1 });
226 |
227 | // Now the catch body.
228 | builder.CopyFromBuilder(catchBodyBytecode);
229 |
230 | // Insert a nop so we can guarantee that the jump at the end of the try block has a target.
231 | builder.Emit(bytecode::Nop{});
232 | }
233 |
--------------------------------------------------------------------------------
/src/UIAutomation/UiaOperationAbstraction/SafeArrayUtil.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | #pragma once
4 |
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | namespace SafeArrayUtil
11 | {
12 |
13 | // A `unique_any` alias that handles safely disposing of a SAFEARRAY.
14 | using unique_safearray = wil::unique_any;
15 |
16 | // A helper template that can be used to map a VARTYPE to a C++ type that it represents
17 | // statically at compile time.
18 | //
19 | // # Example:
20 | // ```
21 | // using ActualType = typename VarTypeHelper::Type;
22 | // ```
23 | template
24 | struct VarTypeHelper;
25 |
26 | template<>
27 | struct VarTypeHelper
28 | {
29 | using Type = unsigned int;
30 | };
31 |
32 | template<>
33 | struct VarTypeHelper
34 | {
35 | using Type = int;
36 | };
37 |
38 | template<>
39 | struct VarTypeHelper
40 | {
41 | using Type = IUnknown*;
42 | };
43 |
44 | template<>
45 | struct VarTypeHelper
46 | {
47 | using Type = double;
48 | };
49 |
50 | template<>
51 | struct VarTypeHelper
52 | {
53 | using Type = wchar_t*;
54 | };
55 |
56 |
57 | template
58 | class SafeArrayAccessor
59 | {
60 | public:
61 | SafeArrayAccessor() = default;
62 |
63 | SafeArrayAccessor(_In_ SAFEARRAY* safeArray, VARTYPE vtExpected)
64 | {
65 | THROW_IF_FAILED(Access(safeArray, vtExpected));
66 | }
67 |
68 | ~SafeArrayAccessor()
69 | {
70 | if (m_safeArray != nullptr)
71 | {
72 | ::SafeArrayUnaccessData(m_safeArray);
73 | }
74 | }
75 |
76 | SafeArrayAccessor(const SafeArrayAccessor& rhs) = delete;
77 | SafeArrayAccessor& operator=(const SafeArrayAccessor& rhs) = delete;
78 | SafeArrayAccessor(SafeArrayAccessor&& rhs) = delete;
79 | SafeArrayAccessor& operator=(SafeArrayAccessor&& rhs) = delete;
80 |
81 | HRESULT Access(_In_ SAFEARRAY* safeArray, VARTYPE vtExpected) noexcept
82 | {
83 | FAIL_FAST_IF(m_safeArray != nullptr);
84 |
85 | RETURN_HR_IF_NULL(E_INVALIDARG, safeArray);
86 |
87 | m_safeArray = safeArray;
88 |
89 | // Check that it's a 1-D array of the expected type...
90 | RETURN_HR_IF(E_INVALIDARG, ::SafeArrayGetDim(m_safeArray) != 1);
91 |
92 | VARTYPE actualType;
93 | RETURN_IF_FAILED(::SafeArrayGetVartype(m_safeArray, &actualType));
94 | if (actualType != vtExpected)
95 | {
96 | // Special case to deal with SafeArrays from managed code
97 | // Managed interop will bring in arrays of ints as VT_INT
98 | // This is functionally the same as VT_I4 for this code, so
99 | // allow them to pass as VT_I4.
100 | // Actually converting them to VT_I4 arrays would mean full
101 | // array copies, which would both make the code more complex
102 | // and less perfomant, making this short-circuit the best way
103 | // to allow them through.
104 | RETURN_HR_IF(E_INVALIDARG, !(actualType == VT_INT && vtExpected == VT_I4));
105 | }
106 |
107 | LONG lb;
108 | LONG ub;
109 | RETURN_IF_FAILED(::SafeArrayGetLBound(m_safeArray, 1, &lb));
110 | RETURN_IF_FAILED(::SafeArrayGetUBound(m_safeArray, 1, &ub));
111 | m_count = ub - lb + 1;
112 |
113 | RETURN_IF_FAILED(::SafeArrayAccessData(m_safeArray, reinterpret_cast(&m_data)));
114 | return S_OK;
115 | }
116 |
117 | UINT Count() const noexcept
118 | {
119 | return m_count;
120 | }
121 |
122 | const TElement& operator[](UINT i) const noexcept
123 | {
124 | return m_data[i];
125 | }
126 |
127 | TElement& operator[](UINT i) noexcept
128 | {
129 | return m_data[i];
130 | }
131 |
132 | operator TElement*() noexcept
133 | {
134 | return m_data;
135 | }
136 |
137 | TElement* Ptr() noexcept
138 | {
139 | return m_data;
140 | }
141 |
142 | private:
143 | SAFEARRAY* m_safeArray = nullptr;
144 | UINT m_count = 0;
145 | TElement* m_data = nullptr;
146 | };
147 |
148 | template
149 | inline
150 | HRESULT SafeArrayToArray(
151 | _In_ SAFEARRAY* safeArray,
152 | _Outptr_result_buffer_(*countOut) T** arrayOut,
153 | _Out_ int* countOut,
154 | VARTYPE vt) noexcept
155 | {
156 | SafeArrayAccessor accessor;
157 | RETURN_IF_FAILED(accessor.Access(safeArray, vt));
158 |
159 | std::unique_ptr arrayCopy(new (std::nothrow) T[accessor.Count()]);
160 | RETURN_IF_NULL_ALLOC(arrayCopy);
161 | for (UINT i = 0 ; i < accessor.Count() ; i++)
162 | {
163 | arrayCopy[i] = accessor[i];
164 | }
165 |
166 | *countOut = accessor.Count();
167 | *arrayOut = arrayCopy.release();
168 | return S_OK;
169 | }
170 |
171 | // Convert the given SAFEARRAY containing elements of the VARTYPE provided as the template
172 | // parameter to a vector of type T. The conversion from the underlying SAFEARRAY type to T
173 | // should be performed by `conversionFn`. If `conversionFn` returns a value that cannot be
174 | // implicitly converted to `T`, the compiler will reject the call.
175 | template
176 | inline
177 | std::vector SafeArrayToVector(_In_ SAFEARRAY* safeArray, Fn&& conversionFn)
178 | {
179 | std::vector result;
180 | using SafeArrayElementT = typename VarTypeHelper::Type;
181 |
182 | SafeArrayAccessor accessor;
183 | THROW_IF_FAILED(accessor.Access(safeArray, vt));
184 |
185 | for (UINT i = 0; i < accessor.Count(); ++i)
186 | {
187 | result.push_back(conversionFn(accessor[i]));
188 | }
189 |
190 | return result;
191 | }
192 |
193 | // A convenience overload that by default assumes that the output vector's type should be the same
194 | // as the original SAFEARRAY's element type. The elements are copied into the array
195 | // by using that type's copy ctor. If a different type parameter is provided, then the template
196 | // will compile as long as there exists an implicit conversion between the SAFEARRAY's underlying
197 | // type and `T`.
198 | template::Type>
199 | inline
200 | std::vector SafeArrayToVector(_In_ SAFEARRAY* safeArray)
201 | {
202 | return SafeArrayToVector(safeArray, [](auto& el) { return el; });
203 | }
204 |
205 | // The noexcept overload, where the type conversion is automatic.
206 | template
207 | inline
208 | HRESULT SafeArrayToVector(_In_ SAFEARRAY* safeArray, std::vector& arrayOut) noexcept try
209 | {
210 | arrayOut = SafeArrayToVector(safeArray);
211 | return S_OK;
212 | }
213 | CATCH_RETURN()
214 |
215 | // The noexcept overload, where the type conversion is performed by the given functor.
216 | template
217 | inline
218 | HRESULT SafeArrayToVector(_In_ SAFEARRAY* safeArray, Fn&& conversionFn, std::vector& arrayOut) noexcept try
219 | {
220 | arrayOut = SafeArrayToVector(safeArray, conversionFn);
221 | return S_OK;
222 | }
223 | CATCH_RETURN()
224 |
225 | template
226 | inline
227 | HRESULT ArrayToSafeArray(_In_ const T* originalArray, int count, VARTYPE vt, _Outptr_ SAFEARRAY** resultOut) noexcept try
228 | {
229 | *resultOut = nullptr;
230 | THROW_HR_IF(E_INVALIDARG, count < 0);
231 | unique_safearray safeArray(::SafeArrayCreateVector(vt, 0, static_cast(count)));
232 | THROW_IF_NULL_ALLOC(safeArray);
233 |
234 | {
235 | SafeArrayAccessor accessor(safeArray.get(), vt);
236 |
237 | for (unsigned int i = 0; i < static_cast(count); ++i)
238 | {
239 | accessor[i] = originalArray[i];
240 | }
241 | }
242 |
243 | *resultOut = safeArray.release();
244 | return S_OK;
245 | }
246 | CATCH_RETURN();
247 |
248 | // A type-safe conversion function for going from an array of `T` to a SAFEARRAY of the given VT.
249 | //
250 | // It uses the `VarTypeHelper` to map the given VT to an actual type. If there is no automatic
251 | // conversion possible between the array type and this type, compilation will fail, forcing the
252 | // user to reconcile the array type with the SAFEARRAY's VT.
253 | //
254 | // # Examples
255 | //
256 | // ## Successfully convert an int array to a VT_I4 SAFEARRAY.
257 | // ```
258 | // std::vector arr;
259 | // unique_safearray res;
260 | // RETURN_IF_FAILED(ArrayToSafeArray(arr.data(), static_cast(arr.size()), &res));
261 | // ```
262 | //
263 | // ## Conversion fails because there's no automatic type conversion between HWND and a VT_UI4.
264 | // ```
265 | // std::vector arr;
266 | // unique_safearray res;
267 | // // NOTE: Compile error! No conversion between HWND and unsigned int.
268 | // RETURN_IF_FAILED(ArrayToSafeArray(arr.data(), static_cast(arr.size()), &res));
269 | // ```
270 | template
271 | inline
272 | HRESULT ArrayToSafeArray(_In_ const T* originalArray, int count, _Outptr_ SAFEARRAY** resultOut) noexcept try
273 | {
274 | *resultOut = nullptr;
275 | *resultOut = ArrayToSafeArray(originalArray, count, [](const auto& el) { return el; }).release();
276 |
277 | return S_OK;
278 | }
279 | CATCH_RETURN();
280 |
281 | template
282 | inline
283 | unique_safearray ArrayToSafeArray(_In_ const T* originalArray, int count)
284 | {
285 | unique_safearray result;
286 | THROW_IF_FAILED(ArrayToSafeArray(originalArray, count, &result));
287 |
288 | return result;
289 | }
290 |
291 | // A type-safe conversion function for going from an array of `T` to a SAFEARRAY of the given VT.
292 | //
293 | // It uses the `VarTypeHelper` to map the given VT to an actual type. It uses the given conversion
294 | // function to convert the array element to the SAFEARRAY's type.
295 | //
296 | // This is provided as a convenience overload, so that callers don't have to construct temporary
297 | // arrays when they have mismatched array and target SAFEARRAY types.
298 | template
299 | inline
300 | unique_safearray ArrayToSafeArray(_In_ const T* originalArray, int count, Fn&& conversionFn)
301 | {
302 | THROW_HR_IF(E_INVALIDARG, count < 0);
303 | unique_safearray safeArray(::SafeArrayCreateVector(vt, 0, static_cast(count)));
304 | THROW_IF_NULL_ALLOC(safeArray);
305 |
306 | {
307 | // The array type is obtained by mapping the vt to the corresponding type. Note that this _could_ be a different
308 | // type than the array element type, in which case the compiler will try to use an appropriate conversion.
309 | // If none exists, the compilation will fail, making us find the correct safearray type.
310 | using SafeArrayElementT = typename VarTypeHelper::Type;
311 | SafeArrayAccessor accessor(safeArray.get(), vt);
312 |
313 | for (unsigned int i = 0; i < static_cast(count); ++i)
314 | {
315 | accessor[i] = conversionFn(originalArray[i]);
316 | }
317 | }
318 |
319 | return safeArray;
320 | }
321 |
322 | template
323 | inline
324 | HRESULT SafeArrayCompare(_In_ SAFEARRAY* array1, _In_ SAFEARRAY* array2, VARTYPE vt, _Out_ BOOL* same) noexcept try
325 | {
326 | *same = FALSE;
327 |
328 | SafeArrayAccessor a1(array1, vt);
329 | SafeArrayAccessor a2(array2, vt);
330 | if (a1.Count() != a2.Count())
331 | {
332 | return S_OK;
333 | }
334 |
335 | for (unsigned int i = 0; i < a1.Count(); ++i)
336 | {
337 | if (a1[i] != a2[i])
338 | {
339 | return S_OK;
340 | }
341 | }
342 |
343 | *same = TRUE;
344 | return S_OK;
345 | }
346 | CATCH_RETURN();
347 |
348 | HRESULT SafeArrayGetCount(_In_ SAFEARRAY* array, _Out_ long* size) noexcept;
349 |
350 | } // SafeArrayUtil
351 |
--------------------------------------------------------------------------------
/src/UIAutomation/UiaOperationAbstraction/UiaOperationAbstraction.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | Win32
8 |
9 |
10 | Release
11 | Win32
12 |
13 |
14 | Debug
15 | x64
16 |
17 |
18 | Release
19 | x64
20 |
21 |
22 |
23 | 16.0
24 | {A5682ADB-8C0C-4CFD-AED9-2E979751FDCC}
25 | Win32Proj
26 | UiaOperationAbstraction
27 | 10.0
28 |
29 |
30 |
31 | StaticLibrary
32 | true
33 | v142
34 | Unicode
35 |
36 |
37 | StaticLibrary
38 | false
39 | v142
40 | true
41 | Unicode
42 |
43 |
44 | StaticLibrary
45 | true
46 | v142
47 | Unicode
48 |
49 |
50 | StaticLibrary
51 | false
52 | v142
53 | true
54 | Unicode
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | false
76 |
77 |
78 | true
79 |
80 |
81 | true
82 |
83 |
84 | false
85 |
86 |
87 |
88 | Use
89 | Level4
90 | true
91 | true
92 | true
93 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
94 | false
95 | pch.h
96 | stdcpp17
97 |
98 |
99 | Windows
100 | true
101 | true
102 | true
103 |
104 |
105 | uiAutomationCore.lib
106 |
107 |
108 |
109 |
110 | Use
111 | Level4
112 | true
113 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
114 | false
115 | pch.h
116 | stdcpp17
117 |
118 |
119 | Windows
120 | true
121 |
122 |
123 | uiAutomationCore.lib
124 |
125 |
126 |
127 |
128 | Use
129 | Level4
130 | true
131 | _DEBUG;_LIB;%(PreprocessorDefinitions)
132 | false
133 | pch.h
134 | stdcpp17
135 |
136 |
137 | Windows
138 | true
139 |
140 |
141 | uiAutomationCore.lib
142 |
143 |
144 |
145 |
146 | Use
147 | Level4
148 | true
149 | true
150 | true
151 | NDEBUG;_LIB;%(PreprocessorDefinitions)
152 | false
153 | pch.h
154 | stdcpp17
155 |
156 |
157 | Windows
158 | true
159 | true
160 | true
161 |
162 |
163 | uiAutomationCore.lib
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 | Create
176 | Create
177 | Create
178 | Create
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 | $(OutDir)winmd\Microsoft.UI.UIAutomation.winmd
189 | true
190 |
191 |
192 | $(FrameworkSdkDir)UnionMetadata\$(TargetPlatformVersion)\Windows.winmd
193 | true
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
204 |
205 |
206 |
207 |
208 |
209 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/RemoteOperationInstructionEnumValues.g.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #pragma once
6 |
7 | GetInvokePattern = MakePatternGetterInstructionType(UIA_InvokePatternId),
8 | GetSelectionPattern = MakePatternGetterInstructionType(UIA_SelectionPatternId),
9 | GetValuePattern = MakePatternGetterInstructionType(UIA_ValuePatternId),
10 | GetRangeValuePattern = MakePatternGetterInstructionType(UIA_RangeValuePatternId),
11 | GetScrollPattern = MakePatternGetterInstructionType(UIA_ScrollPatternId),
12 | GetExpandCollapsePattern = MakePatternGetterInstructionType(UIA_ExpandCollapsePatternId),
13 | GetGridPattern = MakePatternGetterInstructionType(UIA_GridPatternId),
14 | GetGridItemPattern = MakePatternGetterInstructionType(UIA_GridItemPatternId),
15 | GetMultipleViewPattern = MakePatternGetterInstructionType(UIA_MultipleViewPatternId),
16 | GetWindowPattern = MakePatternGetterInstructionType(UIA_WindowPatternId),
17 | GetSelectionItemPattern = MakePatternGetterInstructionType(UIA_SelectionItemPatternId),
18 | GetDockPattern = MakePatternGetterInstructionType(UIA_DockPatternId),
19 | GetTablePattern = MakePatternGetterInstructionType(UIA_TablePatternId),
20 | GetTableItemPattern = MakePatternGetterInstructionType(UIA_TableItemPatternId),
21 | GetTextPattern = MakePatternGetterInstructionType(UIA_TextPatternId),
22 | GetTogglePattern = MakePatternGetterInstructionType(UIA_TogglePatternId),
23 | GetTransformPattern = MakePatternGetterInstructionType(UIA_TransformPatternId),
24 | GetScrollItemPattern = MakePatternGetterInstructionType(UIA_ScrollItemPatternId),
25 | GetLegacyIAccessiblePattern = MakePatternGetterInstructionType(UIA_LegacyIAccessiblePatternId),
26 | GetItemContainerPattern = MakePatternGetterInstructionType(UIA_ItemContainerPatternId),
27 | GetVirtualizedItemPattern = MakePatternGetterInstructionType(UIA_VirtualizedItemPatternId),
28 | GetSynchronizedInputPattern = MakePatternGetterInstructionType(UIA_SynchronizedInputPatternId),
29 | GetAnnotationPattern = MakePatternGetterInstructionType(UIA_AnnotationPatternId),
30 | GetTextPattern2 = MakePatternGetterInstructionType(UIA_TextPattern2Id),
31 | GetStylesPattern = MakePatternGetterInstructionType(UIA_StylesPatternId),
32 | GetSpreadsheetPattern = MakePatternGetterInstructionType(UIA_SpreadsheetPatternId),
33 | GetSpreadsheetItemPattern = MakePatternGetterInstructionType(UIA_SpreadsheetItemPatternId),
34 | GetTransformPattern2 = MakePatternGetterInstructionType(UIA_TransformPattern2Id),
35 | GetTextChildPattern = MakePatternGetterInstructionType(UIA_TextChildPatternId),
36 | GetDragPattern = MakePatternGetterInstructionType(UIA_DragPatternId),
37 | GetDropTargetPattern = MakePatternGetterInstructionType(UIA_DropTargetPatternId),
38 | GetTextEditPattern = MakePatternGetterInstructionType(UIA_TextEditPatternId),
39 | GetCustomNavigationPattern = MakePatternGetterInstructionType(UIA_CustomNavigationPatternId),
40 | GetSelectionPattern2 = MakePatternGetterInstructionType(UIA_SelectionPattern2Id),
41 | InvokePatternInvoke = MakePatternMethodInstructionType(
42 | UIA_InvokePatternId,
43 | 3 /* clientVtableIndex */),
44 | ValuePatternSetValue = MakePatternMethodInstructionType(
45 | UIA_ValuePatternId,
46 | 3 /* clientVtableIndex */),
47 | RangeValuePatternSetValue = MakePatternMethodInstructionType(
48 | UIA_RangeValuePatternId,
49 | 3 /* clientVtableIndex */),
50 | ScrollPatternScroll = MakePatternMethodInstructionType(
51 | UIA_ScrollPatternId,
52 | 3 /* clientVtableIndex */),
53 | ScrollPatternSetScrollPercent = MakePatternMethodInstructionType(
54 | UIA_ScrollPatternId,
55 | 4 /* clientVtableIndex */),
56 | ExpandCollapsePatternExpand = MakePatternMethodInstructionType(
57 | UIA_ExpandCollapsePatternId,
58 | 3 /* clientVtableIndex */),
59 | ExpandCollapsePatternCollapse = MakePatternMethodInstructionType(
60 | UIA_ExpandCollapsePatternId,
61 | 4 /* clientVtableIndex */),
62 | GridPatternGetItem = MakePatternMethodInstructionType(
63 | UIA_GridPatternId,
64 | 3 /* clientVtableIndex */),
65 | MultipleViewPatternGetViewName = MakePatternMethodInstructionType(
66 | UIA_MultipleViewPatternId,
67 | 3 /* clientVtableIndex */),
68 | MultipleViewPatternSetCurrentView = MakePatternMethodInstructionType(
69 | UIA_MultipleViewPatternId,
70 | 4 /* clientVtableIndex */),
71 | WindowPatternClose = MakePatternMethodInstructionType(
72 | UIA_WindowPatternId,
73 | 3 /* clientVtableIndex */),
74 | WindowPatternWaitForInputIdle = MakePatternMethodInstructionType(
75 | UIA_WindowPatternId,
76 | 4 /* clientVtableIndex */),
77 | WindowPatternSetWindowVisualState = MakePatternMethodInstructionType(
78 | UIA_WindowPatternId,
79 | 5 /* clientVtableIndex */),
80 | SelectionItemPatternSelect = MakePatternMethodInstructionType(
81 | UIA_SelectionItemPatternId,
82 | 3 /* clientVtableIndex */),
83 | SelectionItemPatternAddToSelection = MakePatternMethodInstructionType(
84 | UIA_SelectionItemPatternId,
85 | 4 /* clientVtableIndex */),
86 | SelectionItemPatternRemoveFromSelection = MakePatternMethodInstructionType(
87 | UIA_SelectionItemPatternId,
88 | 5 /* clientVtableIndex */),
89 | DockPatternSetDockPosition = MakePatternMethodInstructionType(
90 | UIA_DockPatternId,
91 | 3 /* clientVtableIndex */),
92 | TextPatternRangeFromPoint = MakePatternMethodInstructionType(
93 | UIA_TextPatternId,
94 | 3 /* clientVtableIndex */),
95 | TextPatternRangeFromChild = MakePatternMethodInstructionType(
96 | UIA_TextPatternId,
97 | 4 /* clientVtableIndex */),
98 | TextPatternGetSelection = MakePatternMethodInstructionType(
99 | UIA_TextPatternId,
100 | 5 /* clientVtableIndex */),
101 | TextPatternGetVisibleRanges = MakePatternMethodInstructionType(
102 | UIA_TextPatternId,
103 | 6 /* clientVtableIndex */),
104 | TextPatternGetDocumentRange = MakePatternMethodInstructionType(
105 | UIA_TextPatternId,
106 | 7 /* clientVtableIndex */),
107 | TextPatternGetSupportedTextSelection = MakePatternMethodInstructionType(
108 | UIA_TextPatternId,
109 | 8 /* clientVtableIndex */),
110 | TextRangeClone = MakePatternRelatedObjectMethodInstructionType(
111 | UIA_TextPatternId,
112 | 1 /* relatedObjectNumber */,
113 | 3 /* clientVtableIndex */),
114 | TextRangeCompare = MakePatternRelatedObjectMethodInstructionType(
115 | UIA_TextPatternId,
116 | 1 /* relatedObjectNumber */,
117 | 4 /* clientVtableIndex */),
118 | TextRangeCompareEndpoints = MakePatternRelatedObjectMethodInstructionType(
119 | UIA_TextPatternId,
120 | 1 /* relatedObjectNumber */,
121 | 5 /* clientVtableIndex */),
122 | TextRangeExpandToEnclosingUnit = MakePatternRelatedObjectMethodInstructionType(
123 | UIA_TextPatternId,
124 | 1 /* relatedObjectNumber */,
125 | 6 /* clientVtableIndex */),
126 | TextRangeFindAttribute = MakePatternRelatedObjectMethodInstructionType(
127 | UIA_TextPatternId,
128 | 1 /* relatedObjectNumber */,
129 | 7 /* clientVtableIndex */),
130 | TextRangeFindText = MakePatternRelatedObjectMethodInstructionType(
131 | UIA_TextPatternId,
132 | 1 /* relatedObjectNumber */,
133 | 8 /* clientVtableIndex */),
134 | TextRangeGetAttributeValue = MakePatternRelatedObjectMethodInstructionType(
135 | UIA_TextPatternId,
136 | 1 /* relatedObjectNumber */,
137 | 9 /* clientVtableIndex */),
138 | TextRangeGetBoundingRectangles = MakePatternRelatedObjectMethodInstructionType(
139 | UIA_TextPatternId,
140 | 1 /* relatedObjectNumber */,
141 | 10 /* clientVtableIndex */),
142 | TextRangeGetEnclosingElement = MakePatternRelatedObjectMethodInstructionType(
143 | UIA_TextPatternId,
144 | 1 /* relatedObjectNumber */,
145 | 11 /* clientVtableIndex */),
146 | TextRangeGetText = MakePatternRelatedObjectMethodInstructionType(
147 | UIA_TextPatternId,
148 | 1 /* relatedObjectNumber */,
149 | 12 /* clientVtableIndex */),
150 | TextRangeMove = MakePatternRelatedObjectMethodInstructionType(
151 | UIA_TextPatternId,
152 | 1 /* relatedObjectNumber */,
153 | 13 /* clientVtableIndex */),
154 | TextRangeMoveEndpointByUnit = MakePatternRelatedObjectMethodInstructionType(
155 | UIA_TextPatternId,
156 | 1 /* relatedObjectNumber */,
157 | 14 /* clientVtableIndex */),
158 | TextRangeMoveEndpointByRange = MakePatternRelatedObjectMethodInstructionType(
159 | UIA_TextPatternId,
160 | 1 /* relatedObjectNumber */,
161 | 15 /* clientVtableIndex */),
162 | TextRangeSelect = MakePatternRelatedObjectMethodInstructionType(
163 | UIA_TextPatternId,
164 | 1 /* relatedObjectNumber */,
165 | 16 /* clientVtableIndex */),
166 | TextRangeAddToSelection = MakePatternRelatedObjectMethodInstructionType(
167 | UIA_TextPatternId,
168 | 1 /* relatedObjectNumber */,
169 | 17 /* clientVtableIndex */),
170 | TextRangeRemoveFromSelection = MakePatternRelatedObjectMethodInstructionType(
171 | UIA_TextPatternId,
172 | 1 /* relatedObjectNumber */,
173 | 18 /* clientVtableIndex */),
174 | TextRangeScrollIntoView = MakePatternRelatedObjectMethodInstructionType(
175 | UIA_TextPatternId,
176 | 1 /* relatedObjectNumber */,
177 | 19 /* clientVtableIndex */),
178 | TextRangeGetChildren = MakePatternRelatedObjectMethodInstructionType(
179 | UIA_TextPatternId,
180 | 1 /* relatedObjectNumber */,
181 | 20 /* clientVtableIndex */),
182 | TextRangeShowContextMenu = MakePatternRelatedObjectMethodInstructionType(
183 | UIA_TextPatternId,
184 | 1 /* relatedObjectNumber */,
185 | 21 /* clientVtableIndex */),
186 | TogglePatternToggle = MakePatternMethodInstructionType(
187 | UIA_TogglePatternId,
188 | 3 /* clientVtableIndex */),
189 | TransformPatternMove = MakePatternMethodInstructionType(
190 | UIA_TransformPatternId,
191 | 3 /* clientVtableIndex */),
192 | TransformPatternResize = MakePatternMethodInstructionType(
193 | UIA_TransformPatternId,
194 | 4 /* clientVtableIndex */),
195 | TransformPatternRotate = MakePatternMethodInstructionType(
196 | UIA_TransformPatternId,
197 | 5 /* clientVtableIndex */),
198 | ScrollItemPatternScrollIntoView = MakePatternMethodInstructionType(
199 | UIA_ScrollItemPatternId,
200 | 3 /* clientVtableIndex */),
201 | LegacyIAccessiblePatternSelect = MakePatternMethodInstructionType(
202 | UIA_LegacyIAccessiblePatternId,
203 | 3 /* clientVtableIndex */),
204 | LegacyIAccessiblePatternDoDefaultAction = MakePatternMethodInstructionType(
205 | UIA_LegacyIAccessiblePatternId,
206 | 4 /* clientVtableIndex */),
207 | LegacyIAccessiblePatternSetValue = MakePatternMethodInstructionType(
208 | UIA_LegacyIAccessiblePatternId,
209 | 5 /* clientVtableIndex */),
210 | ItemContainerPatternFindItemByProperty = MakePatternMethodInstructionType(
211 | UIA_ItemContainerPatternId,
212 | 3 /* clientVtableIndex */),
213 | VirtualizedItemPatternRealize = MakePatternMethodInstructionType(
214 | UIA_VirtualizedItemPatternId,
215 | 3 /* clientVtableIndex */),
216 | SynchronizedInputPatternStartListening = MakePatternMethodInstructionType(
217 | UIA_SynchronizedInputPatternId,
218 | 3 /* clientVtableIndex */),
219 | SynchronizedInputPatternCancel = MakePatternMethodInstructionType(
220 | UIA_SynchronizedInputPatternId,
221 | 4 /* clientVtableIndex */),
222 | TextPattern2RangeFromAnnotation = MakePatternMethodInstructionType(
223 | UIA_TextPattern2Id,
224 | 9 /* clientVtableIndex */),
225 | TextPattern2GetCaretRange = MakePatternMethodInstructionType(
226 | UIA_TextPattern2Id,
227 | 10 /* clientVtableIndex */),
228 | SpreadsheetPatternGetItemByName = MakePatternMethodInstructionType(
229 | UIA_SpreadsheetPatternId,
230 | 3 /* clientVtableIndex */),
231 | TransformPattern2Zoom = MakePatternMethodInstructionType(
232 | UIA_TransformPattern2Id,
233 | 12 /* clientVtableIndex */),
234 | TransformPattern2ZoomByUnit = MakePatternMethodInstructionType(
235 | UIA_TransformPattern2Id,
236 | 13 /* clientVtableIndex */),
237 | TextChildPatternGetTextContainer = MakePatternMethodInstructionType(
238 | UIA_TextChildPatternId,
239 | 3 /* clientVtableIndex */),
240 | TextChildPatternGetTextRange = MakePatternMethodInstructionType(
241 | UIA_TextChildPatternId,
242 | 4 /* clientVtableIndex */),
243 | TextEditPatternGetActiveComposition = MakePatternMethodInstructionType(
244 | UIA_TextEditPatternId,
245 | 9 /* clientVtableIndex */),
246 | TextEditPatternGetConversionTarget = MakePatternMethodInstructionType(
247 | UIA_TextEditPatternId,
248 | 10 /* clientVtableIndex */),
249 | CustomNavigationPatternNavigate = MakePatternMethodInstructionType(
250 | UIA_CustomNavigationPatternId,
251 | 3 /* clientVtableIndex */),
252 |
--------------------------------------------------------------------------------
/src/UIAutomation/FunctionalTests/FunctionalTests.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | Win32
8 |
9 |
10 | Release
11 | Win32
12 |
13 |
14 | Debug
15 | x64
16 |
17 |
18 | Release
19 | x64
20 |
21 |
22 |
23 | 16.0
24 | {ADC03671-2DB4-4130-BC73-B78314046BFB}
25 | Win32Proj
26 | FunctionalTests
27 | 10.0
28 | NativeUnitTestProject
29 |
30 |
31 |
32 | DynamicLibrary
33 | true
34 | v142
35 | Unicode
36 | false
37 |
38 |
39 | DynamicLibrary
40 | false
41 | v142
42 | true
43 | Unicode
44 | false
45 |
46 |
47 | DynamicLibrary
48 | true
49 | v142
50 | Unicode
51 | false
52 |
53 |
54 | DynamicLibrary
55 | false
56 | v142
57 | true
58 | Unicode
59 | false
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | true
81 |
82 |
83 | true
84 |
85 |
86 | false
87 |
88 |
89 | false
90 |
91 |
92 |
93 | Use
94 | Level4
95 | true
96 | $(VCInstallDir)UnitTest\include;$(SolutionDir)UiaOperationAbstraction;%(AdditionalIncludeDirectories)
97 | WIN32;_DEBUG;%(PreprocessorDefinitions)
98 | true
99 | pch.h
100 | stdcpp17
101 | false
102 | /bigobj /await /D WIN32_LEAN_AND_MEAN /D NOMINMAX %(AdditionalOptions)
103 |
104 |
105 | Windows
106 | $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)
107 |
108 |
109 |
110 |
111 | Use
112 | Level4
113 | true
114 | $(VCInstallDir)UnitTest\include;$(SolutionDir)UiaOperationAbstraction;%(AdditionalIncludeDirectories)
115 | _DEBUG;%(PreprocessorDefinitions)
116 | true
117 | pch.h
118 | stdcpp17
119 | false
120 | /bigobj /await /D WIN32_LEAN_AND_MEAN /D NOMINMAX %(AdditionalOptions)
121 |
122 |
123 | Windows
124 | $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)
125 |
126 |
127 |
128 |
129 | Use
130 | Level4
131 | true
132 | true
133 | true
134 | $(VCInstallDir)UnitTest\include;$(SolutionDir)UiaOperationAbstraction;%(AdditionalIncludeDirectories)
135 | WIN32;NDEBUG;%(PreprocessorDefinitions)
136 | true
137 | pch.h
138 | stdcpp17
139 | false
140 | /bigobj /await /D WIN32_LEAN_AND_MEAN /D NOMINMAX %(AdditionalOptions)
141 |
142 |
143 | Windows
144 | true
145 | true
146 | $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)
147 |
148 |
149 |
150 |
151 | Use
152 | Level4
153 | true
154 | true
155 | true
156 | $(VCInstallDir)UnitTest\include;$(SolutionDir)UiaOperationAbstraction;%(AdditionalIncludeDirectories)
157 | NDEBUG;%(PreprocessorDefinitions)
158 | true
159 | pch.h
160 | stdcpp17
161 | false
162 | /bigobj /await /D WIN32_LEAN_AND_MEAN /D NOMINMAX %(AdditionalOptions)
163 |
164 |
165 | Windows
166 | true
167 | true
168 | $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 | Create
177 | Create
178 | Create
179 | Create
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 | $(OutDir)winmd\Microsoft.UI.UIAutomation.winmd
193 | true
194 |
195 |
196 | $(FrameworkSdkDir)UnionMetadata\$(TargetPlatformVersion)\Windows.winmd
197 | true
198 |
199 |
200 |
201 |
202 | {a5682adb-8c0c-4cfd-aed9-2e979751fdcc}
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
213 |
214 |
215 |
216 |
217 |
218 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/RemoteOperationInstructionSerialization.g.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #include "pch.h"
6 | #include "RemoteOperationInstructionSerialization.h"
7 |
8 | using namespace bytecode;
9 |
10 | void RemoteOperationInstructionSerializer::Write(const InvokePatternInvoke& instruction)
11 | {
12 | Write(instruction.targetId);
13 | }
14 |
15 | void RemoteOperationInstructionSerializer::Write(const ValuePatternSetValue& instruction)
16 | {
17 | Write(instruction.targetId);
18 | Write(instruction.valId);
19 | }
20 |
21 | void RemoteOperationInstructionSerializer::Write(const RangeValuePatternSetValue& instruction)
22 | {
23 | Write(instruction.targetId);
24 | Write(instruction.valId);
25 | }
26 |
27 | void RemoteOperationInstructionSerializer::Write(const ScrollPatternScroll& instruction)
28 | {
29 | Write(instruction.targetId);
30 | Write(instruction.horizontalAmountId);
31 | Write(instruction.verticalAmountId);
32 | }
33 |
34 | void RemoteOperationInstructionSerializer::Write(const ScrollPatternSetScrollPercent& instruction)
35 | {
36 | Write(instruction.targetId);
37 | Write(instruction.horizontalPercentId);
38 | Write(instruction.verticalPercentId);
39 | }
40 |
41 | void RemoteOperationInstructionSerializer::Write(const ExpandCollapsePatternExpand& instruction)
42 | {
43 | Write(instruction.targetId);
44 | }
45 |
46 | void RemoteOperationInstructionSerializer::Write(const ExpandCollapsePatternCollapse& instruction)
47 | {
48 | Write(instruction.targetId);
49 | }
50 |
51 | void RemoteOperationInstructionSerializer::Write(const GridPatternGetItem& instruction)
52 | {
53 | Write(instruction.resultId);
54 | Write(instruction.targetId);
55 | Write(instruction.rowId);
56 | Write(instruction.columnId);
57 | }
58 |
59 | void RemoteOperationInstructionSerializer::Write(const MultipleViewPatternGetViewName& instruction)
60 | {
61 | Write(instruction.resultId);
62 | Write(instruction.targetId);
63 | Write(instruction.viewId);
64 | }
65 |
66 | void RemoteOperationInstructionSerializer::Write(const MultipleViewPatternSetCurrentView& instruction)
67 | {
68 | Write(instruction.targetId);
69 | Write(instruction.viewId);
70 | }
71 |
72 | void RemoteOperationInstructionSerializer::Write(const WindowPatternClose& instruction)
73 | {
74 | Write(instruction.targetId);
75 | }
76 |
77 | void RemoteOperationInstructionSerializer::Write(const WindowPatternWaitForInputIdle& instruction)
78 | {
79 | Write(instruction.resultId);
80 | Write(instruction.targetId);
81 | Write(instruction.millisecondsId);
82 | }
83 |
84 | void RemoteOperationInstructionSerializer::Write(const WindowPatternSetWindowVisualState& instruction)
85 | {
86 | Write(instruction.targetId);
87 | Write(instruction.stateId);
88 | }
89 |
90 | void RemoteOperationInstructionSerializer::Write(const SelectionItemPatternSelect& instruction)
91 | {
92 | Write(instruction.targetId);
93 | }
94 |
95 | void RemoteOperationInstructionSerializer::Write(const SelectionItemPatternAddToSelection& instruction)
96 | {
97 | Write(instruction.targetId);
98 | }
99 |
100 | void RemoteOperationInstructionSerializer::Write(const SelectionItemPatternRemoveFromSelection& instruction)
101 | {
102 | Write(instruction.targetId);
103 | }
104 |
105 | void RemoteOperationInstructionSerializer::Write(const DockPatternSetDockPosition& instruction)
106 | {
107 | Write(instruction.targetId);
108 | Write(instruction.dockPosId);
109 | }
110 |
111 | void RemoteOperationInstructionSerializer::Write(const TextPatternRangeFromPoint& instruction)
112 | {
113 | Write(instruction.resultId);
114 | Write(instruction.targetId);
115 | Write(instruction.ptId);
116 | }
117 |
118 | void RemoteOperationInstructionSerializer::Write(const TextPatternRangeFromChild& instruction)
119 | {
120 | Write(instruction.resultId);
121 | Write(instruction.targetId);
122 | Write(instruction.childId);
123 | }
124 |
125 | void RemoteOperationInstructionSerializer::Write(const TextPatternGetSelection& instruction)
126 | {
127 | Write(instruction.resultId);
128 | Write(instruction.targetId);
129 | }
130 |
131 | void RemoteOperationInstructionSerializer::Write(const TextPatternGetVisibleRanges& instruction)
132 | {
133 | Write(instruction.resultId);
134 | Write(instruction.targetId);
135 | }
136 |
137 | void RemoteOperationInstructionSerializer::Write(const TextPatternGetDocumentRange& instruction)
138 | {
139 | Write(instruction.resultId);
140 | Write(instruction.targetId);
141 | }
142 |
143 | void RemoteOperationInstructionSerializer::Write(const TextPatternGetSupportedTextSelection& instruction)
144 | {
145 | Write(instruction.resultId);
146 | Write(instruction.targetId);
147 | }
148 |
149 | void RemoteOperationInstructionSerializer::Write(const TextRangeClone& instruction)
150 | {
151 | Write(instruction.resultId);
152 | Write(instruction.targetId);
153 | }
154 |
155 | void RemoteOperationInstructionSerializer::Write(const TextRangeCompare& instruction)
156 | {
157 | Write(instruction.resultId);
158 | Write(instruction.targetId);
159 | Write(instruction.rangeId);
160 | }
161 |
162 | void RemoteOperationInstructionSerializer::Write(const TextRangeCompareEndpoints& instruction)
163 | {
164 | Write(instruction.resultId);
165 | Write(instruction.targetId);
166 | Write(instruction.srcEndPointId);
167 | Write(instruction.rangeId);
168 | Write(instruction.targetEndPointId);
169 | }
170 |
171 | void RemoteOperationInstructionSerializer::Write(const TextRangeExpandToEnclosingUnit& instruction)
172 | {
173 | Write(instruction.targetId);
174 | Write(instruction.TextUnitId);
175 | }
176 |
177 | void RemoteOperationInstructionSerializer::Write(const TextRangeFindAttribute& instruction)
178 | {
179 | Write(instruction.resultId);
180 | Write(instruction.targetId);
181 | Write(instruction.attrId);
182 | Write(instruction.valId);
183 | Write(instruction.backwardId);
184 | }
185 |
186 | void RemoteOperationInstructionSerializer::Write(const TextRangeFindText& instruction)
187 | {
188 | Write(instruction.resultId);
189 | Write(instruction.targetId);
190 | Write(instruction.textId);
191 | Write(instruction.backwardId);
192 | Write(instruction.ignoreCaseId);
193 | }
194 |
195 | void RemoteOperationInstructionSerializer::Write(const TextRangeGetAttributeValue& instruction)
196 | {
197 | Write(instruction.resultId);
198 | Write(instruction.targetId);
199 | Write(instruction.attrId);
200 | }
201 |
202 | void RemoteOperationInstructionSerializer::Write(const TextRangeGetBoundingRectangles& instruction)
203 | {
204 | Write(instruction.resultId);
205 | Write(instruction.targetId);
206 | }
207 |
208 | void RemoteOperationInstructionSerializer::Write(const TextRangeGetEnclosingElement& instruction)
209 | {
210 | Write(instruction.resultId);
211 | Write(instruction.targetId);
212 | }
213 |
214 | void RemoteOperationInstructionSerializer::Write(const TextRangeGetText& instruction)
215 | {
216 | Write(instruction.resultId);
217 | Write(instruction.targetId);
218 | Write(instruction.maxLengthId);
219 | }
220 |
221 | void RemoteOperationInstructionSerializer::Write(const TextRangeMove& instruction)
222 | {
223 | Write(instruction.resultId);
224 | Write(instruction.targetId);
225 | Write(instruction.unitId);
226 | Write(instruction.countId);
227 | }
228 |
229 | void RemoteOperationInstructionSerializer::Write(const TextRangeMoveEndpointByUnit& instruction)
230 | {
231 | Write(instruction.resultId);
232 | Write(instruction.targetId);
233 | Write(instruction.endpointId);
234 | Write(instruction.unitId);
235 | Write(instruction.countId);
236 | }
237 |
238 | void RemoteOperationInstructionSerializer::Write(const TextRangeMoveEndpointByRange& instruction)
239 | {
240 | Write(instruction.targetId);
241 | Write(instruction.srcEndPointId);
242 | Write(instruction.rangeId);
243 | Write(instruction.targetEndPointId);
244 | }
245 |
246 | void RemoteOperationInstructionSerializer::Write(const TextRangeSelect& instruction)
247 | {
248 | Write(instruction.targetId);
249 | }
250 |
251 | void RemoteOperationInstructionSerializer::Write(const TextRangeAddToSelection& instruction)
252 | {
253 | Write(instruction.targetId);
254 | }
255 |
256 | void RemoteOperationInstructionSerializer::Write(const TextRangeRemoveFromSelection& instruction)
257 | {
258 | Write(instruction.targetId);
259 | }
260 |
261 | void RemoteOperationInstructionSerializer::Write(const TextRangeScrollIntoView& instruction)
262 | {
263 | Write(instruction.targetId);
264 | Write(instruction.alignToTopId);
265 | }
266 |
267 | void RemoteOperationInstructionSerializer::Write(const TextRangeGetChildren& instruction)
268 | {
269 | Write(instruction.resultId);
270 | Write(instruction.targetId);
271 | }
272 |
273 | void RemoteOperationInstructionSerializer::Write(const TextRangeShowContextMenu& instruction)
274 | {
275 | Write(instruction.targetId);
276 | }
277 |
278 | void RemoteOperationInstructionSerializer::Write(const TogglePatternToggle& instruction)
279 | {
280 | Write(instruction.targetId);
281 | }
282 |
283 | void RemoteOperationInstructionSerializer::Write(const TransformPatternMove& instruction)
284 | {
285 | Write(instruction.targetId);
286 | Write(instruction.xId);
287 | Write(instruction.yId);
288 | }
289 |
290 | void RemoteOperationInstructionSerializer::Write(const TransformPatternResize& instruction)
291 | {
292 | Write(instruction.targetId);
293 | Write(instruction.widthId);
294 | Write(instruction.heightId);
295 | }
296 |
297 | void RemoteOperationInstructionSerializer::Write(const TransformPatternRotate& instruction)
298 | {
299 | Write(instruction.targetId);
300 | Write(instruction.degreesId);
301 | }
302 |
303 | void RemoteOperationInstructionSerializer::Write(const ScrollItemPatternScrollIntoView& instruction)
304 | {
305 | Write(instruction.targetId);
306 | }
307 |
308 | void RemoteOperationInstructionSerializer::Write(const LegacyIAccessiblePatternSelect& instruction)
309 | {
310 | Write(instruction.targetId);
311 | Write(instruction.flagsSelectId);
312 | }
313 |
314 | void RemoteOperationInstructionSerializer::Write(const LegacyIAccessiblePatternDoDefaultAction& instruction)
315 | {
316 | Write(instruction.targetId);
317 | }
318 |
319 | void RemoteOperationInstructionSerializer::Write(const LegacyIAccessiblePatternSetValue& instruction)
320 | {
321 | Write(instruction.targetId);
322 | Write(instruction.szValueId);
323 | }
324 |
325 | void RemoteOperationInstructionSerializer::Write(const ItemContainerPatternFindItemByProperty& instruction)
326 | {
327 | Write(instruction.resultId);
328 | Write(instruction.targetId);
329 | Write(instruction.pStartAfterId);
330 | Write(instruction.propertyIdId);
331 | Write(instruction.valueId);
332 | }
333 |
334 | void RemoteOperationInstructionSerializer::Write(const VirtualizedItemPatternRealize& instruction)
335 | {
336 | Write(instruction.targetId);
337 | }
338 |
339 | void RemoteOperationInstructionSerializer::Write(const SynchronizedInputPatternStartListening& instruction)
340 | {
341 | Write(instruction.targetId);
342 | Write(instruction.inputTypeId);
343 | }
344 |
345 | void RemoteOperationInstructionSerializer::Write(const SynchronizedInputPatternCancel& instruction)
346 | {
347 | Write(instruction.targetId);
348 | }
349 |
350 | void RemoteOperationInstructionSerializer::Write(const TextPattern2RangeFromAnnotation& instruction)
351 | {
352 | Write(instruction.resultId);
353 | Write(instruction.targetId);
354 | Write(instruction.annotationId);
355 | }
356 |
357 | void RemoteOperationInstructionSerializer::Write(const TextPattern2GetCaretRange& instruction)
358 | {
359 | Write(instruction.resultId);
360 | Write(instruction.targetId);
361 | Write(instruction.isActiveId);
362 | }
363 |
364 | void RemoteOperationInstructionSerializer::Write(const SpreadsheetPatternGetItemByName& instruction)
365 | {
366 | Write(instruction.resultId);
367 | Write(instruction.targetId);
368 | Write(instruction.nameId);
369 | }
370 |
371 | void RemoteOperationInstructionSerializer::Write(const TransformPattern2Zoom& instruction)
372 | {
373 | Write(instruction.targetId);
374 | Write(instruction.zoomValueId);
375 | }
376 |
377 | void RemoteOperationInstructionSerializer::Write(const TransformPattern2ZoomByUnit& instruction)
378 | {
379 | Write(instruction.targetId);
380 | Write(instruction.ZoomUnitId);
381 | }
382 |
383 | void RemoteOperationInstructionSerializer::Write(const TextChildPatternGetTextContainer& instruction)
384 | {
385 | Write(instruction.resultId);
386 | Write(instruction.targetId);
387 | }
388 |
389 | void RemoteOperationInstructionSerializer::Write(const TextChildPatternGetTextRange& instruction)
390 | {
391 | Write(instruction.resultId);
392 | Write(instruction.targetId);
393 | }
394 |
395 | void RemoteOperationInstructionSerializer::Write(const TextEditPatternGetActiveComposition& instruction)
396 | {
397 | Write(instruction.resultId);
398 | Write(instruction.targetId);
399 | }
400 |
401 | void RemoteOperationInstructionSerializer::Write(const TextEditPatternGetConversionTarget& instruction)
402 | {
403 | Write(instruction.resultId);
404 | Write(instruction.targetId);
405 | }
406 |
407 | void RemoteOperationInstructionSerializer::Write(const CustomNavigationPatternNavigate& instruction)
408 | {
409 | Write(instruction.resultId);
410 | Write(instruction.targetId);
411 | Write(instruction.directionId);
412 | }
413 |
414 |
--------------------------------------------------------------------------------
/src/UIAutomation/Microsoft.UI.UIAutomation/AutomationRemoteOperation.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #include "pch.h"
5 | #include "AutomationRemoteOperation.h"
6 | #include "AutomationRemoteOperation.g.cpp"
7 | #include "Standins.h"
8 |
9 | #include
10 |
11 | namespace winrt
12 | {
13 | using namespace winrt::Microsoft::UI::UIAutomation;
14 | using namespace winrt::Windows::UI::UIAutomation;
15 | }
16 |
17 | namespace winrt::Microsoft::UI::UIAutomation::implementation
18 | {
19 | AutomationRemoteOperation::AutomationRemoteOperation()
20 | {
21 | m_currentScope = m_rootGraph;
22 | }
23 |
24 | void AutomationRemoteOperation::InsertInstruction(const bytecode::Instruction& instruction)
25 | {
26 | m_currentScope->AddInstruction(instruction);
27 | }
28 |
29 | bytecode::OperandId AutomationRemoteOperation::GetNextId()
30 | {
31 | if (m_nextId == std::numeric_limits::max())
32 | {
33 | throw_hresult(E_UNEXPECTED);
34 | }
35 |
36 | return bytecode::OperandId{ m_nextId++ };
37 | }
38 |
39 | winrt::AutomationRemoteBool AutomationRemoteOperation::NewBool(bool initialValue)
40 | {
41 | const auto newId = GetNextId();
42 | InsertInstruction(bytecode::NewBool{ newId, initialValue });
43 |
44 | return make(newId, *this);
45 | }
46 |
47 | winrt::AutomationRemoteInt AutomationRemoteOperation::NewInt(int32_t initialValue)
48 | {
49 | const auto newId = GetNextId();
50 | InsertInstruction(bytecode::NewInt{ newId, initialValue });
51 |
52 | return make(newId, *this);
53 | }
54 |
55 | winrt::AutomationRemoteUint AutomationRemoteOperation::NewUint(uint32_t initialValue)
56 | {
57 | const auto newId = GetNextId();
58 | InsertInstruction(bytecode::NewUint{ newId, initialValue });
59 |
60 | return make(newId, *this);
61 | }
62 |
63 | winrt::AutomationRemoteDouble AutomationRemoteOperation::NewDouble(double initialValue)
64 | {
65 | const auto newId = GetNextId();
66 | InsertInstruction(bytecode::NewDouble{ newId, initialValue });
67 |
68 | return make(newId, *this);
69 | }
70 |
71 | winrt::AutomationRemoteChar AutomationRemoteOperation::NewChar(wchar_t initialValue)
72 | {
73 | const auto newId = GetNextId();
74 | InsertInstruction(bytecode::NewChar{ newId, initialValue });
75 |
76 | return make(newId, *this);
77 | }
78 |
79 | winrt::AutomationRemoteString AutomationRemoteOperation::NewString(hstring const& initialValue)
80 | {
81 | const auto newId = GetNextId();
82 | InsertInstruction(bytecode::NewString{ newId, std::wstring{ initialValue } });
83 |
84 | return make(newId, *this);
85 | }
86 |
87 | winrt::AutomationRemotePoint AutomationRemoteOperation::NewPoint(Windows::Foundation::Point const& initialValue)
88 | {
89 | const auto newId = GetNextId();
90 | UiaPoint uiaPoint{ initialValue.X, initialValue.Y };
91 | InsertInstruction(bytecode::NewPoint{ newId, uiaPoint });
92 |
93 | return make(newId, *this);
94 | }
95 |
96 | winrt::AutomationRemoteRect AutomationRemoteOperation::NewRect(Windows::Foundation::Rect const& initialValue)
97 | {
98 | const auto newId = GetNextId();
99 | UiaRect uiaRect{ initialValue.X, initialValue.Y, initialValue.Width, initialValue.Height };
100 | InsertInstruction(bytecode::NewRect{ newId, uiaRect });
101 |
102 | return make(newId, *this);
103 | }
104 |
105 | bool AutomationRemoteOperation::IsGuidSupported() const
106 | {
107 | return m_remoteOperation.IsOpcodeSupported(static_cast(bytecode::InstructionType::NewGuid));
108 | }
109 |
110 | winrt::AutomationRemoteGuid AutomationRemoteOperation::NewGuid(const winrt::guid& initialValue)
111 | {
112 | const auto newId = GetNextId();
113 | InsertInstruction(bytecode::NewGuid{ newId, initialValue });
114 |
115 | return make(newId, *this);
116 | }
117 |
118 | bool AutomationRemoteOperation::IsCacheRequestSupported() const
119 | {
120 | return m_remoteOperation.IsOpcodeSupported(static_cast(bytecode::InstructionType::NewCacheRequest));
121 | }
122 |
123 | winrt::AutomationRemoteCacheRequest AutomationRemoteOperation::NewCacheRequest()
124 | {
125 | const auto newId = GetNextId();
126 | InsertInstruction(bytecode::NewCacheRequest{ newId });
127 |
128 | return make(newId, *this);
129 | }
130 |
131 | winrt::AutomationRemoteArray AutomationRemoteOperation::NewArray()
132 | {
133 | const auto newId = GetNextId();
134 | InsertInstruction(bytecode::NewArray{ newId });
135 |
136 | return make(newId, *this);
137 | }
138 |
139 | winrt::AutomationRemoteStringMap AutomationRemoteOperation::NewStringMap()
140 | {
141 | const auto newId = GetNextId();
142 | InsertInstruction(bytecode::NewStringMap{ newId });
143 |
144 | return make(newId, *this);
145 | }
146 |
147 | winrt::AutomationRemoteAnyObject AutomationRemoteOperation::NewNull()
148 | {
149 | const auto newId = GetNextId();
150 | InsertInstruction(bytecode::NewNull{ newId });
151 |
152 | return make(newId, *this);
153 | }
154 |
155 | // NewEmpty is similar to NewNull except it doesn't insert any instruction, instead NewEmpty serves as a place holder
156 | // for any operands that are to be set when the Remote Operation gets executed(an out only parameter without wasting an instruction)
157 | // This is particularly used with CallExtension as it takes an arrray of operands and some of them will be
158 | // out params and using NullOperand for all of them would waste instructions.
159 | winrt::AutomationRemoteAnyObject AutomationRemoteOperation::NewEmpty()
160 | {
161 | const auto newId = GetNextId();
162 |
163 | return make(newId, *this);
164 | }
165 |
166 | winrt::AutomationRemoteByteArray AutomationRemoteOperation::NewByteArray(winrt::array_view initialValue)
167 | {
168 | const auto newId = GetNextId();
169 |
170 | std::vector byteVector;
171 | for (const auto& byteVal : initialValue)
172 | {
173 | byteVector.emplace_back(byteVal);
174 | }
175 |
176 | InsertInstruction(bytecode::NewByteArray{ newId, std::move(byteVector) });
177 |
178 | return make(newId, *this);
179 | }
180 |
181 | bool AutomationRemoteOperation::IsOpcodeSupported(const uint32_t opcode) const
182 | {
183 | return m_remoteOperation.IsOpcodeSupported(opcode);
184 | }
185 |
186 | winrt::AutomationRemoteElement AutomationRemoteOperation::ImportElement(winrt::AutomationElement const& element)
187 | {
188 | const auto elementId = GetNextId();
189 | m_remoteOperation.ImportElement({ elementId.Value }, element);
190 | const auto result = make(elementId, *this);
191 |
192 | return result;
193 | }
194 |
195 | winrt::AutomationRemoteTextRange AutomationRemoteOperation::ImportTextRange(winrt::AutomationTextRange const& textRange)
196 | {
197 | const auto textRangeId = GetNextId();
198 | m_remoteOperation.ImportTextRange({ textRangeId.Value }, textRange);
199 |
200 | const auto result = make(textRangeId, *this);
201 | return result;
202 | }
203 |
204 | winrt::AutomationRemoteConnectionBoundObject AutomationRemoteOperation::ImportConnectionBoundObject(winrt::AutomationConnectionBoundObject const& connectionBoundObject)
205 | {
206 | const auto connectionBoundObjectId = GetNextId();
207 | m_remoteOperation.ImportConnectionBoundObject({ connectionBoundObjectId.Value }, connectionBoundObject);
208 |
209 | const auto result = make(connectionBoundObjectId, *this);
210 | return result;
211 | }
212 |
213 | void AutomationRemoteOperation::RequestResponse(bytecode::OperandId remoteOperationId)
214 | {
215 | m_remoteOperation.AddToResults({ remoteOperationId.Value });
216 | }
217 |
218 | AutomationRemoteOperationResponseToken AutomationRemoteOperation::RequestResponse(const winrt::AutomationRemoteObject& object)
219 | {
220 | const auto operandId = get_self(object)->OperandId();
221 | RequestResponse(operandId);
222 | return { operandId.Value };
223 | }
224 |
225 | void AutomationRemoteOperation::IfBlock(
226 | const winrt::AutomationRemoteBool& condition,
227 | const AutomationRemoteOperationScopeHandler& trueHandler,
228 | const AutomationRemoteOperationScopeHandler& falseHandler /* = nullptr */)
229 | {
230 | const auto conditionId = get_self(condition)->OperandId();
231 | const auto [trueScope, falseScope] = m_currentScope->AddIfStatement(conditionId.Value);
232 |
233 | const auto previousScope = m_currentScope;
234 | auto scopeExit = wil::scope_exit([&]()
235 | {
236 | m_currentScope = previousScope;
237 | });
238 |
239 | m_currentScope = trueScope;
240 | trueHandler();
241 |
242 | if (falseHandler)
243 | {
244 | m_currentScope = falseScope;
245 | falseHandler();
246 | }
247 | }
248 |
249 | void AutomationRemoteOperation::WhileBlock(
250 | const winrt::AutomationRemoteBool& condition,
251 | const AutomationRemoteOperationScopeHandler& loopBodyHandler,
252 | const AutomationRemoteOperationScopeHandler& loopConditionUpdateHandler)
253 | {
254 | const auto conditionId = get_self(condition)->OperandId();
255 | const auto [loopBodyScope, loopConditionUpdateScope] = m_currentScope->AddWhileLoop(conditionId.Value);
256 |
257 | const auto previousScope = m_currentScope;
258 | auto scopeExit = wil::scope_exit([&]()
259 | {
260 | m_currentScope = previousScope;
261 | });
262 |
263 | m_currentScope = loopBodyScope;
264 | loopBodyHandler();
265 |
266 | if (loopConditionUpdateHandler)
267 | {
268 | m_currentScope = loopConditionUpdateScope;
269 | loopConditionUpdateHandler();
270 | }
271 | }
272 |
273 | void AutomationRemoteOperation::ReturnOperationStatus(winrt::hresult status)
274 | {
275 | auto remoteErrorCode = NewInt(static_cast(status));
276 | ReturnOperationStatus(remoteErrorCode);
277 | }
278 |
279 | void AutomationRemoteOperation::ReturnOperationStatus(const winrt::AutomationRemoteInt& status)
280 | {
281 | const auto operandId = get_self(status)->OperandId();
282 | InsertInstruction(bytecode::SetOperationStatus{ operandId });
283 | InsertInstruction(bytecode::Halt{});
284 | }
285 |
286 | void AutomationRemoteOperation::BreakLoop()
287 | {
288 | InsertInstruction(bytecode::BreakLoop{});
289 | }
290 |
291 | void AutomationRemoteOperation::ContinueLoop()
292 | {
293 | InsertInstruction(bytecode::ContinueLoop{});
294 | }
295 |
296 | void AutomationRemoteOperation::TryBlock(
297 | const AutomationRemoteOperationScopeHandler& tryBodyHandler)
298 | {
299 | TryBlock(tryBodyHandler, nullptr /* exceptBlockHandler */);
300 | }
301 |
302 | void AutomationRemoteOperation::TryBlock(
303 | const AutomationRemoteOperationScopeHandler& tryBodyHandler,
304 | const AutomationRemoteOperationScopeHandler& exceptBlockHandler)
305 | {
306 | const auto [tryBodyScope, exceptBlockScope] = m_currentScope->AddTryStatement();
307 |
308 | const auto previousScope = m_currentScope;
309 | auto scopeExit = wil::scope_exit([&]()
310 | {
311 | m_currentScope = previousScope;
312 | });
313 |
314 | m_currentScope = tryBodyScope;
315 | tryBodyHandler();
316 |
317 | if (exceptBlockHandler)
318 | {
319 | m_currentScope = exceptBlockScope;
320 | exceptBlockHandler();
321 | }
322 |
323 | // No matter what, the except block executes a special instruction that clears the extended error code
324 | // that was set by the error. This way, once the except block is complete, we've cleared the extended
325 | // error code back to S_OK/success.
326 | const auto newId = GetNextId();
327 | exceptBlockScope->AddInstruction(bytecode::NewInt{ newId, S_OK });
328 | exceptBlockScope->AddInstruction(bytecode::SetOperationStatus{ newId });
329 | }
330 |
331 | winrt::AutomationRemoteInt AutomationRemoteOperation::GetCurrentFailureCode()
332 | {
333 | const auto resultId = GetNextId();
334 | InsertInstruction(bytecode::GetOperationStatus{ resultId });
335 |
336 | return make(resultId, *this);
337 | }
338 |
339 | winrt::AutomationRemoteOperationResultSet AutomationRemoteOperation::Execute()
340 | {
341 | auto serializedBytecode = m_rootGraph->Serialize();
342 | auto result = m_remoteOperation.Execute(serializedBytecode);
343 |
344 | // We wrap the platform result into the Result Set that the higher-level API operates on.
345 | auto resultSet = make(std::move(result));
346 |
347 | return resultSet;
348 | }
349 | }
350 |
--------------------------------------------------------------------------------
/src/UIAutomation/UiaOperationAbstraction/UiaTypeAbstractionEnums.g.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 | // WARNING: Please don't edit this file. It was generated.
4 |
5 | #pragma once
6 |
7 | using UiaActiveEnd = UiaEnum<
8 | ActiveEnd,
9 | winrt::Microsoft::UI::UIAutomation::AutomationActiveEnd,
10 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteActiveEnd,
11 | static_cast>(
12 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsActiveEnd)>;
13 | using UiaAnimationStyle = UiaEnum<
14 | AnimationStyle,
15 | winrt::Microsoft::UI::UIAutomation::AutomationAnimationStyle,
16 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnimationStyle,
17 | static_cast>(
18 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsAnimationStyle)>;
19 | using UiaAnnotationType = UiaEnum<
20 | int,
21 | winrt::Microsoft::UI::UIAutomation::AutomationAnnotationType,
22 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnnotationType,
23 | static_cast>(
24 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsAnnotationType)>;
25 | using UiaBulletStyle = UiaEnum<
26 | BulletStyle,
27 | winrt::Microsoft::UI::UIAutomation::AutomationBulletStyle,
28 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteBulletStyle,
29 | static_cast>(
30 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsBulletStyle)>;
31 | using UiaCapStyle = UiaEnum<
32 | CapStyle,
33 | winrt::Microsoft::UI::UIAutomation::AutomationCapStyle,
34 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteCapStyle,
35 | static_cast>(
36 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsCapStyle)>;
37 | using UiaCaretBidiMode = UiaEnum<
38 | CaretBidiMode,
39 | winrt::Microsoft::UI::UIAutomation::AutomationCaretBidiMode,
40 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteCaretBidiMode,
41 | static_cast>(
42 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsCaretBidiMode)>;
43 | using UiaCaretPosition = UiaEnum<
44 | CaretPosition,
45 | winrt::Microsoft::UI::UIAutomation::AutomationCaretPosition,
46 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteCaretPosition,
47 | static_cast>(
48 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsCaretPosition)>;
49 | using UiaControlType = UiaEnum<
50 | CONTROLTYPEID,
51 | winrt::Microsoft::UI::UIAutomation::AutomationControlType,
52 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteControlType,
53 | static_cast>(
54 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsControlType)>;
55 | using UiaDockPosition = UiaEnum<
56 | DockPosition,
57 | winrt::Microsoft::UI::UIAutomation::AutomationDockPosition,
58 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteDockPosition,
59 | static_cast>(
60 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsDockPosition)>;
61 | using UiaExpandCollapseState = UiaEnum<
62 | ExpandCollapseState,
63 | winrt::Microsoft::UI::UIAutomation::AutomationExpandCollapseState,
64 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteExpandCollapseState,
65 | static_cast>(
66 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsExpandCollapseState)>;
67 | using UiaFlowDirections = UiaEnum<
68 | FlowDirections,
69 | winrt::Microsoft::UI::UIAutomation::AutomationFlowDirections,
70 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteFlowDirections,
71 | static_cast>(
72 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsFlowDirections)>;
73 | using UiaHeadingLevel = UiaEnum<
74 | HEADINGLEVELID,
75 | winrt::Microsoft::UI::UIAutomation::AutomationHeadingLevel,
76 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteHeadingLevel,
77 | static_cast>(
78 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsHeadingLevel)>;
79 | using UiaHorizontalTextAlignment = UiaEnum<
80 | HorizontalTextAlignment,
81 | winrt::Microsoft::UI::UIAutomation::AutomationHorizontalTextAlignment,
82 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteHorizontalTextAlignment,
83 | static_cast>(
84 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsHorizontalTextAlignment)>;
85 | using UiaLandmarkType = UiaEnum<
86 | LANDMARKTYPEID,
87 | winrt::Microsoft::UI::UIAutomation::AutomationLandmarkType,
88 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteLandmarkType,
89 | static_cast>(
90 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsLandmarkType)>;
91 | using UiaLiveSetting = UiaEnum<
92 | LiveSetting,
93 | winrt::Microsoft::UI::UIAutomation::AutomationLiveSetting,
94 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteLiveSetting,
95 | static_cast>(
96 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsLiveSetting)>;
97 | using UiaMetadata = UiaEnum<
98 | METADATAID,
99 | winrt::Microsoft::UI::UIAutomation::AutomationMetadata,
100 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteMetadata,
101 | static_cast>(
102 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsMetadata)>;
103 | using UiaNavigateDirection = UiaEnum<
104 | NavigateDirection,
105 | winrt::Microsoft::UI::UIAutomation::AutomationNavigateDirection,
106 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteNavigateDirection,
107 | static_cast>(
108 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsNavigateDirection)>;
109 | using UiaOrientationType = UiaEnum<
110 | OrientationType,
111 | winrt::Microsoft::UI::UIAutomation::AutomationOrientationType,
112 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteOrientationType,
113 | static_cast>(
114 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsOrientationType)>;
115 | using UiaOutlineStyles = UiaEnum<
116 | OutlineStyles,
117 | winrt::Microsoft::UI::UIAutomation::AutomationOutlineStyles,
118 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteOutlineStyles,
119 | static_cast>(
120 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsOutlineStyles)>;
121 | using UiaPatternId = UiaEnum<
122 | PATTERNID,
123 | winrt::Microsoft::UI::UIAutomation::AutomationPatternId,
124 | winrt::Microsoft::UI::UIAutomation::AutomationRemotePatternId,
125 | static_cast>(
126 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsPatternId)>;
127 | using UiaPropertyId = UiaEnum<
128 | PROPERTYID,
129 | winrt::Microsoft::UI::UIAutomation::AutomationPropertyId,
130 | winrt::Microsoft::UI::UIAutomation::AutomationRemotePropertyId,
131 | static_cast>(
132 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsPropertyId)>;
133 | using UiaRowOrColumnMajor = UiaEnum<
134 | RowOrColumnMajor,
135 | winrt::Microsoft::UI::UIAutomation::AutomationRowOrColumnMajor,
136 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteRowOrColumnMajor,
137 | static_cast>(
138 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsRowOrColumnMajor)>;
139 | using UiaSayAsInterpretAs = UiaEnum<
140 | SayAsInterpretAs,
141 | winrt::Microsoft::UI::UIAutomation::AutomationSayAsInterpretAs,
142 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteSayAsInterpretAs,
143 | static_cast>(
144 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsSayAsInterpretAs)>;
145 | using UiaScrollAmount = UiaEnum<
146 | ScrollAmount,
147 | winrt::Microsoft::UI::UIAutomation::AutomationScrollAmount,
148 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteScrollAmount,
149 | static_cast>(
150 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsScrollAmount)>;
151 | using UiaStyleId = UiaEnum<
152 | int,
153 | winrt::Microsoft::UI::UIAutomation::AutomationStyleId,
154 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteStyleId,
155 | static_cast>(
156 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsStyleId)>;
157 | using UiaSupportedTextSelection = UiaEnum<
158 | SupportedTextSelection,
159 | winrt::Microsoft::UI::UIAutomation::AutomationSupportedTextSelection,
160 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteSupportedTextSelection,
161 | static_cast>(
162 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsSupportedTextSelection)>;
163 | using UiaSynchronizedInputType = UiaEnum<
164 | SynchronizedInputType,
165 | winrt::Microsoft::UI::UIAutomation::AutomationSynchronizedInputType,
166 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteSynchronizedInputType,
167 | static_cast>(
168 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsSynchronizedInputType)>;
169 | using UiaTextAttributeId = UiaEnum<
170 | TEXTATTRIBUTEID,
171 | winrt::Microsoft::UI::UIAutomation::AutomationTextAttributeId,
172 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteTextAttributeId,
173 | static_cast>(
174 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsTextAttributeId)>;
175 | using UiaTextDecorationLineStyle = UiaEnum<
176 | TextDecorationLineStyle,
177 | winrt::Microsoft::UI::UIAutomation::AutomationTextDecorationLineStyle,
178 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteTextDecorationLineStyle,
179 | static_cast>(
180 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsTextDecorationLineStyle)>;
181 | using UiaTextPatternRangeEndpoint = UiaEnum<
182 | TextPatternRangeEndpoint,
183 | winrt::Microsoft::UI::UIAutomation::AutomationTextPatternRangeEndpoint,
184 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteTextPatternRangeEndpoint,
185 | static_cast>(
186 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsTextPatternRangeEndpoint)>;
187 | using UiaTextUnit = UiaEnum<
188 | TextUnit,
189 | winrt::Microsoft::UI::UIAutomation::AutomationTextUnit,
190 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteTextUnit,
191 | static_cast>(
192 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsTextUnit)>;
193 | using UiaToggleState = UiaEnum<
194 | ToggleState,
195 | winrt::Microsoft::UI::UIAutomation::AutomationToggleState,
196 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteToggleState,
197 | static_cast>(
198 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsToggleState)>;
199 | using UiaWindowInteractionState = UiaEnum<
200 | WindowInteractionState,
201 | winrt::Microsoft::UI::UIAutomation::AutomationWindowInteractionState,
202 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteWindowInteractionState,
203 | static_cast>(
204 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsWindowInteractionState)>;
205 | using UiaWindowVisualState = UiaEnum<
206 | WindowVisualState,
207 | winrt::Microsoft::UI::UIAutomation::AutomationWindowVisualState,
208 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteWindowVisualState,
209 | static_cast>(
210 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsWindowVisualState)>;
211 | using UiaZoomUnit = UiaEnum<
212 | ZoomUnit,
213 | winrt::Microsoft::UI::UIAutomation::AutomationZoomUnit,
214 | winrt::Microsoft::UI::UIAutomation::AutomationRemoteZoomUnit,
215 | static_cast>(
216 | &winrt::Microsoft::UI::UIAutomation::AutomationRemoteAnyObject::AsZoomUnit)>;
217 |
--------------------------------------------------------------------------------