Ejemplo n.º 1
0
        public static SUIIE CreateIEWithURL(string URL)
        {
            InternetExplorer ie = new InternetExplorerClass();

            ie.Visible = true;
            SUIWindow ieWin    = new SUIWindow(new IntPtr(ie.HWND));
            SUIIE     instance = new SUIIE(ie);

            instance.ieWin = ieWin;
            Object obj = new Object();

            ie.Navigate(URL, ref obj, ref obj, ref obj, ref obj);
            if (instance.WaitingForLoadComplete())
            {
                instance.IEWin.Maximized = true;
                return(instance);
            }
            return(null);
        }
Ejemplo n.º 2
0
        // Comment out this method and we have an alternative solution.
        //private static SUIIE GetIE()
        //{
        //    Object o = Interaction.CreateObject("Shell.Application.1", null);
        //    IShellDispatch4 shell = (IShellDispatch4)o;
        //    IShellWindows windows = (IShellWindows)shell.Windows();
        //    for (int i = 0; i < windows.Count; i++)
        //    {
        //        Object obj = windows.Item(i);

        //        if (Information.TypeName(obj).Equals("IWebBrowser2"))
        //        {
        //            IWebBrowser2 browser = (IWebBrowser2)obj;
        //            SUIWindow ieWin = new SUIWindow(new IntPtr(browser.HWND));
        //            if (ieWin.WindowText.Contains(IETitleSuffix))
        //            {
        //                SUIIE instance = new SUIIE(browser);
        //                instance.ieWin = ieWin;
        //                return instance;
        //            }
        //        }
        //    }
        //    return null;
        //}

        public static SUIIE WaitingForIEWindow(string IETitle)
        {
            // Interestingly, we cannot catch IE7 window with below logic on Vista
            // without Administrative previlege.
            ShellWindows windows = new ShellWindowsClass();
            int          count   = windows.Count;

            InternetExplorer myIE = null;

            while (myIE == null)
            {
                SUISleeper.Sleep(1000);
                if (windows.Count >= count + 1)
                {
                    foreach (InternetExplorer tmpIE in windows)
                    {
                        if (tmpIE.FullName.EndsWith(IEProcess, true, null))
                        {
                            myIE = tmpIE;
                        }
                    }
                }
            }

            SUIIE ie = new SUIIE(myIE);

            ie.ieWin = new SUIWindow(new IntPtr(myIE.HWND));

            if (ie.WaitingForLoadComplete())
            {
                //If the specified title is a null string, we will return the default IE window we find.
                if (IETitle == null || ie.IEWin.WindowText.Equals(IETitle + SUIIE.IETitleSuffix))
                {
                    ie.IEWin.Maximized = true;
                    return(ie);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        // Comment out this method and we have an alternative solution.
        //private static SUIIE GetIE()
        //{
        //    Object o = Interaction.CreateObject("Shell.Application.1", null);
        //    IShellDispatch4 shell = (IShellDispatch4)o;
        //    IShellWindows windows = (IShellWindows)shell.Windows();
        //    for (int i = 0; i < windows.Count; i++)
        //    {
        //        Object obj = windows.Item(i);

        //        if (Information.TypeName(obj).Equals("IWebBrowser2"))
        //        {
        //            IWebBrowser2 browser = (IWebBrowser2)obj;
        //            SUIWindow ieWin = new SUIWindow(new IntPtr(browser.HWND));
        //            if (ieWin.WindowText.Contains(IETitleSuffix))
        //            {
        //                SUIIE instance = new SUIIE(browser);
        //                instance.ieWin = ieWin;
        //                return instance;
        //            }
        //        }
        //    }
        //    return null;
        //}  

        public static SUIIE WaitingForIEWindow(string IETitle)
        {
            // Interestingly, we cannot catch IE7 window with below logic on Vista
            // without Administrative previlege.
            ShellWindows windows = new ShellWindowsClass();
            int count = windows.Count;

            InternetExplorer myIE = null;
            while (myIE == null)
            {
                SUISleeper.Sleep(1000);
                if (windows.Count >= count + 1)
                {
                    foreach (InternetExplorer tmpIE in windows)
                    {
                        if (tmpIE.FullName.EndsWith(IEProcess, true, null))
                        {
                            myIE = tmpIE;
                        }
                    }
                }
            }

            SUIIE ie = new SUIIE(myIE);
            ie.ieWin = new SUIWindow(new IntPtr(myIE.HWND));

            if (ie.WaitingForLoadComplete())
            {
                //If the specified title is a null string, we will return the default IE window we find.
                if (IETitle == null || ie.IEWin.WindowText.Equals(IETitle + SUIIE.IETitleSuffix))
                {
                    ie.IEWin.Maximized = true;
                    return ie;
                }
            }
            return null;
        }
Ejemplo n.º 4
0
 public static SUIIE CreateIEWithURL(string URL)
 {
     InternetExplorer ie = new InternetExplorerClass();
     ie.Visible = true;
     SUIWindow ieWin = new SUIWindow(new IntPtr(ie.HWND));
     SUIIE instance = new SUIIE(ie);
     instance.ieWin = ieWin;
     Object obj = new Object();
     ie.Navigate(URL, ref obj, ref obj, ref obj, ref obj);
     if (instance.WaitingForLoadComplete())
     {
         instance.IEWin.Maximized = true;
         return instance;
     }
     return null;
 }