1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <QtGui/qtguiglobal.h>
#if QT_CONFIG(accessibility)
#include "qwindowsuiautomation.h"
#if defined(__MINGW32__) || defined(__MINGW64__)
template<typename T, typename... TArg>
struct winapi_func
{
using func_t = T(WINAPI*)(TArg...);
const func_t func;
const T error_value;
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
winapi_func(const char *lib_name, const char *func_name, func_t func_proto,
T error_value = T(__HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND))) :
func(reinterpret_cast<func_t>(GetProcAddress(LoadLibraryA(lib_name), func_name))),
error_value(error_value)
{
std::ignore = func_proto;
}
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
T invoke(TArg... arg)
{
if (!func)
return error_value;
return func(arg...);
}
};
#define FN(fn) #fn,fn
BOOL WINAPI UiaClientsAreListening()
{
static auto func = winapi_func("uiautomationcore", FN(UiaClientsAreListening), BOOL(false));
return func.invoke();
}
LRESULT WINAPI UiaReturnRawElementProvider(
HWND hwnd, WPARAM wParam, LPARAM lParam, IRawElementProviderSimple *el)
{
static auto func = winapi_func("uiautomationcore", FN(UiaReturnRawElementProvider));
return func.invoke(hwnd, wParam, lParam, el);
}
HRESULT WINAPI UiaHostProviderFromHwnd(HWND hwnd, IRawElementProviderSimple **ppProvider)
{
static auto func = winapi_func("uiautomationcore", FN(UiaHostProviderFromHwnd));
return func.invoke(hwnd, ppProvider);
}
HRESULT WINAPI UiaRaiseAutomationPropertyChangedEvent(
IRawElementProviderSimple *pProvider, PROPERTYID id, VARIANT oldValue, VARIANT newValue)
{
static auto func = winapi_func("uiautomationcore", FN(UiaRaiseAutomationPropertyChangedEvent));
return func.invoke(pProvider, id, oldValue, newValue);
}
HRESULT WINAPI UiaRaiseAutomationEvent(IRawElementProviderSimple *pProvider, EVENTID id)
{
static auto func = winapi_func("uiautomationcore", FN(UiaRaiseAutomationEvent));
return func.invoke(pProvider, id);
}
HRESULT WINAPI UiaRaiseNotificationEvent(
IRawElementProviderSimple *pProvider, NotificationKind notificationKind,
NotificationProcessing notificationProcessing, BSTR displayString, BSTR activityId)
{
static auto func = winapi_func("uiautomationcore", FN(UiaRaiseNotificationEvent));
return func.invoke(pProvider, notificationKind, notificationProcessing, displayString, activityId);
}
#endif // defined(__MINGW32__) || defined(__MINGW64__)
#endif // QT_CONFIG(accessibility)
|