Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string GetUrl(Process* process) {
- CoInitialize(NULL);
- HWND hwnd = NULL;
- while (true) {
- if ((*process).exeName == "chrome.exe" or (*process).exeName == "opera.exe") {
- hwnd = FindWindowEx(0, hwnd, L"Chrome_WidgetWin_1", NULL);
- }
- else if ((*process).exeName == "firefox.exe") {
- hwnd = FindWindowEx(0, hwnd, L"MozillaWindowClass", NULL);
- }
- if (!hwnd)
- break;
- if (!IsWindowVisible(hwnd))
- continue;
- CComQIPtr<IUIAutomation> uia;
- if (FAILED(uia.CoCreateInstance(CLSID_CUIAutomation)) || !uia)
- return "Error5";
- CComPtr<IUIAutomationElement> element;
- if (FAILED(uia->ElementFromHandle(hwnd, &element)) || !element)
- return "Error4";
- if ((*process).exeName == "chrome.exe" or (*process).exeName == "opera.exe") {
- CComPtr<IUIAutomationCondition> condition;
- uia->CreatePropertyCondition(UIA_ControlTypePropertyId,
- CComVariant(UIA_EditControlTypeId), &condition);
- CComPtr<IUIAutomationElement> edit;// СМОТРЕТЬ СЮДА!!!!!!!!!!
- if (FAILED(element->FindFirst(TreeScope_Descendants, condition, &edit))
- || !edit)
- continue;
- CComVariant url;
- edit->GetCurrentPropertyValue(UIA_ValueValuePropertyId, &url);
- (*process).url = ConvertCComVariantToStr(url);
- return "Done";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement