Exemplo n.º 1
0
        public void InvokeFileUpload(IHTMLElement HtmlElement)
        {
            HTMLButtonElementEvents_Event htmlButtonEvent = HtmlElement as HTMLButtonElementEvents_Event;

            htmlButtonEvent.onclick += new HTMLButtonElementEvents_onclickEventHandler(() =>
            {
                // have to create thread to run Dialog automation
                Thread FileUploadThread = new Thread(() =>
                {
                    Thread.Sleep(500); // wait just in case File Dialog is not open.
                    System.Diagnostics.Debug.WriteLine("[*] AutoFillFileUploadDialog");

                    // Automate file upload dialog box
                    FileDialogHandler AutomateFileUpload = new FileDialogHandler();
                    AutomateFileUpload.Execute();
                });

                FileUploadThread.SetApartmentState(ApartmentState.STA);
                FileUploadThread.IsBackground = true;
                FileUploadThread.Start();

                return(true);
            });

            HtmlElement.click();
        }
Exemplo n.º 2
0
        public void WebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            //throw new NotImplementedException();
            mshtml.HTMLDocument           doc  = webBrowser.Document as mshtml.HTMLDocument;
            mshtml.IHTMLElementCollection coll = (mshtml.IHTMLElementCollection)(doc.getElementsByTagName("button"));
            mshtml.IHTMLElement           coll_id_start_explorer = (mshtml.IHTMLElement)(doc.getElementById("id_start_explorer"));
            mshtml.IHTMLElement           coll_id_start_dialog   = (mshtml.IHTMLElement)(doc.getElementById("id_start_dialog"));

            // https://codevomit.wordpress.com/2015/06/15/wpf-webbrowser-control-part-2/

            /*
             * foreach (mshtml.IHTMLElement obj in coll)
             * {
             *  HTMLButtonElementEvents_Event htmlButtonEvent = obj as HTMLButtonElementEvents_Event;
             *  htmlButtonEvent.onclick += clickElementHandler;
             * }
             * //*/

            if (coll_id_start_dialog != null)
            {
                HTMLButtonElementEvents_Event htmlButtonEvent = coll_id_start_dialog as HTMLButtonElementEvents_Event;
                htmlButtonEvent.onclick += start_dialog;
            }
            if (coll_id_start_explorer != null)
            {
                HTMLButtonElementEvents_Event htmlButtonEvent = coll_id_start_explorer as HTMLButtonElementEvents_Event;
                htmlButtonEvent.onclick += start_explorer;
            }
        }