Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qwindowsuiawrapper.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <initguid.h>
5
7#include <QtCore/private/qsystemlibrary_p.h>
8
10
11// private constructor
12QWindowsUiaWrapper::QWindowsUiaWrapper()
13{
14 QSystemLibrary uiaLib(QStringLiteral("UIAutomationCore"));
15 if (uiaLib.load()) {
16 m_pUiaReturnRawElementProvider = reinterpret_cast<PtrUiaReturnRawElementProvider>(uiaLib.resolve("UiaReturnRawElementProvider"));
17 m_pUiaHostProviderFromHwnd = reinterpret_cast<PtrUiaHostProviderFromHwnd>(uiaLib.resolve("UiaHostProviderFromHwnd"));
18 m_pUiaRaiseAutomationPropertyChangedEvent = reinterpret_cast<PtrUiaRaiseAutomationPropertyChangedEvent>(uiaLib.resolve("UiaRaiseAutomationPropertyChangedEvent"));
19 m_pUiaRaiseAutomationEvent = reinterpret_cast<PtrUiaRaiseAutomationEvent>(uiaLib.resolve("UiaRaiseAutomationEvent"));
20 m_pUiaRaiseNotificationEvent = reinterpret_cast<PtrUiaRaiseNotificationEvent>(uiaLib.resolve("UiaRaiseNotificationEvent"));
21 m_pUiaClientsAreListening = reinterpret_cast<PtrUiaClientsAreListening>(uiaLib.resolve("UiaClientsAreListening"));
22 }
23}
24
26{
27}
28
29// shared instance
31{
33 return &wrapper;
34}
35
36// True if most symbols resolved (UiaRaiseNotificationEvent is optional).
38{
39 return m_pUiaReturnRawElementProvider
40 && m_pUiaHostProviderFromHwnd
41 && m_pUiaRaiseAutomationPropertyChangedEvent
42 && m_pUiaRaiseAutomationEvent
43 && m_pUiaClientsAreListening;
44}
45
47{
48 if (!m_pUiaClientsAreListening)
49 return FALSE;
50 return m_pUiaClientsAreListening();
51}
52
53LRESULT QWindowsUiaWrapper::returnRawElementProvider(HWND hwnd, WPARAM wParam, LPARAM lParam, IRawElementProviderSimple *el)
54{
55 if (!m_pUiaReturnRawElementProvider)
56 return static_cast<LRESULT>(NULL);
57 return m_pUiaReturnRawElementProvider(hwnd, wParam, lParam, el);
58}
59
60HRESULT QWindowsUiaWrapper::hostProviderFromHwnd(HWND hwnd, IRawElementProviderSimple **ppProvider)
61{
62 if (!m_pUiaHostProviderFromHwnd)
63 return UIA_E_NOTSUPPORTED;
64 return m_pUiaHostProviderFromHwnd(hwnd, ppProvider);
65}
66
67HRESULT QWindowsUiaWrapper::raiseAutomationPropertyChangedEvent(IRawElementProviderSimple *pProvider, PROPERTYID id, VARIANT oldValue, VARIANT newValue)
68{
69 if (!m_pUiaRaiseAutomationPropertyChangedEvent)
70 return UIA_E_NOTSUPPORTED;
71 return m_pUiaRaiseAutomationPropertyChangedEvent(pProvider, id, oldValue, newValue);
72}
73
74HRESULT QWindowsUiaWrapper::raiseAutomationEvent(IRawElementProviderSimple *pProvider, EVENTID id)
75{
76 if (!m_pUiaRaiseAutomationEvent)
77 return UIA_E_NOTSUPPORTED;
78 return m_pUiaRaiseAutomationEvent(pProvider, id);
79}
80
81HRESULT QWindowsUiaWrapper::raiseNotificationEvent(IRawElementProviderSimple *provider, NotificationKind notificationKind, NotificationProcessing notificationProcessing, BSTR displayString, BSTR activityId)
82{
83 if (!m_pUiaRaiseNotificationEvent)
84 return UIA_E_NOTSUPPORTED;
85 return m_pUiaRaiseNotificationEvent(provider, notificationKind, notificationProcessing, displayString, activityId);
86}
87
89
HRESULT raiseNotificationEvent(IRawElementProviderSimple *provider, NotificationKind notificationKind, NotificationProcessing notificationProcessing, BSTR displayString, BSTR activityId)
HRESULT raiseAutomationEvent(IRawElementProviderSimple *pProvider, EVENTID id)
static QWindowsUiaWrapper * instance()
HRESULT raiseAutomationPropertyChangedEvent(IRawElementProviderSimple *pProvider, PROPERTYID id, VARIANT oldValue, VARIANT newValue)
LRESULT returnRawElementProvider(HWND hwnd, WPARAM wParam, LPARAM lParam, IRawElementProviderSimple *el)
HRESULT hostProviderFromHwnd(HWND hwnd, IRawElementProviderSimple **ppProvider)
Combined button and popup list for selecting options.
#define QStringLiteral(str)
long HRESULT
QStringView el
void wrapper()
#define UIA_E_NOTSUPPORTED
NotificationProcessing
Definition uiatypes_p.h:137
int EVENTID
Definition uiatypes_p.h:20
NotificationKind
Definition uiatypes_p.h:129
int PROPERTYID
Definition uiatypes_p.h:18