AccNotifyTouchInteraction 函数 (oleacc.h)
允许辅助技术 (AT) 应用程序通过 Windows 自动化 API ((例如 Microsoft UI 自动化) )通知系统它正在与 UI 交互,因为用户的触摸手势。 这允许辅助技术通知目标应用程序和系统用户正在与触摸交互。
语法
HRESULT AccNotifyTouchInteraction(
[in] HWND hwndApp,
[in] HWND hwndTarget,
[in] POINT ptTarget
);
参数
[in] hwndApp
属于调用 AccNotifyTouchInteraction 的 AT 进程的窗口。
[in] hwndTarget
AT 所面向的自动化元素的最近窗口。
[in] ptTarget
自动化元素的中心点 (或元素) 边框中的点。
返回值
如果成功,则返回 S_OK。
如果未成功,则返回标准 COM 错误代码。
注解
此函数要求调用进程具有 UIAccess 或更高权限。 如果调用方没有所需的权限,则对 AccNotifyTouchInteraction 的调用将失败并返回 E_ACCESSDENIED。 有关详细信息,请参阅 辅助技术的安全注意事项 和 /MANIFESTUAC (在清单中嵌入 UAC 信息) 。
当 AT 使用触摸数据 (例如使用 RegisterPointerInputTarget 函数) 时,AT 通过 Windows 自动化 API 与之交互的 shell 和应用程序不知道用户正在通过触摸进行交互。 要使系统向用户公开触摸相关功能,AT 必须使用 AccNotifyTouchInteraction 来通知系统它正在执行交互以响应用户触摸输入。
示例
此代码示例演示如何调用 AccNotifyTouchInteraction 函数。
// pTargetElement is the element being interacted with by the user, hwndApp
// represents an HWND owned by the AT.
HRESULT PerformTouchBasedInteraction(IUIAutomationElement *pTargetElement,
HWND hwndApp)
{
HRESULT hr = S_OK;
// Set the focus to the element and then notify the system that the
// interaction is occurring due to a touch gesture. This would also apply
// to pattern-based interactions (such as calls to
// IUIAutomationInvokePattern::Invoke)
hr = pTargetElement->SetFocus();
if (SUCCEEDED(hr))
{
HWND hwndTarget;
POINT ptTarget;
BOOL fGotClickablePoint;
// If the current element does not have a native window handle, an
// alternate method (such as walking up the parent chain) is required
// to get the nearest valid HWND.
hr = pTargetElement->get_CurrentNativeWindowHandle((UIA_HWND *)(&hwndTarget));
if (SUCCEEDED(hr))
{
// If the provider doesn't return a clickable point, an alternate
// method (such as using the bounding rectangle) will be required
// to get the center point of the current element.
hr = pTargetElement->GetClickablePoint(&ptTarget, &fGotClickablePoint);
}
if (SUCCEEDED(hr) && fGotClickablePoint)
{
hr = AccNotifyTouchInteraction(hwndApp, hwndTarget, ptTarget);
}
}
return hr;
}
要求
要求 | 值 |
---|---|
最低受支持的客户端 | Windows 8 [仅限桌面应用] |
最低受支持的服务器 | Windows Server 2012 [仅限桌面应用] |
目标平台 | Windows |
标头 | oleacc.h |
Library | Oleacc.lib |
DLL | Oleacc.dll |