public void SetWebProcesses(List <string> good, List <string> bad, string browser) { if (browser.Equals("chrome")) { browserHandler = new ChromeHandler(); } else if (browser.Equals("firefox")) { browserHandler = new FirefoxHandler(); } else { browserHandler = null; } workingProcesses.AddRange(good.Select(p => new DesktopProcess { Name = browserHandler.BrowserProcessName, PostFix = p })); slackingProcesses.AddRange(bad.Select(p => new DesktopProcess { Name = browserHandler.BrowserProcessName, PostFix = p })); }
public override string ExtractUrl(Process pr) { AutomationElement elm = AutomationElement.FromHandle(pr.MainWindowHandle); var e = elm.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); if (e == null) { return("youtube.com"); } var patterns = e.GetSupportedPatterns(); if (patterns.Length > 0) { foreach (var p in patterns) { ValuePattern val = (ValuePattern)e.GetCurrentPattern(p); return(string.IsNullOrEmpty(val.Current.Value) ? string.Empty : BrowserHandler.TrimToMainUrl(val.Current.Value)); } } return(string.Empty); }