Windows 10 Creators Update(1703)后UIAutomation变慢

时间:2017-05-22 07:45:07

标签: c++ com ui-automation

Windows 10(1607) - ElementFromPoint 呼叫持续时间 2 ms

Windows 10 Creators更新(1703) - ElementFromPoint 呼叫持续时间 500ms

#include <Windows.h>
#include <UIAutomationClient.h>

IUIAutomation* g_automation = nullptr;

LRESULT CALLBACK LowLevelMouseProc(INT nCode, WPARAM wParam, LPARAM lParam)
{
    POINT pt = ((PMSLLHOOKSTRUCT)lParam)->pt;

    IUIAutomationElement *element = nullptr;
    g_automation->ElementFromPoint(pt, &element);

    return CallNextHookEx(0, nCode, wParam, lParam);
}

void main()
{
    CoInitializeEx(NULL, COINIT_SPEED_OVER_MEMORY);
    CoCreateInstance(__uuidof(CUIAutomation), NULL, CLSCTX_INPROC_SERVER, 
        __uuidof(IUIAutomation), (void**)& g_automation);

    SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)LowLevelMouseProc, 
    GetModuleHandle(nullptr), 0);

    MSG message;
    GetMessage(&message, (HWND)NULL, 0, 0);
}

点是鼠标点击坐标。

ElementFromPoint太长了 - 这就是问题。

在COM / UIAutomation处理中看起来有些变化吗?

是否存在一些解决方法从点获取UI元素?

0 个答案:

没有答案