Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.webBrowser1.ReadyState == WebBrowserReadyState.Loading ||
                this.webBrowser1.ReadyState == WebBrowserReadyState.Uninitialized)
            {
                MessageBox.Show("Please wait for RadEditor to load first.");
                return;
            }

            //Register a script function to extract editor's html
            string jsFunction = @"
            function GetEditorHtml()
            {
                return RadEditor1.GetHtml(true);
            }";

            IHTMLDocument doc1         = (IHTMLDocument)this.webBrowser1.Document.DomDocument;
            HTMLWindow2   iHtmlWindow2 = (HTMLWindow2)doc1.Script;

            //register
            iHtmlWindow2.execScript(jsFunction, "javascript");

            //call the function to get editor's text
            try
            {
                object res = this.webBrowser1.Document.InvokeScript("GetEditorHtml");
                MessageBox.Show(res == null ? "null" : res.ToString(), this.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "RadEditor's text: " + this.Text);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// javascript で記述されたスクリプトを実行します。
 /// </summary>
 /// <param name="code">実行するコードを指定します。</param>
 public void exec(string code)
 {
     try{
         win.execScript(code, "javascript");
     }catch {
         System.Windows.Forms.MessageBox.Show("スクリプトの実行中にエラーが発生しました。");
     }
 }
Ejemplo n.º 3
0
        public static void MonitorIE()
        {
            IntPtr fgWin = GetForegroundWindow();
            //When IE is the active window
            var fgWinClass = GetWindowClassName(fgWin);

            if (fgWinClass != "IEFrame" && fgWinClass != "Internet Explorer_TridentDlgFrame")
            {
                OnIEActive?.Invoke(false);
                return;
            }
            OnIEActive?.Invoke(true);

            if (!Scriptlets.Any(o => !o.Disabled))
            {
                return;
            }

            IEHtmlDocs.Clear();
            var hWnd = desktopHwnd;

            EnumChildWindows(hWnd, enumIE, ref hWnd);
            IEHtmlDocs.ToList()
            .ForEach(o =>
            {
                var url = o.Item1;
                var doc = o.Item2;
                Scriptlets.Where(s => !s.Disabled).ToList().ForEach(s =>
                {
                    try
                    {
                        if (Regex.IsMatch(url, s.UrlMatch))
                        {
                            doc.body.setAttribute(ChkAttr, "Y");
                            OnScriptInject?.Invoke(s.UrlMatch);
                            HTMLWindow2 win = (HTMLWindow2)doc.Script;
                            win.execScript(s.Script, "javascript");
                            DisplayStatus?.Invoke($"Inject [{s.Name}]...");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Script Error: " + ex.Message);
                    }
                });
            });
        }