Guest User

Untitled

a guest
Feb 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <windows.h>
  2. #include <ole2.h>
  3. #include <UIAutomation.h>
  4. #include <strsafe.h>
  5. #include <iostream>
  6.  
  7. IUIAutomation *_automation;
  8.  
  9. int main()
  10. {
  11. HRESULT hr = CoInitialize(NULL);
  12. if (FAILED(hr))
  13. {
  14. wprintf(L"CoInitialize failed, HR:0x%08xn", hr);
  15. }
  16. else
  17. {
  18. hr = CoCreateInstance(__uuidof(CUIAutomation8), NULL,
  19. CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&_automation));
  20. if (FAILED(hr))
  21. {
  22. wprintf(L"Failed to create a CUIAutomation8, HR: 0x%08xn", hr);
  23. }
  24. else
  25. {
  26. IUIAutomationElement *element = NULL;
  27. HWND wHandle = FindWindow(0, LPCTSTR((LPARAM)TEXT("3rd party window name")));
  28. HRESULT hr = _automation->ElementFromHandle(wHandle, &element);
  29. if (SUCCEEDED(hr) && element != NULL)
  30. {
  31. ListDescendants(element, 0);
  32. element->Release();
  33. }
  34. _automation->Release();
  35. }
  36. }
  37. CoUninitialize();
  38. }
Add Comment
Please, Sign In to add comment