0

You can get the Chrome URL using uiautomation. However, Chrome UI menu is not visible on some PCs. Is there another way?

UI Menu Success: UI Spy OK

UI Menu Failed: UI Spy KO

varPropAddr.bstrVal = SysAllocString(L"Address and search bar");

m_pAutomation->CreatePropertyCondition(UIA_NamePropertyId, varPropAddr, &pAddrCondition

pRoot->FindFirst(TreeScope_Subtree, pAddrCondition, &pAddrBar);

SysFreeString(varPropAddr.bstrVal);

hr = E_FAIL;

hr = pAddrBar->GetCurrentPatternAs(UIA_ValuePatternId, __uuidof(IUIAutomationValuePattern), (void**)&pURLValuePattern);

if (pURLValuePattern != NULL)
{
BSTR bstrUrl;
HRESULT hr = pURLValuePattern->get_CurrentValue(&bstrUrl);
if (SUCCEEDED(hr))
{   
bReadOnly = TRUE;
strUrl = (LPWSTR)bstrUrl;
//m_strUrl_Chrome = strUrl;

SysFreeString(bstrUrl);
bstrUrl = NULL;
}
}

chrome Update, Reinstall chrome, chrome option reset

I have successfully obtained the Chrome URL with the above code. However, some PCs did not get the URL because I could not check the UI menu.

manuell
  • 7,528
  • 5
  • 31
  • 58
hhbae
  • 1
  • 1
  • Take a look at https://stackoverflow.com/questions/25613115/microsoft-uiautomation-isnt-always-working-on-some-computers-c-sharp – manuell May 21 '19 at 06:37
  • The problem is not solved. Thank you. – hhbae May 23 '19 at 05:34
  • Sorry, I have no solution. Try to find what is different on the failing PCs (os version, chrome version, .dotnet version). Also, try to use inspect.exe from Windows SDK. – manuell May 23 '19 at 06:51

0 Answers0