/// <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); }
/// <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); }
public void FocusOutput() { renderer.Focus(); }