public BABLanguageSwitcher(InternetBrowser ib) { browser = ib; uiProcess = new InternetBrowserData(ib); //windowWatcher = new SystemProcessHookForm(); //enabledChanged += BABLanguageSwitcher_enabledChanged; }
public WebSkypeSwitcher(InternetBrowserData ibData, Keys switchBind, List <GBC_KeyModifier> modifiers, GBC.BindMethod bindMethod, GBC.HookBehaviour hBehaviour) { //initialize webSkypeStruct = new WebSkypeStruct(); threadHwnd = IntPtr.Zero; browserData = ibData; //if(browserData.BrowserName == InternetBrowser.GoogleChrome) //Create var kvp = new List <KeyValuePair <GBC_KeyModifier, Action> >(); Action bindAction = BindAction; foreach (GBC_KeyModifier mod in modifiers) { kvp.Add(new KeyValuePair <GBC_KeyModifier, Action>(mod, BindAction)); } controller = new GBC(switchBind, GBC.BindMethod.RegisterHotKey, GBC.HookBehaviour.Replacement, kvp); atInstance = AltTabSimulator.Instance; }
/// <summary> /// Calls a similar method depending on browser type /// </summary> /// <param name="wSkype"></param> /// <param name="browserData"></param> private void WebSkypeStructRefresh(ref WebSkypeStruct wSkype, InternetBrowserData browserData) { switch (browserData.Browser) { case InternetBrowser.GoogleChrome: GoogleChromeSet.WebSkypeStructRefresh(ref webSkypeStruct, browserData); break; case InternetBrowser.Opera: OperaSet.WebSkypeStructRefresh(ref webSkypeStruct, browserData); break; case InternetBrowser.Firefox: //FirefoxSet.WebSkypeStructRefresh(ref webSkypeStruct, browserData); break; case InternetBrowser.TorBrowser: //TorBrowserSet.WebSkypeStructRefresh(ref webSkypeStruct, browserData); break; } }
private void WebSkypeCallback(InternetBrowserData data) { switch (data.Browser) { case InternetBrowser.GoogleChrome: GoogleChrome(data); break; case InternetBrowser.Firefox: Firefox(data); break; case InternetBrowser.Opera: Opera(data); break; case InternetBrowser.TorBrowser: TorBrowser(data); break; } }
private void TorBrowser(InternetBrowserData ibData) { }
private void Opera(InternetBrowserData ibData) { IntPtr initialForeground; string windowName = ""; List <IntPtr> rootWindowsChrome = new List <IntPtr>(); try { if (ibData.Process == null) { return; } initialForeground = Interop.GetForegroundWindow(); // check if skype tab or toggle window exists if (webSkypeStruct.windowHandle == IntPtr.Zero || OperaSet.WebSkypeIsNullOrEmpty(webSkypeStruct)) { if (!OperaSet.WebSkypeStructRefresh(ref webSkypeStruct, ibData)) { return; } } AutomationElement operaAE = AutomationElement.FromHandle(webSkypeStruct.windowHandle); windowName = operaAE.Current.Name; if (windowName.Contains("Skype - Opera") && Tools.WebSkypeOrNotifyWindowHandle(initialForeground, webSkypeStruct.windowHandle)) { Tools.RestoreMinimizedWindow(webSkypeStruct.windowHandle); Interop.SetForegroundWindow(webSkypeStruct.windowHandle); return; } if (windowName.Contains("Skype - Opera") && initialForeground != webSkypeStruct.windowHandle) { if (atInstance.TabOrWindow == SwitchTo.Window) { Interop.SetForegroundWindow(atInstance.AltTabList[1]); //its a previus window in a list Tools.RestoreMinimizedWindow(atInstance.AltTabList[1]); } //do nothing, we have an extension to switch between tabs //ok just !(simulate mouse click) send ctrl+tab in to space if (atInstance.TabOrWindow == SwitchTo.Tab) { Interop.PostMessage(webSkypeStruct.windowHandle, Const.WM_KEYDOWN, (IntPtr)WindowsVirtualKey.VK_CONTROL, (IntPtr)0x001D0001); Interop.PostMessage(webSkypeStruct.windowHandle, Const.WM_KEYDOWN, (IntPtr)WindowsVirtualKey.VK_TAB, (IntPtr)0x000F0001); Interop.PostMessage(webSkypeStruct.windowHandle, Const.WM_KEYUP, (IntPtr)WindowsVirtualKey.VK_TAB, (IntPtr)0xC00F0001); Interop.PostMessage(webSkypeStruct.windowHandle, Const.WM_KEYUP, (IntPtr)WindowsVirtualKey.VK_CONTROL, (IntPtr)0xC01D0001); } return; } //situation if process is not foreground, and/or skype tab is not active //cant get SelectionItemPattern - http://stackoverflow.com/questions/22747613/control-pattern-availability-is-set-to-true-but-returns-unsupported-pattern-e //than simulate mouse click ! Tools.RestoreMinimizedWindow(webSkypeStruct.windowHandle); Interop.SetForegroundWindow(webSkypeStruct.windowHandle); if (Tools.FullscreenProcess(webSkypeStruct.windowHandle)) { Interop.PostMessage(initialForeground, Const.WM_KEYDOWN, (IntPtr)WindowsVirtualKey.VK_ESCAPE, IntPtr.Zero); Interop.PostMessage(initialForeground, Const.WM_KEYUP, (IntPtr)WindowsVirtualKey.VK_ESCAPE, IntPtr.Zero); Thread.Sleep(50); // пауза ( на быстрых пк не успевает свернуться интерфейс, а условие необходимо для клика мыши по вкладке } Tools.SimulateClickUIAutomation(webSkypeStruct.skypeTab, operaAE, webSkypeStruct.windowHandle); if (initialForeground != webSkypeStruct.windowHandle) { if (!Tools.NotWebSkypeButNotifyWindowHandle(initialForeground, webSkypeStruct.windowHandle)) { Thread.Sleep(100); //задержка, для того, чтобы успел сработать обработчик события, который среагирует на переключение вкладки atInstance.TabOrWindow = SwitchTo.Window; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { //testWatchTime = testWatch.Elapsed; //testWatch.Stop(); //Console.WriteLine(testWatchTime.ToString()); Thread.Sleep(50); threadHwnd = IntPtr.Zero; } }
private void Firefox(InternetBrowserData ibData) { }