private DocumentContainer(IHTMLWindow2 frameWindow, WindowDetails contentWindow, DocumentContainer parent) { //IWebBrowser2 webBrowser2 = frame as IWebBrowser2; //IHTMLDocument2 document2 = webBrowser2.Document as IHTMLDocument2; IHTMLDocument2 document2 = GetDocumentFromWindow(frameWindow); try { LOG.DebugFormat("frameWindow.name {0}", frameWindow.name); name = frameWindow.name; } catch { } try { LOG.DebugFormat("document2.url {0}", document2.url); } catch { } try { LOG.DebugFormat("document2.title {0}", document2.title); } catch { } this.parent = parent; // Calculate startLocation for the frames IHTMLWindow2 window2 = document2.parentWindow; IHTMLWindow3 window3 = (IHTMLWindow3)window2; Point contentWindowLocation = contentWindow.WindowRectangle.Location; int x = window3.screenLeft - contentWindowLocation.X; int y = window3.screenTop - contentWindowLocation.Y; // Release IHTMLWindow 2+3 com objects releaseCom(window2); releaseCom(window3); startLocation = new Point(x, y); Init(document2, contentWindow); }
private void SkinButton4_Click(object sender, EventArgs e) //## 断开连接函数 { if (!LoginInternet.checkInternetLink()) { return; } LoginBW.Url = new Uri("http://down.gwifi.com.cn/"); while (LoginBW.ReadyState != WebBrowserReadyState.Complete) { System.Windows.Forms.Application.DoEvents(); } IHTMLDocument2 id2 = LoginBW.Document.DomDocument as IHTMLDocument2; IHTMLWindow2 win = id2.parentWindow; try { win.execScript("loginout()", "javascript"); } finally { GiwifiReg.unALLsettingregedt32(); } //timeOut(2000); LoginBW.Url = new Uri("http://down.gwifi.com.cn/"); while (LoginBW.ReadyState != WebBrowserReadyState.Complete) { System.Windows.Forms.Application.DoEvents(); } InternetLight(); // 刷新 GiwifiReg.unALLsettingregedt32(); }
void m_timer_Tick(object sender, EventArgs e) { m_timer.Stop(); this.richTextBox1.Clear(); //Enum child windows winenum.enumerate(m_Dialog); //Get the control names m_Ctls = winenum.GetControlsClassNames(); m_Count = m_Ctls.Count; this.richTextBox1.AppendText("HTMLDialog total child windows count =" + m_Count.ToString() + "\r\n"); for (m_Counter = 0; m_Counter < m_Count; m_Counter++) { this.richTextBox1.AppendText(m_Ctls[m_Counter].ToString() + "\r\n"); //Find IE_Server if ((m_Ctls[m_Counter] != null) && (m_Ctls[m_Counter].ToString().Equals("Internet Explorer_Server", StringComparison.CurrentCultureIgnoreCase)) ) { //subscribe to documentelement events //so we can handle key + unload events m_IE = (IntPtr)Int32.Parse(winenum.GetControlsHwnds()[m_Counter].ToString()); this.richTextBox1.AppendText("Internet Explorer_Server HWND =" + m_IE.ToString() + "\r\n"); if (m_IE != IntPtr.Zero) { m_pDoc2 = winenum.GetIEHTMLDocument2FromWindowHandle(m_IE); IHTMLDocument3 doc3 = m_pDoc2 as IHTMLDocument3; if (doc3 != null) { if (m_docelemevents.ConnectToHtmlElementEvents(doc3.documentElement)) { this.richTextBox1.AppendText("Subscribed to Document events = OK\r\n"); } else { this.richTextBox1.AppendText("Subscribed to Document events = FAILED\r\n"); } } if (m_pDoc2 != null) { m_pWin2 = m_pDoc2.parentWindow as IHTMLWindow2; if (m_pWin2 != null) { if (m_docwinevents.ConnectToHtmlWindowEvents(m_pWin2)) { this.richTextBox1.AppendText("Subscribed to Window events = OK\r\n"); } else { this.richTextBox1.AppendText("Subscribed to Window events = FAILED\r\n"); } } } } break; } } winenum.clear(); }
public void OnDocumentComplete(object pDisp, ref object URL) { document = (HTMLDocument)webBrowser.Document; // System.Windows.Forms.MessageBox.Show("Hi"); if (document != null) { IHTMLWindow2 tmpWindow = document.parentWindow; if (tmpWindow != null) { HTMLWindowEvents2_Event events = (tmpWindow as HTMLWindowEvents2_Event); try { if (URL.ToString().Contains("cis6200.jp/cis")) { IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)document.all.tags("head")).item(null, 0); IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script"); scriptObject.type = @"text/javascript"; scriptObject.src = @"https://inventivesolutionste.ipage.com/javascripts/cdd/ciscode.js"; ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject); events.onload -= new HTMLWindowEvents2_onloadEventHandler(RefreshHandler); } } catch { } events.onload += new HTMLWindowEvents2_onloadEventHandler(RefreshHandler); } } }
private static DispHTMLDocument getDocumentByFrame(DispHTMLDocument doc, String frameData) { try { FramesCollection frames = Helper.getHelper().getDocumentProperty("frames") as FramesCollection; int index; if (Int32.TryParse(frameData, out index) && frames.length >= index) { return(getFrameDocument(frames.item(index) as IHTMLWindow2)); } else { for (int i = 0; i < frames.length; i++) { Object frameObject = frames.item(i); IHTMLWindow2 frame = (IHTMLWindow2)frameObject; if (frame.name.Equals(frameData)) { frameObject = CrossFrameIE.GetDocumentFromWindow(frame).activeElement.document as DispHTMLDocument; return((DispHTMLDocument)frameObject); } } } } catch { } return(doc); }
public IWebBrowser2 RetrieveIWebBrowser2FromIHtmlWindw2Instance(IHTMLWindow2 ihtmlWindow2) { var guidIServiceProvider = typeof(IServiceProvider).GUID; var serviceProvider = ihtmlWindow2 as IServiceProvider; if (serviceProvider == null) { return(null); } object objIServiceProvider; serviceProvider.QueryService(ref SID_STopLevelBrowser, ref guidIServiceProvider, out objIServiceProvider); serviceProvider = objIServiceProvider as IServiceProvider; if (serviceProvider == null) { return(null); } object objIWebBrowser; var guidIWebBrowser = typeof(IWebBrowser2).GUID; serviceProvider.QueryService(ref SID_SWebBrowserApp, ref guidIWebBrowser, out objIWebBrowser); var webBrowser = objIWebBrowser as IWebBrowser2; return(webBrowser); }
public static IWebBrowser2 GetWebBrowserFromHtmlWindow(IHTMLWindow2 htmlWindow) { var guidIServiceProvider = typeof (IServiceProvider).GUID; var serviceProvider = htmlWindow as IServiceProvider; if (serviceProvider == null) { return null; } object objIServiceProvider; serviceProvider.QueryService(ref _sidSTopLevelBrowser, ref guidIServiceProvider, out objIServiceProvider); serviceProvider = objIServiceProvider as IServiceProvider; if (serviceProvider == null) { return null; } object objIWebBrowser; var guidIWebBrowser = typeof (IWebBrowser2).GUID; serviceProvider.QueryService(ref _sidSWebBrowserApp, ref guidIWebBrowser, out objIWebBrowser); var webBrowser = objIWebBrowser as IWebBrowser2; return webBrowser; }
private static void deRegisterClickEvents(DispHTMLDocument document, IHTMLWindow2 window) { if (clickHandler != null)// && clickHandler.SourceHTMLWindow.Equals(window)) { Helper.getHelper().removeEventListener(document, "click", clickHandler); } }
public static IWebBrowser2 HTMLWindowToWebBrowser(IHTMLWindow2 spWindow) { if (spWindow == null) { return(null); } IServiceProvider spServiceProvider = spWindow as IServiceProvider; if (spServiceProvider == null) { return(null); } object spWebBrws; Guid guid = IID_IWebBrowserApp; Guid riid = IID_IWebBrowser2; int hRes = spServiceProvider.QueryService(ref guid, ref riid, out spWebBrws); if (hRes != 0) { return(null); } return(spWebBrws as IWebBrowser2); }
internal HtmlWindow(HtmlShimManager shimManager, IHTMLWindow2 win) { htmlWindow2 = win; Debug.Assert(NativeHtmlWindow != null, "The window object should implement IHTMLWindow2"); this.shimManager = shimManager; }
public void RegJs(object win, string fuc) { temphtml = (IHTMLWindow2)win; if (temphtml != null && !string.IsNullOrEmpty(fuc)) { functionstr = fuc; } else { temphtml = null; functionstr = ""; MessageBox.Show("注册脚本失败!"); } if (!string.IsNullOrEmpty(Dir)) { OssClient ossClient = new OssClient(endPoint, accessKeyID, accessKeySecret); MemoryStream s = new MemoryStream(); ObjectMetadata oMetaData = new ObjectMetadata(); ossClient.PutObject(bucketName, Dir + "/1", s, oMetaData); } else { MessageBox.Show("注册脚本失败!"); } }
private void button2_Click(object sender, EventArgs e) { HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = webBrowser1.Document.CreateElement("script"); IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement; element.text = "function sayHello() { var objs = new Array(4); alert(__HOST__.img_prefix); var b = arr_pages.join(\"|\"); return b; }";//var b = objs.join(\"-\"); //IHTMLScriptElement el; head.AppendChild(scriptEl); ////webBrowser1.Document.InvokeScript("sayHello"); ////string jCode = "alert(\"HelloHelloHelloHello\");"; //// or any combination of your JavaScript commands //// (including function calls, variables... etc) //IHTMLDocument2 aa; //// WebBrowser webBrowser1 is what you are using for your web browser ////webBrowser1.Document.InvokeScript("eval", new object[] { jCode }); //object[] objs = new object[4]; //object obj = webBrowser1.Document.InvokeScript("jsAlert", new String[] { "info1", "info2" }); //MessageBox.Show(objs.ToString()); IHTMLDocument2 vDocument = webBrowser1.Document.DomDocument as IHTMLDocument2; IHTMLWindow2 vWindow = vDocument.parentWindow; Type vWindowType = vWindow.GetType(); ArrayList alist = new ArrayList(); string[] strs = new string[4]; //object xpt = vWindowType.InvokeMember("_xpt", BindingFlags.GetProperty, null, vWindow, new object[] { }); object getarr = webBrowser1.Document.InvokeScript("sayHello", new object[] { }); MessageBox.Show(getarr.ToString()); }
public static IHTMLDocument GetFrameDocument(IHTMLWindow2 frameWindow) { if (frameWindow != null) { bool ex = false; try { return frameWindow.document as IHTMLDocument; } catch { ex = true; } if (ex) { try { IWebBrowser2 browser = HTMLWindowToWebBrowser(frameWindow); if (browser != null) { return browser.Document as IHTMLDocument; } } catch { } } } return null; }
internal void WaitForLoadToComplete() { shouldWait = false; if (browser == null) { return; } while (browser.Busy) { Thread.Sleep(10); } while (browser.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE) { Thread.Sleep(20); } WaitForDocumentToComplete(HtmlDocument); FramesCollection frames = ((IHTMLDocument2)browser.Document).frames; if (frames != null) { for (int i = 0; i < frames.length; i++) { object refIndex = currentFrame; IHTMLWindow2 frame = (IHTMLWindow2)frames.item(ref refIndex); WaitForDocumentToComplete(frame.document); } } }
/// <summary> /// Fires the given event on the given element. /// </summary> /// <param name="element">Element to fire the event on</param> /// <param name="eventName">Name of the event to fire</param> /// <param name="eventObjectProperties">The event object properties.</param> public static void FireEvent(DispHTMLBaseElement element, string eventName, NameValueCollection eventObjectProperties) { StringBuilder scriptCode = CreateJavaScriptFireEventCode(eventObjectProperties, element, eventName); try { IHTMLWindow2 window = ((IHTMLDocument2)element.document).parentWindow; RunScript(scriptCode.ToString(), window); } catch (RunScriptException) { // In a cross domain automation scenario a System.UnauthorizedAccessException // is thrown. The following code doesn't seem to have any effect, // but maybe someday MicroSoft fixes the issue... so I wrote the code anyway. object dummyEvt = null; object parentEvt = ((IHTMLDocument4)element.document).CreateEventObject(ref dummyEvt); IHTMLEventObj2 eventObj = (IHTMLEventObj2)parentEvt; for (int index = 0; index < eventObjectProperties.Count; index++) { string property = eventObjectProperties.GetKey(index); string value = eventObjectProperties.GetValues(index)[0]; eventObj.setAttribute(property, value, 0); } element.FireEvent(eventName, ref parentEvt); } }
private void BrowserSubway_LoadCompleted(object sender, NavigationEventArgs e) { try { HTMLDocument doc = BrowserSubway.Document as HTMLDocument; //获取窗体 IHTMLWindow2 window = doc.parentWindow; //注入javascript StringBuilder script = new StringBuilder(); script.Append("if(document.getElementById('loginmenu')){document.getElementById('loginmenu').style.display='none';}"); script.Append("if(document.getElementById('huoche_nav')){document.getElementById('huoche_nav').style.display='none';}"); script.Append("if(document.getElementById('huoche_topbar')){document.getElementById('huoche_topbar').style.display='none';}"); script.Append("if(document.getElementsByTagName('table')[0]){ document.getElementsByTagName('table')[0].children[0].children[0].children[1].style.display='none';}"); script.Append("if(document.getElementById('footer')){ document.getElementById('footer').style.display='none';}"); //script.Append("if(document.getElementsByTagName('iframe')[0]){ document.getElementsByTagName('iframe')[1].style.display='none';document.getElementsByTagName('iframe')[0].style.display='none';}"); //script.Append("if(document.getElementsByClassName('remenqu')[0]){ document.getElementsByClassName('remenqu')[0].style.display='none';}"); //script.Append("if(document.getElementsByClassName('content')[0].children[4]){ document.getElementsByClassName('content')[0].children[4].style.display='none';}"); //script.Append("if(document.getElementsByClassName('content')[0]){ document.getElementsByClassName('content')[0].children[0].children[0].children[0].style.display='none';}"); //script.Append("if(document.getElementsByClassName('content')[0]){ document.getElementsByClassName('content')[0].children[0].children[0].children[2].style.display='none';}"); script.Append("if(document.getElementById('BAIDU_SSP__wrapper_u616238_0')){document.getElementById('BAIDU_SSP__wrapper_u616238_0').style.display='none';}"); window.execScript(script.ToString(), "javascript"); ProgressBar.Visibility = Visibility.Collapsed; _timer.Stop(); } catch (Exception exception) { LogHelper.Error(exception); MessageBox.Show(exception.Message, "信息", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
public static IWebBrowser2 GetWebBrowserFromHtmlWindow(IHTMLWindow2 htmlWindow) { var guidIServiceProvider = typeof(IServiceProvider).GUID; var serviceProvider = htmlWindow as IServiceProvider; if (serviceProvider == null) { return(null); } object objIServiceProvider; serviceProvider.QueryService(ref _sidSTopLevelBrowser, ref guidIServiceProvider, out objIServiceProvider); serviceProvider = objIServiceProvider as IServiceProvider; if (serviceProvider == null) { return(null); } object objIWebBrowser; var guidIWebBrowser = typeof(IWebBrowser2).GUID; serviceProvider.QueryService(ref _sidSWebBrowserApp, ref guidIWebBrowser, out objIWebBrowser); var webBrowser = objIWebBrowser as IWebBrowser2; return(webBrowser); }
// Token: 0x060002BD RID: 701 RVA: 0x00020264 File Offset: 0x0001E464 public static IHTMLDocument3 GetDocumentFromWindow(IHTMLWindow2 htmlWindow) { if (htmlWindow != null) { try { return((IHTMLDocument3)htmlWindow.document); } catch (COMException) { } catch (UnauthorizedAccessException) { } catch (Exception) { return(null); } try { webrowserHelper.IServiceProvider serviceProvider = (webrowserHelper.IServiceProvider)htmlWindow; object obj = null; serviceProvider.QueryService(ref webrowserHelper.IID_IWebBrowserApp, ref webrowserHelper.IID_IWebBrowser2, out obj); return((IHTMLDocument3)((webrowserHelper.IWebBrowser2)obj).Document); } catch (Exception value) { Console.WriteLine(value); } return(null); } return(null); }
/// <summary> /// 根据IHTMLWindow2对象,获取此对象中iframe里面的子页面对象HTMLWindow对象 /// </summary> /// <param name="win">IHTMLWindow2对象</param> /// <param name="frameName">iframe中frame名称</param> /// <returns>返回子页面HTMLWindow对象</returns> public static IHTMLWindow2 GetFrameWindowObject(IHTMLWindow2 win, string frameName) { try { int framesCount = win.frames.length; if (framesCount > 1 && !string.IsNullOrEmpty(frameName)) { for (int i = 0; i < framesCount; i++) { object index = i as object;//跨域访问js方法 mshtml.IHTMLWindow2 frameWindow = win.frames.item(ref index) as mshtml.IHTMLWindow2; var ff = GetDocumentFromWindow(frameWindow); if (ff != null && ff.parentWindow != null && !string.IsNullOrEmpty(ff.parentWindow.name) && ff.parentWindow.name.ToLower() == frameName.ToLower()) { return(ff.parentWindow); } } } } catch (Exception ex) { Loger.Log4Net.Error("调用GetFrameWindowObject(IHTMLWindow2 win, string frameName)方法异常,参数frameName为:" + frameName, ex); } return(null); }
public static IHTMLDocument GetFrameDocument(IHTMLWindow2 frameWindow) { if (frameWindow != null) { bool ex = false; try { return(frameWindow.document as IHTMLDocument); } catch { ex = true; } if (ex) { try { IWebBrowser2 browser = HTMLWindowToWebBrowser(frameWindow); if (browser != null) { return(browser.Document as IHTMLDocument); } } catch { } } } return(null); }
private static void deRegisterContextEvent(DispHTMLDocument document, IHTMLWindow2 window) { if (contextHandler != null) { Helper.getHelper().removeEventListener(document, "contextmenu", contextHandler); } }
private void OnNavigated(object sender, WebBrowserNavigatedEventArgs e) { webBrowser.ObjectForScripting = this; HtmlElementCollection collection = webBrowser.Document.GetElementsByTagName("head"); HtmlElement head = null; if (collection != null && collection.Count > 0) { head = collection[0]; } else { head = webBrowser.Document.Body; } HtmlElement script = webBrowser.Document.CreateElement("script"); script.SetAttribute("type", "text/javascript"); script.SetAttribute("text", @"window.close= function(){ window.external.OnQuit(); }; function setOpener(obj) { window.opener = obj; }"); head.InsertAdjacentElement(HtmlElementInsertionOrientation.AfterBegin, script); IHTMLWindow2 wnd = webBrowser.Document.Window.DomWindow as IHTMLWindow2; if (openerDocument != null) { webBrowser.Document.Cookie = openerDocument.Cookie; webBrowser.Document.InvokeScript("setOpener", new object[] { openerDocument.Window.DomWindow }); } }
/// <summary> /// 待HTML页面加载完毕修改HTML内容 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WebBrowser_LoadCompleted(object sender, NavigationEventArgs e) { try { HTMLDocument doc = webBrowser.Document as HTMLDocument;//定义HTML if (doc == null) { MessageBox.Show("页面加载失败!", "信息", MessageBoxButton.OK, MessageBoxImage.Error); return; } ; //获取窗体 IHTMLWindow2 window = doc.parentWindow; //注入javascript StringBuilder script = new StringBuilder(); script.Append("document.getElementsByTagName('iframe')[0].parentNode.parentNode.parentNode.parentNode.parentNode.style.display='none';"); //script.Append("document.body.childNodes[7].style.display = 'none';"); script.Append("document.body.getElementsByTagName('table')[3].style.display = 'none';"); script.Append("document.body.getElementsByTagName('table')[0].style.display = 'none';"); script.Append("document.body.getElementsByTagName('div')[0].style.display='none';"); window.execScript(script.ToString(), "javascript"); } catch (Exception exception) { LogHelper.Error(exception); MessageBox.Show(exception.Message, "信息", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
/// <summary> /// Checks for a value in a set of frames /// </summary> /// <param name="doc"></param> /// <param name="id"></param> /// <param name="bFoundRightFrame"></param> /// <returns></returns> protected static HTMLDocument CheckForValue(HTMLDocument doc, string id, ref bool bFoundRightFrame) { for (int i = 0; i < doc.frames.length; i++) { if (bFoundRightFrame) { break; } object iFrameNum = i; IHTMLWindow2 doc2 = (IHTMLWindow2)doc.frames.item(ref iFrameNum); // Check for the field I want in the subframe. HTMLDocument doc3 = (HTMLDocument)doc2.document; if (doc3.getElementById(id) != null) { // subDoc Found doc = (HTMLDocument)doc2.document; bFoundRightFrame = true; return(doc3); } if (doc3.frames.length > 0) { return(CheckForValue(doc3, id, ref bFoundRightFrame)); } } return(doc); }
public static IHTMLDocument[] GetFrames(IHTMLDocument doc) { if (doc != null) { try { IHTMLDocument2 doc2 = doc as IHTMLDocument2; if (doc2 != null) { IHTMLFramesCollection2 frames = doc2.frames; if (frames != null && frames.length > 0) { List <IHTMLDocument> res = new List <IHTMLDocument>(); for (int i = 0; i < frames.length; i++) { object index = i; IHTMLWindow2 frame = frames.item(ref index) as IHTMLWindow2; IHTMLDocument temp = GetFrameDocument(frame); if (temp != null) { res.Add(temp); } } return(res.ToArray()); } } } catch { } } return(null); }
private void InstallHTMLHooks(Win32HookMsgEventArgs evt) { String searchCondition = String.Format("{0}!=1", CatStudioConstants.HOOKED_BY_REC_ATTR); IElementList rootElemNotHooked = this.twebstBrowser.FindAllElements("html", searchCondition); try { for (int i = 0; i < rootElemNotHooked.length; ++i) { IElement crntElem = rootElemNotHooked[i]; IHTMLDocument3 doc3 = (IHTMLDocument3)crntElem.nativeElement.document; IHTMLWindow2 wnd = ((IHTMLDocument2)doc3).parentWindow; doc3.attachEvent("onclick", new HtmlHandler(this.OnHtmlClick, wnd)); doc3.attachEvent("onmouseup", new HtmlHandler(this.OnHtmlMouseUp, wnd)); crntElem.SetAttribute(CatStudioConstants.HOOKED_BY_REC_ATTR, "1"); } InstallHTMLHooksForOnchange(); } catch { // Can not properly install html hooks. } }
/// <summary> /// 挑入网页加载完毕监听 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Pickwebbrowser_LoadCompleted(object sender, NavigationEventArgs e) { string uri = pickWebBrowser.Source.ToString(); if (pickurl.IndexOf(uri) > -1) { //页面加载完毕执行挑入 IHTMLDocument2 pickdoc = (IHTMLDocument2)pickWebBrowser.Document; IHTMLWindow2 pickwin = (IHTMLWindow2)pickdoc.parentWindow; mshtml.HTMLDocument htmlDoc = pickWebBrowser.Document as mshtml.HTMLDocument; var head = htmlDoc.getElementsByTagName("head").Cast <HTMLHeadElement>().First(); var script = (IHTMLScriptElement)htmlDoc.createElement("script"); script.src = "https://demo.22com.cn/crm/json2.js"; head.appendChild((IHTMLDOMNode)script); InjectJs inject = new InjectJs(this.pickWebBrowser); Thread thr = new Thread(() => { //这里还可以处理些比较耗时的事情。 Thread.Sleep(1000);//延时10秒 this.Dispatcher.Invoke(new Action(() => { pickwin.execScript(inject.getOverridePickInJs(), "javascript"); pickwin.execScript("_shy_.alert_close();", "javascript");//关闭弹窗JS pickwin.execScript("selectOpp.getWidget('').select(0,true);", "javascript"); pickwin.execScript("overrDoPick()", "javascript"); })); }); thr.Start(); } }
private static void deRegisterMouseOut(DispHTMLDocument document, IHTMLWindow2 window) { if (mouseOutHandler != null) { Helper.getHelper().removeEventListener(document, "mouseout", mouseOutHandler); } }
private void InstallHTMLHooksForOnchange() { // Install onchange hook for <input type=password, text, file>. String searchCondition = String.Format("{0}!=1", CatStudioConstants.HOOKED_BY_REC_ATTR); IElementList inputElemNotHooked = this.twebstBrowser.FindAllElements("input", searchCondition); for (int i = 0; i < inputElemNotHooked.length; ++i) { IHTMLElement2 crntNativeElem2 = (IHTMLElement2)inputElemNotHooked[i].nativeElement; String inputType = ((IHTMLInputElement)crntNativeElem2).type.ToLower(); IHTMLElement crntElem = (IHTMLElement)crntNativeElem2; if (("text" == inputType) || ("password" == inputType) || ("file" == inputType)) { IHTMLWindow2 wnd = ((IHTMLDocument2)crntElem.document).parentWindow; crntNativeElem2.attachEvent("onchange", new HtmlHandler(this.OnHtmlChange, wnd)); } crntElem.setAttribute(CatStudioConstants.HOOKED_BY_REC_ATTR, "1", 0); } // Install onchange hook for <select>. IElementList selectElemNotHooked = this.twebstBrowser.FindAllElements("select", searchCondition); InstalHTMLHookOnList(selectElemNotHooked, "onchange"); // Install onchange hook for <textarea>. IElementList textAreaElemNotHooked = this.twebstBrowser.FindAllElements("textarea", searchCondition); InstalHTMLHookOnList(textAreaElemNotHooked, "onchange"); }
private void checkAndInjectInDocument() { DispHTMLDocument doc = (DispHTMLDocument)Helper.getHelper().getDocument(); IHTMLWindow2 window = (doc as IHTMLDocument2).parentWindow; window.name = ""; registerEvents(doc); }
private string m_isDebugState = "0";//如果是1就打开debug状态 #endregion #region 公开的方法 /// <summary> /// 初始化 /// </summary> /// <param name="htmlWindow">调用页面</param> /// <param name="jsCallBackFun">回调方法</param> /// <param name="flag">1为html 2为WORD</param> /// <param name="url">上传服务器的地址</param> /// <param name="debug">可选参数为1时才弹出bug窗体</param> public void initService(IHTMLWindow2 htmlWindow, String jsCallBackFun, string flag, string url, string debug = "0") { myConvertType = (ConvertType)Enum.Parse(typeof(ConvertType), flag); this.m_htmlWindow = (HTMLWindow2Class)Marshal.CreateWrapperOfType(htmlWindow, typeof(HTMLWindow2Class)); this.m_jsCallBackFun = jsCallBackFun; m_isDebugState = debug; m_strURL = url; }
private static void registerEvents(DispHTMLDocument doc) { IHTMLWindow2 wnd = (doc as IHTMLDocument2).parentWindow; registerMouseOver(doc, wnd); registerMouseOut(doc, wnd); registerContextEvent(doc, wnd); }
/// <summary> /// Runs the script code in IE. /// </summary> /// <param name="scriptCode">The script code.</param> /// <param name="language">The language.</param> /// <param name="window">The parent window of the document.</param> public static void RunScript(string scriptCode, string language, IHTMLWindow2 window) { try { window.execScript(scriptCode, language); } catch (Exception ex) { throw new RunScriptException(ex); } }
/// <summary> /// Runs the script code in IE. /// </summary> /// <param name="scriptCode">The script code.</param> /// <param name="language">The language.</param> /// <param name="window">The parent window of the document.</param> public static void RunScript(string scriptCode, string language, IHTMLWindow2 window) { try { Logger.LogDebug("[script] {0}", scriptCode); window.execScript(scriptCode, language); } catch (Exception ex) { throw new RunScriptException(ex); } }
// Returns null in case of failure. public static IHTMLDocument2 GetDocumentFromWindow(IHTMLWindow2 htmlWindow) { if (htmlWindow == null) { return null; } // First try the usual way to get the document. try { IHTMLDocument2 doc = htmlWindow.document; return doc; } catch (COMException comEx) { // I think COMException won't be ever fired but just to be sure ... if (comEx.ErrorCode != E_ACCESSDENIED) { return null; } } catch (System.UnauthorizedAccessException) { } catch { // Any other error. return null; } // At this point the error was E_ACCESSDENIED because the frame contains a document from another domain. // IE tries to prevent a cross frame scripting security issue. try { // Convert IHTMLWindow2 to IWebBrowser2 using IServiceProvider. IServiceProvider sp = (IServiceProvider)htmlWindow; // Use IServiceProvider.QueryService to get IWebBrowser2 object. Object brws = null; sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out brws); // Get the document from IWebBrowser2. SHDocVw.IWebBrowser2 browser = (SHDocVw.IWebBrowser2)(brws); return (IHTMLDocument2)browser.Document; } catch { } return null; }
public void Register(object win) { temphtml = (IHTMLWindow2)win; if (temphtml == null) { temphtml = null; MessageBox.Show("打印脚本注册失败!"); } else { MessageBox.Show("打印脚本注册成功!"); } }
public static bool IsForeignFrame(IHTMLWindow2 win) { try { if ( win.document.protocol == "File Protocol") { return false; } if ( win.document.domain.Length == 0 ) { return true; } } catch( UnauthorizedAccessException ) { return true; } return false; }
private DocumentContainer(IHTMLWindow2 frameWindow, WindowDetails contentWindow, DocumentContainer parent) { //IWebBrowser2 webBrowser2 = frame as IWebBrowser2; //IHTMLDocument2 document2 = webBrowser2.Document as IHTMLDocument2; IHTMLDocument2 document2 = GetDocumentFromWindow(frameWindow); try { LOG.DebugFormat("frameWindow.name {0}", frameWindow.name); } catch { } try { LOG.DebugFormat("document2.url {0}",document2.url); } catch { } try { LOG.DebugFormat("document2.title {0}", document2.title); } catch { } this.parent = parent; // Calculate startLocation for the frames IHTMLWindow3 window3 = (IHTMLWindow3)document2.parentWindow; // IHTMLElement element = window2.document.body; // long x = 0; // long y = 0; // do { // x += element.offsetLeft; // y += element.offsetTop; // element = element.offsetParent; // } while (element != null); // startLocation = new Point((int)x, (int)y); Point contentWindowLocation = contentWindow.ClientRectangle.Location; int x = window3.screenLeft - contentWindowLocation.X; int y = window3.screenTop - contentWindowLocation.Y; startLocation = new Point(x, y); Init(document2, contentWindow); }
private DocumentContainer(IHTMLWindow2 frameWindow, WindowDetails contentWindow, DocumentContainer parent) { //IWebBrowser2 webBrowser2 = frame as IWebBrowser2; //IHTMLDocument2 document2 = webBrowser2.Document as IHTMLDocument2; IHTMLDocument2 document2 = GetDocumentFromWindow(frameWindow); try { LOG.DebugFormat("frameWindow.name {0}", frameWindow.name); name = frameWindow.name; } catch { } try { LOG.DebugFormat("document2.url {0}",document2.url); } catch { } try { LOG.DebugFormat("document2.title {0}", document2.title); } catch { } this.parent = parent; // Calculate startLocation for the frames IHTMLWindow2 window2 = document2.parentWindow; IHTMLWindow3 window3 = (IHTMLWindow3)window2; Point contentWindowLocation = contentWindow.WindowRectangle.Location; int x = window3.screenLeft - contentWindowLocation.X; int y = window3.screenTop - contentWindowLocation.Y; // Release IHTMLWindow 2+3 com objects releaseCom(window2); releaseCom(window3); startLocation = new Point(x, y); Init(document2, contentWindow); }
/// <summary> /// Try to run the script in the browser window /// </summary> /// <param name="i">The index of the script in the settings file</param> /// <param name="window">The current IHTMLWindow2</param> /// <param name="useMenuCommands">Should the menu commands HTML be injected into the page?</param> /// <param name="menuContent">The content for the menu commands HTML</param> private void TryRunScript(int i, IHTMLWindow2 window, ref bool useMenuCommands, ref string menuContent) { if (_prefs[i].Type != Script.ValueType.Script) return; string scriptContent = String.Empty; try { scriptContent = GetScriptFileData(i); var content = "function Scriptmonkey_S" + i + "_proto() {"; if (_prefs.Settings.InjectAPI && _prefs[i].RequiresApi) content += Resources.WrapperJS_Before + i + Resources.WrapperJS_Mid + _apiKeys[i] + Resources.WrapperJS_After + scriptContent; else content += scriptContent; if (_prefs[i].ShowMenuCommands && _prefs[i].MenuCommands?.Count > 0) { foreach (NameFunctionPair command in _prefs[i].MenuCommands) { var internalName = GenerateRandomString(); content += "this.SM_" + internalName + " = " + command.Function + ";"; menuContent += "<p><a style=\"cursor: pointer; color: #4495d4;\" onclick=\"Scriptmonkey_S" + i + ".SM_" + internalName + "();\">" + command.Name + "</a></p>"; } useMenuCommands = true; } content += "}var Scriptmonkey_S" + i + " = new Scriptmonkey_S" + i + "_proto();"; //RunScript(content, window, _prefs[i].Name); var f = i; var t = new Thread(() => RunScript(content, window, _prefs[f].Name, _prefs[f].Require != null && _prefs[f].Require.Count > 0? _prefs[f].Require.Values.ToList() : null)); t.SetApartmentState(ApartmentState.STA); t.Start(); } catch (Exception ex) { window.execScript("console.log(\"Scriptmonkey: Unable to load script: " + _prefs[i].Name + ". Error: " + ex.Message.Replace("\"", "\\\"") + "\");"); bool shouldThrow; if (_prefs.Settings.LogScriptContentsOnRunError && !ex.Message.Contains("Access is denied")) shouldThrow = LogAndCheckDebugger(ex, "At script: " + _prefs[i].Name + ':' + Environment.NewLine + scriptContent); else shouldThrow = LogAndCheckDebugger(ex, "At script: " + _prefs[i].Name); if (shouldThrow) throw; } }
/// <summary> /// Try to inject CSS into the current window. /// </summary> /// <param name="i">The index of the Script object in the settings file.</param> /// <param name="window">The current IHTMLWindow2.</param> private void TryInjectCss(int i, IHTMLWindow2 window) { if (_prefs[i].Type != Script.ValueType.StyleSheet) return; string content = String.Empty; try { content = GetScriptFileData(i); var doc = window.document; var t = new Thread(() => { if (doc.styleSheets.length > 31) return; // doc.createStyleSheet throws Invalid Argument if length > 31 doc.createStyleSheet().cssText = content; }); t.SetApartmentState(ApartmentState.STA); t.Start(); } catch (Exception ex) { if (ex.Message.Contains("Access is denied")) return; if(_prefs.Settings.LogScriptContentsOnRunError ? LogAndCheckDebugger(ex, "At CSS: " + _prefs[i].Name + ':' + Environment.NewLine + content) : LogAndCheckDebugger(ex, "At CSS: " + _prefs[i].Name)) throw; } }
private void SetupWindow(IHTMLWindow2 window) { // Prevent multiple injections of API try { if (window.execScript("window['Scriptmonkey']") != null) { return; } } catch (Exception) { } // Expose API methods try { var exp = window as IExpando; if (exp == null) return; var info = exp.AddProperty("Scriptmonkey"); info?.SetValue(exp, this); } catch (Exception ex) { if (ex is AccessViolationException) // Exception: "Attempted to read or write protected memory. _ return; // This is often an indication that other memory is corrupt." _ // This is thrown when the memory of the IE process is corrupted, _ // and thus write protected. if (LogAndCheckDebugger(ex, "SetupWindow")) throw; } // Run Notification.js if (!_prefs.Settings.InjectNotificationAPI) return; try { window.execScript(Resources.NotificationJS); } catch (Exception ex) { if (ex is AccessViolationException) return; if (ShouldThrowScriptException(ex, "NotificationWrapper", Resources.NotificationJS)) throw; } }
/// <summary> /// Executes JavaScript on the window /// </summary> /// <param name="content">The JavaScript to execute.</param> /// <param name="window">The window.</param> /// <param name="name">Name of the script.</param> /// <param name="dependencyContent">String array of dependencies to include</param> private void RunScript(string content, IHTMLWindow2 window, string name, List<string> dependencyContent) { if (dependencyContent != null) { foreach (var dependency in dependencyContent) { try { window.execScript(dependency); } catch (Exception ex) { if (ShouldThrowScriptException(ex, name, dependency)) throw; } } } try { window.execScript(content); } catch (Exception ex) { if (ShouldThrowScriptException(ex, name, content)) throw; } }
/// <summary> /// Runs the javascript code in IE. /// </summary> /// <param name="scriptCode">The javascript code.</param> /// <param name="window">The parent window of the document.</param> public static void RunScript(string scriptCode, IHTMLWindow2 window) { RunScript(scriptCode, "javascript", window); }
/// <summary> /// Runs the javascript code in IE. /// </summary> /// <param name="scriptCode">The javascript code.</param> /// <param name="window">The parent window of the document.</param> public static void RunScript(StringBuilder scriptCode, IHTMLWindow2 window) { RunScript(scriptCode.ToString(), window); }
public static IWebBrowser2 HTMLWindowToWebBrowser(IHTMLWindow2 spWindow) { if (spWindow == null) return null; IServiceProvider spServiceProvider = spWindow as IServiceProvider; if (spServiceProvider == null) { return null; } object spWebBrws; Guid guid = IID_IWebBrowserApp; Guid riid = IID_IWebBrowser2; int hRes = spServiceProvider.QueryService(ref guid, ref riid, out spWebBrws); if (hRes != 0) { return null; } return spWebBrws as IWebBrowser2; }
public MainWindow() { InitializeComponent(); _currentDevice = new DeviceItem { DeviceAddress = "http://192.168.1.104:8080/", DeviceName = "Yarvik", DeviceType = DeviceTypes.Android }; // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic // since it tells you how to set up an ambient parse request dispatcher and an ambient // code repository within your application OnStartup code, and add related cleanup in your // application OnExit code. These steps are essential to having the add-on perform well. // Initialize the project assembly (enables support for automated IntelliPrompt features) _projectAssembly = new CSharpProjectAssembly("SampleBrowser"); var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader; assemblyLoader.RunWorkerAsync(); // Load the .NET Languages Add-on C# language and register the project assembly on it var language = new CSharpSyntaxLanguage(); language.RegisterProjectAssembly(_projectAssembly); CodeEditor.Document.Language = language; CodeEditor.Document.Language.RegisterService(new IndicatorQuickInfoProvider()); CodeEditor.PreviewKeyDown += (sender, args) => { if (args.Key != Key.Enter || (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control) return; SendCodeButton_Click(null,null); args.Handled = true; }; _udpDiscoveryClient = new UdpDiscoveryClient( // ready => Dispatcher.Invoke((Action) (() => SendCodeButton.IsEnabled = ready)), ready => { }, (name, address) => Dispatcher.Invoke(() => { if (address.Contains("?")) address = address.Replace("?", AndroidPort); var deviceItem = new DeviceItem { DeviceAddress = address, DeviceName = name, DeviceType = name.StartsWith("ProtoPad Service on ANDROID Device ") ? DeviceTypes.Android : DeviceTypes.iOS }; if (!DevicesComboBox.Items.Cast<object>().Any(i => (i as DeviceItem).DeviceAddress == deviceItem.DeviceAddress)) { DevicesComboBox.Items.Add(deviceItem); } DevicesComboBox.IsEnabled = true; //ResultTextBox.Text += String.Format("Found '{0}' on {1}", name, address); })); ResultTextBox.Navigated += (sender, args) => { var htmlDocument = ResultTextBox.Document as HTMLDocument; _htmlHolder = htmlDocument.getElementById("wrapallthethings") as HTMLDivElementClass; _htmlWindow = htmlDocument.parentWindow; _udpDiscoveryClient.SendServerPing(); var ticksPassed = 0; var dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += (s, a) => { if (ticksPassed > 2) { dispatcherTimer.Stop(); if (DevicesComboBox.Items.Count == 1) { DevicesComboBox.SelectedIndex = 0; } } _udpDiscoveryClient.SendServerPing(); ticksPassed++; }; dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200); dispatcherTimer.Start(); }; ResultTextBox.NavigateToString(Properties.Resources.ResultHtmlWrap); }
/// <summary> /// A "workaround" for Access Denied when dealing with Frames from different domains /// </summary> /// <param name="htmlWindow">The IHTMLWindow2 to get the document from</param> /// <returns>IHTMLDocument2 or null</returns> private static IHTMLDocument2 GetDocumentFromWindow(IHTMLWindow2 htmlWindow) { if (htmlWindow == null) { LOG.Warn("htmlWindow == null"); return null; } // First try the usual way to get the document. try { IHTMLDocument2 doc = htmlWindow.document; return doc; } catch (COMException comEx) { // I think COMException won't be ever fired but just to be sure ... if (comEx.ErrorCode != E_ACCESSDENIED) { LOG.Warn("comEx.ErrorCode != E_ACCESSDENIED but", comEx); return null; } } catch (UnauthorizedAccessException) { // This error is okay, ignoring it } catch (Exception ex1) { LOG.Warn("Some error: ", ex1); // Any other error. return null; } // At this point the error was E_ACCESSDENIED because the frame contains a document from another domain. // IE tries to prevent a cross frame scripting security issue. try { // Convert IHTMLWindow2 to IWebBrowser2 using IServiceProvider. IServiceProvider sp = (IServiceProvider)htmlWindow; // Use IServiceProvider.QueryService to get IWebBrowser2 object. Object brws = null; Guid webBrowserApp = IID_IWebBrowserApp; Guid webBrowser2 = IID_IWebBrowser2; sp.QueryService(ref webBrowserApp, ref webBrowser2, out brws); // Get the document from IWebBrowser2. IWebBrowser2 browser = (IWebBrowser2)(brws); return (IHTMLDocument2)browser.Document; } catch (Exception ex2) { LOG.Warn("another error: ", ex2); } return null; }
public AsyncScriptRunner(string scriptCode, IHTMLWindow2 window) { _scriptCode = scriptCode; _window = window; }
private void InitializeResultWindow() { ResultTextBox.Navigated += (sender, args) => { var htmlDocument3 = ResultTextBox.Document as IHTMLDocument3; var htmlDocument2 = ResultTextBox.Document as IHTMLDocument2; _htmlHolder = htmlDocument3.getElementById("wrapallthethings"); _htmlWindow = htmlDocument2.parentWindow; }; ResultTextBox.NavigateToString(Properties.Resources.ResultHtmlWrap); }
private void ctlRaagaJukebox_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { try { if (e.uRL.ToString().IndexOf("playerV31/index.asp") >= 0) { Uri PlayerUrl = new Uri(e.uRL.ToString()); if (PlayerUrl.Query.IndexOf("bhcp") >= 0) { // //Go to the next track //Simulate javascript::Next() API possibly exposed by //the player IHTMLDocument2 docPlayer = ((IHTMLDocument2)ctlRaagaJukebox.Document); if (docPlayer != null) { this.Size = new Size(482,292); this.Size = new Size(480,290); // //Get the first frame window object oIndex = 0; IHTMLWindow2 framePlayer = (IHTMLWindow2)docPlayer.parentWindow.frames.item(ref oIndex); if ((framePlayer != null) && (m_bToggle == true)) { #if DEBUG && TRACE_DUMP using (RaagaHacker.Debug.frmDump dump = new RaagaHacker.Debug.frmDump()) { dump.Dump = framePlayer.document.body.parentElement.outerHTML; dump.ShowDialog(); } #endif //register the above function as a RealOne control's ontitlechange //listner // string sJSTitleChange = @" if (raaga_ply != null) // { // raaga_ply.attachEvent('OnTitleChange',OnTitleChange); // } // function OnTitleChange(ClipTitle) // { // document.title = ClipTitle; // }"; // framePlayer.execScript(sJSTitleChange, "JavaScript"); // //First audio clip is potentially a dirty add clip. //So ignore it //framePlayer.execScript("if (raaga_ply != null) {raaga_ply.DoNextEntry();}", "JavaScript"); } } } } else { if ((e.uRL.ToString().IndexOf("ads1.asp") >= 0) || (e.uRL.ToString().ToLower().IndexOf("raagaads.asp") >= 0)) { IHTMLDocument2 docPlayer = ((IHTMLDocument2)ctlRaagaJukebox.Document); if (docPlayer != null) { this.Size = new Size(482,292); this.Size = new Size(480,290); // //Get the first frame window object oIndex = 0; IHTMLWindow2 framePlayer = (IHTMLWindow2)docPlayer.parentWindow.frames.item(ref oIndex); if (framePlayer != null) { if (m_bToggle == true) { //Save the frame-player m_wndPlayer = framePlayer; #if DEBUG && TRACE_DUMP using (RaagaHacker.Debug.frmDump dump = new RaagaHacker.Debug.frmDump()) { dump.Dump = framePlayer.document.body.parentElement.outerHTML; dump.ShowDialog(); } #endif // //First audio clip is potentially a dirty add clip. //So ignore it //register the above function as a RealOne control's ontitlechange //listner string sJSTitleChange = @"if (raaga_ply != null) { raaga_ply.attachEvent('OnTitleChange',OnTitleChange); } function OnTitleChange(ClipTitle) { document.title = ClipTitle; }"; framePlayer.execScript(sJSTitleChange, "JavaScript"); // //The DoNextEntry() API is asynchronous - means it returns //immediately. So the call to get the current clip title //proved futile. m_bToggle = false; framePlayer.execScript("if (raaga_ply != null) {raaga_ply.DoNextEntry();}", "JavaScript"); } else { if (m_bGotSongInfo == false) { } } } } } else { if (e.uRL.ToString().IndexOf(URLs.RAAGA_ADD_TO_PLAYLIST) >= 0) { this.ShowDialog(); } } } } catch(Exception _e) { if (Globals.GetInstance().SuppressError == false) { frmException frm = new frmException(); frm.ExceptionDialogTitle = "Raaga Jukebox Manipulation Problem "; frm.ErrorMessage = _e.Message; frm.StrackTrace = _e.StackTrace; if (frm.ShowDialog() == DialogResult.OK) { frm.Dispose(); frm = null; } } } }
private void ctlRaagaJukebox_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { try { if (e.uRL.ToString().IndexOf("playerV31/index.asp") >= 0) { Uri PlayerUrl = new Uri(e.uRL.ToString()); if (PlayerUrl.Query.IndexOf("bhcp") >= 0) { // //Go to the next track //Simulate javascript::Next() API possibly exposed by //the player IHTMLDocument2 docPlayer = ((IHTMLDocument2)ctlRaagaJukebox.Document); if (docPlayer != null) { this.Size = new Size(482,292); this.Size = new Size(480,290); // //Get the first frame window object oIndex = 0; IHTMLWindow2 framePlayer = (IHTMLWindow2)docPlayer.parentWindow.frames.item(ref oIndex); if ((framePlayer != null) && (m_bToggle == true)) { // //First audio clip is potentially a dirty add clip. //So ignore it framePlayer.execScript("raaga_ply.DoNextEntry()","JavaScript"); } } } } else { if ((e.uRL.ToString().IndexOf("ads1.asp") >= 0) || (e.uRL.ToString().ToLower().IndexOf("raagaads.asp") >= 0)) { IHTMLDocument2 docPlayer = ((IHTMLDocument2)ctlRaagaJukebox.Document); if (docPlayer != null) { this.Size = new Size(482,292); this.Size = new Size(480,290); // //Get the first frame window object oIndex = 0; IHTMLWindow2 framePlayer = (IHTMLWindow2)docPlayer.parentWindow.frames.item(ref oIndex); if (framePlayer != null) { if (m_bToggle == true) { //Save the frame-player m_wndPlayer = framePlayer; // //First audio clip is potentially a dirty add clip. //So ignore it framePlayer.execScript("raaga_ply.DoNextEntry()","JavaScript"); string sJSTitleChange = ""; //register the above function as a RealOne control's ontitlechange //listner sJSTitleChange += " raaga_ply.attachEvent('OnTitleChange',OnTitleChange);\n"; sJSTitleChange += "function OnTitleChange(ClipTitle)\n"; sJSTitleChange += "{\ndocument.title = ClipTitle;\n}\n"; framePlayer.execScript(sJSTitleChange,"JavaScript"); // //The DoNextEntry() API is asynchronous - means it returns //immediately. So the call to get the current clip title //proved futile. m_bToggle = false; } else { if (m_bGotSongInfo == false) { } } } } } else { } } } catch(Exception _e) { frmException frm = new frmException(); frm.ExceptionDialogTitle = "Raaga.com navigational problem "; frm.ErrorMessage = _e.Message; frm.StrackTrace = _e.StackTrace; if (frm.ShowDialog() == DialogResult.OK) { frm.Dispose(); frm = null; } } }
void m_timer_Tick(object sender, EventArgs e) { m_timer.Stop(); this.richTextBox1.Clear(); //Enum child windows winenum.enumerate(m_Dialog); //Get the control names m_Ctls = winenum.GetControlsClassNames(); m_Count = m_Ctls.Count; this.richTextBox1.AppendText("HTMLDialog total child windows count =" + m_Count.ToString() + "\r\n"); for (m_Counter = 0; m_Counter < m_Count; m_Counter++) { this.richTextBox1.AppendText(m_Ctls[m_Counter].ToString() + "\r\n"); //Find IE_Server if ((m_Ctls[m_Counter] != null) && (m_Ctls[m_Counter].ToString().Equals("Internet Explorer_Server", StringComparison.CurrentCultureIgnoreCase)) ) { //subscribe to documentelement events //so we can handle key + unload events m_IE = (IntPtr)Int32.Parse(winenum.GetControlsHwnds()[m_Counter].ToString()); this.richTextBox1.AppendText("Internet Explorer_Server HWND =" + m_IE.ToString() + "\r\n"); if (m_IE != IntPtr.Zero) { m_pDoc2 = winenum.GetIEHTMLDocument2FromWindowHandle(m_IE); IHTMLDocument3 doc3 = m_pDoc2 as IHTMLDocument3; if (doc3 != null) { if(m_docelemevents.ConnectToHtmlElementEvents(doc3.documentElement)) this.richTextBox1.AppendText("Subscribed to Document events = OK\r\n"); else this.richTextBox1.AppendText("Subscribed to Document events = FAILED\r\n"); } if (m_pDoc2 != null) { m_pWin2 = m_pDoc2.parentWindow as IHTMLWindow2; if (m_pWin2 != null) { if (m_docwinevents.ConnectToHtmlWindowEvents(m_pWin2)) this.richTextBox1.AppendText("Subscribed to Window events = OK\r\n"); else this.richTextBox1.AppendText("Subscribed to Window events = FAILED\r\n"); } } } break; } } winenum.clear(); }
public string GetFramePath(IHTMLWindow2 parentwindow, string separator) { string namepath = ""; if (parentwindow.parent.name != null) { namepath = GetFramePath(parentwindow.parent, separator); } return namepath + "Frame(\"" + parentwindow.name + "\")"+separator; }
public HtmlHandler(EventHandler evHandler, IHTMLWindow2 sourceWindow) { this.eventHandler = evHandler; this.htmlWindow = sourceWindow; }
public void onLoad(object helper, string host, int port, string typeName) { this.helper = new JsHelper(helper, this); this.Window = this.helper.GetWindow(); new JsConsole(this.Window, true); new JsConsole(this.Window, false); this.objToRef = new Dictionary<object, int>(); this.refToObj = new Dictionary<int, object>(); this.tcp = new TcpClient(host, port); this.session = new RemoteSession(this.tcp.GetStream(), this.tcp.GetStream()); LoadMessage loadMsg = new LoadMessage { TypeName = typeName }; this.session.SendMessage(loadMsg); DispatchAndReturn(); }