I want to obtain the URL of the browser Internet Explorer. I found the following code (Get active Tab URL in Chrome with C++) in C++ and I am trying to convert it to plain C.
IUIAutomationCondition *pCondition = NULL;
VARIANT url;
VARIANT varProp;
varProp.vt = VT_I4;
varProp.lVal = UIA_EditControlTypeId;
hr = IUIAutomation_CreatePropertyCondition(pAutomation,UIA_ControlTypePropertyId,varProp,&pCondition);
if(SUCCEEDED(hr)){
hr = IUIAutomationElement_FindFirst(pNode,TreeScope_Descendants,pCondition,&urlBar);
if(urlBar!= NULL){
IUIAutomationElement_GetCurrentPropertyValue(urlBar,UIA_ValueValuePropertyId,&url);
MessageBox(0, url.bstrVal, L"success", 0);
}
}
IUnknown_Release(pCondition);
This code prints the text URL "h" in the message box when I want to retrieve the value from the browser and the value should be www.amazon.com. I do not know what I am doing incorrectly. I really appreciate if someone could help me out.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…