Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowsuiautomation.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 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 <QtGui/qtguiglobal.h>
5#if QT_CONFIG(accessibility)
6
7#include "qwindowsuiautomation.h"
8
9#ifndef Q_CC_MSVC
10
11template<typename T, typename... TArg>
12struct winapi_func
13{
14 using func_t = T(WINAPI*)(TArg...);
15 const func_t func;
16 const T error_value;
17#ifdef __GNUC__
18# pragma GCC diagnostic push
19# pragma GCC diagnostic ignored "-Wcast-function-type"
20#endif
21 winapi_func(const char *lib_name, const char *func_name, func_t func_proto,
22 T error_value = T(__HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND))) :
23 func(reinterpret_cast<func_t>(GetProcAddress(LoadLibraryA(lib_name), func_name))),
24 error_value(error_value)
25 {
26 std::ignore = func_proto;
27 }
28#ifdef __GNUC__
29# pragma GCC diagnostic pop
30#endif
31 T invoke(TArg... arg)
32 {
33 if (!func)
34 return error_value;
35 return func(arg...);
36 }
37};
38
39#define FN(fn) #fn,fn
40
41BOOL WINAPI UiaClientsAreListening()
42{
43 static auto func = winapi_func("uiautomationcore", FN(UiaClientsAreListening), BOOL(false));
44 return func.invoke();
45}
46
47LRESULT WINAPI UiaReturnRawElementProvider(
48 HWND hwnd, WPARAM wParam, LPARAM lParam, IRawElementProviderSimple *el)
49{
50 static auto func = winapi_func("uiautomationcore", FN(UiaReturnRawElementProvider));
51 return func.invoke(hwnd, wParam, lParam, el);
52}
53
54HRESULT WINAPI UiaHostProviderFromHwnd(HWND hwnd, IRawElementProviderSimple **ppProvider)
55{
56 static auto func = winapi_func("uiautomationcore", FN(UiaHostProviderFromHwnd));
57 return func.invoke(hwnd, ppProvider);
58}
59
60HRESULT WINAPI UiaRaiseAutomationPropertyChangedEvent(
61 IRawElementProviderSimple *pProvider, PROPERTYID id, VARIANT oldValue, VARIANT newValue)
62{
63 static auto func = winapi_func("uiautomationcore", FN(UiaRaiseAutomationPropertyChangedEvent));
64 return func.invoke(pProvider, id, oldValue, newValue);
65}
66
67HRESULT WINAPI UiaRaiseAutomationEvent(IRawElementProviderSimple *pProvider, EVENTID id)
68{
69 static auto func = winapi_func("uiautomationcore", FN(UiaRaiseAutomationEvent));
70 return func.invoke(pProvider, id);
71}
72
73HRESULT WINAPI UiaRaiseNotificationEvent(
74 IRawElementProviderSimple *pProvider, NotificationKind notificationKind,
75 NotificationProcessing notificationProcessing, BSTR displayString, BSTR activityId)
76{
77 static auto func = winapi_func("uiautomationcore", FN(UiaRaiseNotificationEvent));
78 return func.invoke(pProvider, notificationKind, notificationProcessing, displayString, activityId);
79}
80
81#endif // !Q_CC_MSVC
82
83#endif // QT_CONFIG(accessibility)