daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top