private static bool EnumWindows(IntPtr hWnd, IntPtr lParam) { if (IsWindowVisible(hWnd) && BrowserUrlReader.IsWindowHandleSupportedBrowser(hWnd)) { sTopLevelBrowserWindowHandles.Add(hWnd); } return(true); }
/// <summary> /// Gets the URL from the browser with the current focus. If there is no current focus, falls back on trying to get the active URL from /// the fallback top-level window handle specified. /// /// If the current focus is detected to be in a password field, passwordFieldFocussed is set true. /// </summary> internal static string GetFocusedBrowserUrl(ChromeAccessibilityWinEventHook chromeAccessibility, IntPtr hwnd, out bool passwordFieldFocussed) { var browserUrlReader = BrowserUrlReader.Create(hwnd); if (browserUrlReader is ChromeBrowserUrlReader) { ((ChromeBrowserUrlReader)browserUrlReader).ChromeAccessibilityWinEventHook = chromeAccessibility; } return(browserUrlReader.GetBrowserFocusUrl(out passwordFieldFocussed)); }
/// <summary> /// Gets URLs for all top-level supported browser windows /// </summary> /// <returns></returns> public static IEnumerable <String> GetTopLevelBrowserWindowUrls() { sTopLevelBrowserWindowHandles = new List <IntPtr>(); EnumWindows(EnumWindows, IntPtr.Zero); var urls = new List <String>(sTopLevelBrowserWindowHandles.Count); foreach (var hwnd in sTopLevelBrowserWindowHandles) { var windowUrl = BrowserUrlReader.Create(hwnd).GetWindowUrl(); if (!String.IsNullOrEmpty(windowUrl)) { urls.Add(windowUrl); } } return(urls); }
internal static void GetFocusedBrowserInfo(ChromeAccessibilityWinEventHook chromeAccessibility, out string selectedText, out string url, out string title) { var browserUrlReader = BrowserUrlReader.Create(GetForegroundWindow()); if (browserUrlReader is ChromeBrowserUrlReader) { ((ChromeBrowserUrlReader)browserUrlReader).ChromeAccessibilityWinEventHook = chromeAccessibility; } if (browserUrlReader == null) { selectedText = null; url = null; title = null; } else { url = browserUrlReader.GetBrowserFocusUrlWithInfo(out title, out selectedText); } }
private void AutoType_SequenceQueriesBegin(object sender, SequenceQueriesEventArgs e) { if (!BrowserUrlReader.IsWindowHandleSupportedBrowser(e.TargetWindowHandle)) { return; } bool passwordFieldFocussed = false; string sUrl = WebBrowserUrl.GetFocusedBrowserUrl(mChromeAccessibility, e.TargetWindowHandle, out passwordFieldFocussed); if (!string.IsNullOrEmpty(sUrl)) { lock (mUrlForAutoTypeEvent) { mUrlForAutoTypeEvent[e.EventID] = sUrl; mSkipUserNameForSequence[e.EventID] = passwordFieldFocussed && AutoSkipUserName; } // Ensure starting un-found. mFoundSequence.Remove(e.EventID); } }