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. } }
private void OnWin32HookMsg(Object sender, Win32HookMsgEventArgs e) { if (this.IsRecording) { this.pendingWin32Action = true; this.lastWin32Time = DateTime.Now; if (e.Type == Win32HookMsgEventArgs.HookMsgType.CLICK_DOWN_MSG) { this.pendingWin32Click = true; } else if (e.Type == Win32HookMsgEventArgs.HookMsgType.CLICK_UP_MSG) { //System.Diagnostics.Trace.WriteLine("WM_PENDING_WIN32_CLICK posted because of " + e.Type); Point screenPos = System.Windows.Forms.Cursor.Position; Win32Api.PostMessage(this.Handle, WM_PENDING_WIN32_CLICK, Win32Api.MakeLong((short)screenPos.X, (short)screenPos.Y), e.WndHandle.ToInt32()); } else if (e.Type == Win32HookMsgEventArgs.HookMsgType.RIGHT_CLICK_DOWN_MSG) { Point screenPos = System.Windows.Forms.Cursor.Position; OnRightClick(e.WndHandle, screenPos); } // Install HTML hooks on left click down and key down. if ((e.Type != Win32HookMsgEventArgs.HookMsgType.CLICK_UP_MSG) && (e.Type != Win32HookMsgEventArgs.HookMsgType.RIGHT_CLICK_UP_MSG) && (e.Type != Win32HookMsgEventArgs.HookMsgType.RIGHT_CLICK_DOWN_MSG)) { InstallHTMLHooks(e); } } }
private void OnNewWin32Msg(IntPtr hIEWnd, Win32HookMsgEventArgs.HookMsgType type) { if (Win32HookMsg != null) { Win32HookMsg(this, new Win32HookMsgEventArgs(hIEWnd, type)); } }