Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <ole2.h>
- #include <UIAutomation.h>
- #include <strsafe.h>
- #include <iostream>
- IUIAutomation *_automation;
- int main()
- {
- HRESULT hr = CoInitialize(NULL);
- if (FAILED(hr))
- {
- wprintf(L"CoInitialize failed, HR:0x%08xn", hr);
- }
- else
- {
- hr = CoCreateInstance(__uuidof(CUIAutomation8), NULL,
- CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&_automation));
- if (FAILED(hr))
- {
- wprintf(L"Failed to create a CUIAutomation8, HR: 0x%08xn", hr);
- }
- else
- {
- IUIAutomationElement *element = NULL;
- HWND wHandle = FindWindow(0, LPCTSTR((LPARAM)TEXT("3rd party window name")));
- HRESULT hr = _automation->ElementFromHandle(wHandle, &element);
- if (SUCCEEDED(hr) && element != NULL)
- {
- ListDescendants(element, 0);
- element->Release();
- }
- _automation->Release();
- }
- }
- CoUninitialize();
- }
Add Comment
Please, Sign In to add comment