public InternetExplorerTab(string title, SHDocVw.InternetExplorer ie)
			: base(title)
		{
			_ie = ie;
		}
Ejemplo n.º 2
0
 public IETabWindow( SHDocVw.InternetExplorer tab )
     : base(new IntPtr(tab.HWND))
 {
     this.title = tab.LocationName + " - Internet Explorer";
     this.ie = tab;
     Console.Write(this.handle);
 }
        public HTMLEvents(IGenerator builder, object i, SHDocVw.InternetExplorer browser)
        {

            ie = browser;
            document = (IHTMLDocument2)i;
            _builder = builder;
            ConnectToHtmlEvents();
            //_builder.OnAfterWriteCommand+=new OnAfterGenerateCommandEventHandler(processCommand);
            //_uiHandler = uiHandler;
            //_builder.OnFinishedWritingBatchOfCommands+=new EventHandler(updateUI);

        }
Ejemplo n.º 4
0
		private void InitIEAndStartDialogWatcher(SHDocVw.InternetExplorer internetExplorer, Uri uri)
		{
			ie = internetExplorer;

			// Due to UAC in Vista the navigate has to be done
			// before showing the new Internet Explorer instance
			if (uri != null)
			{
				navigateTo(uri);
			}
			ie.Visible = Core.Settings.MakeNewIeInstanceVisible;
			StartDialogWatcher();
		}
Ejemplo n.º 5
0
		private void InitIEAndStartDialogWatcher(SHDocVw.InternetExplorer internetExplorer)
		{
			InitIEAndStartDialogWatcher(internetExplorer, null);
		}
Ejemplo n.º 6
0
	public virtual void ExecWB (SHDocVw.OLECMDID cmdID, SHDocVw.OLECMDEXECOPT cmdexecopt, ref object pvaIn, ref object pvaOut);
Ejemplo n.º 7
0
	public virtual SHDocVw.OLECMDF QueryStatusWB (SHDocVw.OLECMDID cmdID);
		//public WebBrowserEvents(InternetExplorer _intExp, ref SWATWikiGenerator _write)
		//{
		//    _writer = _write;

		//    Random rand = new Random();
		//    browserId = rand.Next(100000);

		//    if (_intExp == null)
		//    {
		//        manualNavigation = true;
		//        ie = new InternetExplorerClass();
		//        //add a property for identification
		//        ie.PutProperty("ID", browserId);
		//        ie.Visible = true;
		//        object url = "about:blank";
		//        object nullObj = String.Empty;
		//        ConnectWindow(ie);
		//        ie.Navigate2(ref url, ref nullObj, ref nullObj, ref nullObj, ref nullObj);
		//        HTMLEvents.lastBrowser = browserId;
		//    }
		//    else
		//    {
		//        manualNavigation = false;
		//        ie = _intExp;
		//        ie.PutProperty("ID", browserId);
		//        ConnectWindow(ie);
		//    }


		//}


		public WebBrowserEvents(String flag, SHDocVw.InternetExplorer _intExp, ref SWATWikiGenerator _write)
		{
			_writer = _write;
			Random rand = new Random();
			browserId = rand.Next(100000);

			if (flag.Equals("AttachToWindow"))
			{
				init = false;
				manualNavigation = false;
				ie = _intExp;
				ie.PutProperty("ID", browserId);
				ConnectWindow(ie);
				//Debug.WriteLine((((HTMLDocument)ie.Document).frames).length);
				try
				{
					FramesCollection frames = (((HTMLDocument)ie.Document).frames);

					for (int i = 0; i < frames.length; i++)
					{
						object refIndex = i;
						try
						{
							HTMLDocument doc = (HTMLDocument)((HTMLWindow2Class)frames.item(ref refIndex)).document;
							if (doc.Equals((HTMLDocument)ie.Document)) continue;
							HTMLEvents aEvent = new HTMLEvents(_writer, doc, ie);
							_eventsList.Add(aEvent);
						}
						catch (UnauthorizedAccessException) { }
					}
				}
				catch (Exception) { }
				_eventsList.Insert(0, new HTMLEvents(_writer, ie.Document, ie));
				checkAttach();
			}
			else if (flag.Equals("NewWindow"))
			{
				manualNavigation = true;
				ie = new InternetExplorerClass();
				//add a property for identification
				ie.PutProperty("ID", browserId);
				ie.Visible = true;
				object url = "about:blank";
				object nullObj = String.Empty;
				ConnectWindow(ie);
				ie.Navigate2(ref url, ref nullObj, ref nullObj, ref nullObj, ref nullObj);
				HTMLEvents.lastBrowser = browserId;
			}
			else if (flag.Equals("PopUp"))
			{
				manualNavigation = false;
				ie = _intExp;
				ie.PutProperty("ID", browserId);
				ConnectWindow(ie);
			}
			else if (flag.Equals("AttachToModalWindow"))
			{
				IntPtr dialogHwnd = IntPtr.Zero;
				//int indexCount = NativeMethods.GetWindowWithSubstring("content.html", 0, 0, ref dialogHwnd);
				dialogHwnd = NativeMethods.GetForegroundWindow();


				if (dialogHwnd != IntPtr.Zero)
				{
					// This block of code SHOULD take a window handle and return an IHTMLDocument object to dialogDoc
					// Then it will assign that object to _doc. It follows an example in the MSDN library and WatiN uses it as well.
					// If it performs correctly, then we should be attached to the Dialog.
					dialogHwnd = NativeMethods.GetChildWindowHwnd(dialogHwnd, "Internet Explorer_Server");
					//dialogHwnd = NativeMethods.GetForegroundWindow();

					Int32 result = 0;
					Int32 dialog;
					Int32 message;

					message = NativeMethods.RegisterWindowMessage("WM_HTML_GETOBJECT");
					NativeMethods.SendMessageTimeout(dialogHwnd, message, 0, 0, NativeMethods.SMTO_ABORTIFHUNG, 1000, ref result);

					//NativeMethods.SendMessage(dialogHwnd, NativeMethods.WM_CLOSE, 0, 0);

					IHTMLDocument2 dialogDoc = null;
					System.Guid dialogID = typeof(mshtml.HTMLDocument).GUID;
					dialog = NativeMethods.ObjectFromLresult(result, ref dialogID, 0, ref dialogDoc);

					//HTMLFrameBase dialogDoc = null;
					//System.Guid dialogID = typeof(mshtml.HTMLFrameBase).GUID;
					//dialog = NativeMethods.ObjectFromLresult(result, ref dialogID, 0, ref dialogDoc);

					//dialogDoc.title = "Hello?";

					//IHTMLDialog dialogDoc = null;
					//System.Guid dialogID = typeof(mshtml.HTMLDialog).GUID;
					//dialog = NativeMethods.ObjectFromLresult(result, ref dialogID, 0, ref dialogDoc);




					//IHTMLWindow2 dialogDoc = null;
					//System.Guid dialogID = typeof(IHTMLWindow2).GUID;
					//dialog = NativeMethods.ObjectFromLresult(result, ref dialogID, 0, ref dialogDoc);

					//dialogDoc.close();

					//Console.WriteLine("URL: " + dialogDoc.close + "\nTitle: " + dialogDoc.title);

					//ie = (InternetExplorer)dialogDoc;
					//ie.PutProperty("ID", browserId);
					//ConnectWindow(ie);

					//doc = (HTMLDocument)dialogDoc;



				}
			}
			_browserList.Add(this);

		}
