public override string GetWindowUrl() { var coreWindowHwnd = FindDescendantWindows(mHwnd, "Windows.UI.Core.CoreWindow").FirstOrDefault(); if (coreWindowHwnd == IntPtr.Zero) { return(null); } var addressBar = AccessibleObjectHelper.FindChild(AccessibleObjectHelper.FindChild(AccessibleObjectHelper.GetAccessibleObjectFromWindow(coreWindowHwnd), role: AccessibleRole.Window), role: AccessibleRole.Text); if (addressBar == null) { return(null); } var address = addressBar.accValue[0]; if (!address.Contains("://")) { address = "http://" + address; // If we can't tell if it is https or http, default to less secure assumption (insufficient justification to assume secure) } return(address); }
/// <summary> /// Gets the URL of the frame of the browser that has the focus, and the focussed element /// </summary> public virtual string GetBrowserFocusUrl(out bool passwordFieldFocussed) { var windowDoc = GetDocument(); if (windowDoc == null) { passwordFieldFocussed = false; return(null); } var focusedElement = windowDoc.accFocus as IAccessible; if (focusedElement == null) { passwordFieldFocussed = false; return(GetDocumentUrl(windowDoc)); } passwordFieldFocussed = AccessibleObjectHelper.HasState(focusedElement, AccessibleStates.Protected); var focusDoc = GetElementParentDocument(focusedElement); if (focusDoc == null) { return(GetDocumentUrl(windowDoc)); } return(GetDocumentUrl(focusDoc)); }
public virtual string GetBrowserFocusUrlWithInfo(out string title, out string selectedText) { var windowDoc = GetDocument(); if (windowDoc == null) { title = null; selectedText = null; return(null); } var focusedElement = windowDoc.accFocus as IAccessible; if (focusedElement == null) { selectedText = null; title = GetDocumentTitle(windowDoc); return(GetDocumentUrl(windowDoc)); } if ((int)focusedElement.accRole[0] == (int)AccessibleRole.Text) { selectedText = AccessibleObjectHelper.SafeGetValue(focusedElement); } else { selectedText = null; } var focusDoc = GetElementParentDocument(focusedElement) ?? windowDoc; title = GetDocumentTitle(focusDoc); return(GetDocumentUrl(focusDoc)); }
protected override string GetDocumentTitle(IAccessible document) { var firstChild = AccessibleObjectHelper.GetChildren(document).FirstOrDefault(); if (firstChild != null) { return(firstChild.accName[0]); } return(null); }
protected override IAccessible GetDocument() { var ieServerHwnd = FindDescendantWindows(mHwnd, "Internet Explorer_Server").FirstOrDefault(); if (ieServerHwnd == default(IntPtr)) { return(null); } var ieServer = AccessibleObjectHelper.GetAccessibleObjectFromWindow(ieServerHwnd); return(ieServer); }
protected override IAccessible GetDocument() { var propertyPage = AccessibleObjectHelper.FindChild(AccessibleObjectHelper.FindChild(AccessibleObjectHelper.FindChild(AccessibleObjectHelper.GetAccessibleObjectFromWindow(mHwnd), role: AccessibleRole.Application), role: AccessibleRole.Grouping, hasNotState: AccessibleStates.Invisible), role: AccessibleRole.PropertyPage, hasNotState: AccessibleStates.Offscreen /*(inactive tab)*/); var browser = AccessibleObjectHelper.FindChild(propertyPage, customRole: "browser, http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul") // Firefox 59+ ?? AccessibleObjectHelper.FindChild(propertyPage, customRole: "browser"); // Firefox <59 return(AccessibleObjectHelper.FindChild(browser, role: AccessibleRole.Document)); }
protected override IAccessible GetDocument() { var chromeRenderHwnd = FindDescendantWindows(mHwnd, "Chrome_RenderWidgetHostHWND").FirstOrDefault(); if (chromeRenderHwnd == IntPtr.Zero) { return(null); } // Chrome only enables accessibility if it gets a top-level IAccessible request, so let's make one first var _ = AccessibleObjectHelper.GetAccessibleObjectFromWindow(mHwnd).accName; return(AccessibleObjectHelper.FindChild(AccessibleObjectHelper.GetAccessibleObjectFromWindow(chromeRenderHwnd), role: AccessibleRole.Document)); }
protected virtual IAccessible GetElementParentDocument(IAccessible element) { return(AccessibleObjectHelper.FindAncestor(element, role: AccessibleRole.Document, hasState: AccessibleStates.Focusable)); }
protected override IAccessible GetElementParentDocument(IAccessible element) { return(AccessibleObjectHelper.FindAncestor(element, AccessibleRole.Client)); }