コード例 #1
0
        /// <summary>
        /// 给JS注入事件
        /// </summary>
        /// <param name="webBrowser">webBrowser对象</param>
        /// <param name="eventName">JS事件名称</param>
        /// <param name="objects">对象组</param>
        public static void AsyncInvokeJavaScript(System.Windows.Forms.WebBrowser webBrowser, string eventName, object[] objects)
        {
            LogHelper.WriteMethodLog(true);
            try
            {
                Application.Current.Dispatcher.Invoke(new System.Action(() =>
                {
                    if (!webBrowser.IsDisposed)
                    {
                        webBrowser?.Document?.InvokeScript(eventName, objects);
                        AppSettings.mainForm?.Focus();
                        AppSettings.mainForm?.Activate();
                        webBrowser?.Focus();
                    }
                    //System.Windows.Forms.Application.DoEvents();
                }));
            }
            catch (System.Exception ex)
            {
                LogHelper.WriteErrorInfoLog(ex.Message, ex);
            }


            LogHelper.WriteMethodLog(false);
        }
コード例 #2
0
        /// <summary>
        /// 给JS注入事件
        /// </summary>
        /// <param name="webBrowser">webBrowser对象</param>
        /// <param name="eventName">JS事件名称</param>
        /// <param name="objects">对象组</param>
        public static void InvokeJavaScript(System.Windows.Forms.WebBrowser webBrowser, string eventName, object[] objects)
        {
            LogHelper.WriteMethodLog(true);
            try
            {
                webBrowser.Document.InvokeScript(eventName, objects);

                AppSettings.mainForm.Focus();
                AppSettings.mainForm.Activate();
                webBrowser.Focus();
                //System.Windows.Forms.Application.DoEvents();
            }
            catch (System.Exception ex)
            {
                LogHelper.WriteErrorInfoLog(ex.Message, ex);
            }
            LogHelper.WriteMethodLog(false);
        }
コード例 #3
0
 public void FocusOutput()
 {
     renderer.Focus();
 }