Ejemplo n.º 9
0
 private void UnHookForEventNewWindow( SHDocVw.DWebBrowserEvents_Event webBrowserEvents, SHDocVw.DWebBrowserEvents2_Event webBrowserEvents2 )
 {
     webBrowserEvents2.NewWindow3 -= new SHDocVw.DWebBrowserEvents2_NewWindow3EventHandler( webBrowserEvents2_NewWindow3 );
 }
Ejemplo n.º 10
0
 private void UnHookForEventNavigateComplete2( SHDocVw.DWebBrowserEvents_Event webBrowserEvents, SHDocVw.DWebBrowserEvents2_Event webBrowserEvents2 )
 {
     _wpfWebBrowser.Navigated -= new System.Windows.Navigation.NavigatedEventHandler( wpfWebBrowser_Navigated );
 }
Ejemplo n.º 11
0
 private void UnHookForEventNavigateError( SHDocVw.DWebBrowserEvents_Event webBrowserEvents, SHDocVw.DWebBrowserEvents2_Event webBrowserEvents2 )
 {
     webBrowserEvents2.NavigateError -= new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler( webBrowserEvents2_NavigateError );
 }
Ejemplo n.º 12
0
 private void UnHookForEventDownloadComplete( SHDocVw.DWebBrowserEvents_Event webBrowserEvents, SHDocVw.DWebBrowserEvents2_Event webBrowserEvents2 )
 {
     webBrowserEvents2.DownloadComplete -= new SHDocVw.DWebBrowserEvents2_DownloadCompleteEventHandler( webBrowserEvents2_DownloadComplete );
 }
Ejemplo n.º 13
0
 private void UnHookForEventPageLoadProgressUpdate( SHDocVw.DWebBrowserEvents_Event webBrowserEvents, SHDocVw.DWebBrowserEvents2_Event webBrowserEvents2 )
 {
     webBrowserEvents2.ProgressChange -= new SHDocVw.DWebBrowserEvents2_ProgressChangeEventHandler( webBrowserEvents2_ProgressChange );
 }
