private void changeWindow(object sender, EventArgs e) { try { SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows(); IntPtr handle = GetForegroundWindow(); foreach (SHDocVw.WebBrowser IE in shellWindows) { if (IE.HWND.Equals(handle.ToInt32())) { doc = IE.Document as mshtml.HTMLDocument; } } if (doc != null) { // Document 속성 읽기 Uri uri = new Uri(doc.url); String host = uri.Host; if (host != currentHost) { currentHost = host; if (host.Contains(youtube)) { InternetY dlg = new Renewal.InternetY(); dlg.Show(); timer.Stop(); } else if (host.Contains(facebook)) { } } } } catch { Console.WriteLine("change window err"); MainWindow.isInternet = false; timer.Stop(); this.Close(); } }
private void Youtube_Click(object sender, RoutedEventArgs e) { SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows(); IntPtr handle = GetForegroundWindow(); foreach (SHDocVw.WebBrowser IE in shellWindows) { if (IE.HWND.Equals(handle.ToInt32())) { if (!IE.Busy) { IE.Navigate("www.youtube.com"); } InternetY dlg = new Renewal.InternetY(); dlg.Show(); this.Close(); } } }
private void Internet_Click(object sender, RoutedEventArgs e) { try { InternetExplorer ie = new InternetExplorer(); IWebBrowserApp webBrowser = ie; webBrowser.Visible = true; webBrowser.GoHome(); IWebBrowserApp wb = (IWebBrowserApp)ie; wb.Visible = true; wb.GoHome(); internetCount++; } catch { System.Windows.MessageBox.Show("internet connect"); } //인터넷 최대화 단축키 keybd_event(0x5B, 0, 0, 0); // window key keybd_event(0x26, 0, 0, 0); // arrow up key keybd_event(0x5B, 0, 0x0002, 0); keybd_event(0x26, 0, 0x0002, 0); if (isInternet == false) { SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows(); IntPtr handle = GetForegroundWindow(); foreach (SHDocVw.WebBrowser IE in shellWindows) { if (IE.HWND.Equals(handle.ToInt32())) { while (IE.Busy == true || IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { System.Threading.Thread.Sleep(100); } try { doc = IE.Document as mshtml.HTMLDocument; } catch { System.Windows.MessageBox.Show("err"); } } } if (doc != null) { Uri uri = new Uri(doc.url); String host = uri.Host; if (host.Contains(youtube)) { InternetY dlg = new Renewal.InternetY(); dlg.Show(); //isInternetY = true; } else if (host.Contains(facebook)) { } else // naver, daum, google etc. (default) { Internet dlg = new Renewal.Internet(); dlg.Show(); isInternet = true; } } else { System.Windows.MessageBox.Show("Internet open error"); } } }