Ejemplo n.º 14
0
 private void UnHookForEventDownloadBegin( SHDocVw.DWebBrowserEvents_Event webBrowserEvents, SHDocVw.DWebBrowserEvents2_Event webBrowserEvents2 )
 {
     webBrowserEvents2.DownloadBegin -= new SHDocVw.DWebBrowserEvents2_DownloadBeginEventHandler( webBrowserEvents2_DownloadBegin );
 }
        /// <summary>
        /// Determines if an InternetExplorer browser's title matches the specified string.
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="windowTitle"></param>
        /// <returns> true if the windowTitle parameter matches the brower parameter's window title; otherwise, false. </returns>
        private bool browserTitleIsMatch(SHDocVw.InternetExplorer browser, string windowTitle)
        {
            IHTMLDocument2 doc = browser.Document as IHTMLDocument2;

            return (doc != null && // Check if the html document is even accessible
                doc.title.ToLower().Contains(windowTitle)// Check if the document title matches
                        || browser.LocationName.ToLower().Contains(windowTitle)); // check the location name (used for PDFs and "about:blank")
        }
		/**
		 * Event handlers
		 **/
		void ConnectWindow(SHDocVw.InternetExplorer webBrowser)
		{

			resetEvents = false;
			//timer used for resetting events
			timer = new Timer();
			timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
			timer.Enabled = true;
			timer.AutoReset = false;

			webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(ie_DocumentComplete);
			webBrowser.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(webBrowser_BeforeNavigate2);
			webBrowser.NavigateComplete2 += new DWebBrowserEvents2_NavigateComplete2EventHandler(webBrowser_NavigateComplete2);
			webBrowser.OnQuit += new DWebBrowserEvents2_OnQuitEventHandler(webBrowser_OnQuit);
			webBrowser.NewWindow3 += new DWebBrowserEvents2_NewWindow3EventHandler(webBrowser_NewWindow3);
		}
Ejemplo n.º 17
0
 private InternetExplorer(SHDocVw.InternetExplorer browser)
     : base(Application.Attach(new IntPtr(browser.HWND), false))
 {
     _browser = browser;
     _zoneId = NativeMethods.GetZoneId(_browser.LocationURL);
 }
Ejemplo n.º 18
0
        public bool searchBroswer(SHDocVw.WebBrowser wb, string keyword)
        {
            HTMLDocument document = ((HTMLDocument)wb.Document);
            currentDoc = document;
            IHTMLElement element = document.getElementById("q");
            HTMLInputElement searchKW = (HTMLInputElement)element;
            //HTMLInputElementClass searchKW = (HTMLInputElementClass)element;
            searchKW.value = keyword;

            //Point docHeight = new Point(document.body.offsetLeft, document.body.offsetTop);
            //ClientToScreen((IntPtr)wb.HWND, ref docHeight);
            //var rectDoc = document.body.getBoundingClientRect();
            //RECT rct;

            //if (!GetWindowRect((IntPtr)element.HWND, out rct))
            //{
            //    MessageBox.Show("ERROR");
            //    return false;
            //}
            var elements = document.getElementsByTagName("button");
            foreach (HTMLButtonElement searchBTN in elements)
            {
                // If there's more than one button, you can check the
                //element.InnerHTML to see if it's the one you want
                if (searchBTN.innerHTML.Contains("搜 索"))
                {
                    int randX = rndGenerator.Next(0, searchBTN.offsetWidth-1);
                    int randY = rndGenerator.Next(0, searchBTN.offsetHeight-1);

                    var rect = searchBTN.getBoundingClientRect();
                    Point p = new Point(rect.left + randX, rect.top + randY);

                    ClientToScreen((IntPtr)wb.HWND, ref p);
                    //p = this.PointToScreen(p);
                    SetCursorPos(p.X, p.Y);

                    //Thread.Sleep(6000);
                    searchBTN.click();
                    break;
                }
            }

            while (wb.Busy) { Thread.Sleep(100); }

            HTMLAnchorElement foundAnchorEle = null;
            var linkElements = document.getElementsByTagName("a");
            foreach (HTMLAnchorElement linkEle in linkElements)
            {
                // If there's more than one button, you can check the
                //element.InnerHTML to see if it's the one you want
                if (linkEle.innerText == null)
                {
                    continue;
                }
                if (linkEle.innerText.Contains(sellerNameTB.Text.Trim()))
                {
                    //int randX = rndGenerator.Next(0, searchBTN.offsetWidth - 1);
                    //int randY = rndGenerator.Next(0, searchBTN.offsetHeight - 1);

                    //var rect = searchBTN.getBoundingClientRect();
                    //Point p = new Point(rect.left + randX, rect.top + randY);

                    //ClientToScreen((IntPtr)wb.HWND, ref p);
                    ////p = this.PointToScreen(p);
                    //SetCursorPos(p.X, p.Y);

                    ////Thread.Sleep(6000);
                    //searchBTN.click();
                    foundAnchorEle = linkEle;
                    break;
                }
            }

            if (foundAnchorEle == null)
            {
                return false;
            }
            //if found first scroll the page
            if (compareCB.Checked == true)
            {
                //货比三家
                randVisitOther(document);
            }

            #region

            //search load

            #endregion
            Thread.Sleep(1000);
            return true;
        }