コード例 #1
0
 private static void deRegisterContextEvent(DispHTMLDocument document, IHTMLWindow2 window)
 {
     if (contextHandler != null)
     {
         Helper.getHelper().removeEventListener(document, "contextmenu", contextHandler);
     }
 }
コード例 #2
0
        private static Element getElement(String property, String value, DispHTMLDocument doc)
        {
            switch (property)
            {
            case Attributes.id:
                return(getElementById(value, doc));

            case Attributes.name:
                return(getElementByName(value, doc));

            case Attributes.linktext:
                return(getElementByLinkText(value, doc));

            case Attributes.css:
                return(getElementByCSS(value, doc));

            case Attributes.classname:
                return(getElementByClassName(value, doc));

            case Attributes.rxpath:
            case Attributes.xpath:
                return(getElementByXPath(value, doc));

            default:
                return(null);
            }
        }
コード例 #3
0
 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);
 }
コード例 #4
0
 private static void deRegisterMouseOut(DispHTMLDocument document, IHTMLWindow2 window)
 {
     if (mouseOutHandler != null)
     {
         Helper.getHelper().removeEventListener(document, "mouseout", mouseOutHandler);
     }
 }
 private static void deRegisterClickEvents(DispHTMLDocument document, IHTMLWindow2 window)
 {
     if (clickHandler != null)// && clickHandler.SourceHTMLWindow.Equals(window))
     {
         Helper.getHelper().removeEventListener(document, "click", clickHandler);
     }
 }
コード例 #6
0
        private static void registerEvents(DispHTMLDocument doc)
        {
            IHTMLWindow2 wnd = (doc as IHTMLDocument2).parentWindow;

            registerMouseOver(doc, wnd);
            registerMouseOut(doc, wnd);
            registerContextEvent(doc, wnd);
        }
        private void checkAndInjectInDocument()
        {
            DispHTMLDocument doc    = (DispHTMLDocument)Helper.getHelper().getDocument();
            IHTMLWindow2     window = (doc as IHTMLDocument2).parentWindow;

            window.name = "";
            registerEvents(doc);
        }
コード例 #8
0
 private static DispHTMLDocument getDocument(String frameData, DispHTMLDocument doc)
 {
     if (frameData != null && frameData.Trim().Length > 0)
     {
         return(getDocumentByFrame(doc, frameData.Trim()));
     }
     return(doc);
 }
コード例 #9
0
ファイル: Plugin.cs プロジェクト: iesus17/recordanywhere
        //void keyHook_KeyDown(object sender, KeyEventArgs e)
        //{ }
        //void keyHook_KeyUp(object sender, KeyEventArgs e)
        //{ }
        //void keyHook_KeyPress(object sender, KeyPressEventArgs e)
        //{
        //    MessageBox.Show(e.KeyChar.ToString());
        //}

        //void mousehook_Click(object sender, MouseEventArgs e)
        //{
        //    if (UserBar.instance != null)
        //    {
        //        //Get Web Browser
        //        if (Recorder.HostInstance != null && Recorder.HostInstance.BrowserRef != null)
        //        {
        //            IWebBrowser2 ActiveBrowser = Recorder.HostInstance.BrowserRef as SHDocVw.IWebBrowser2;

        //            if (ActiveBrowser != null)
        //            {
        //                //Get the current document
        //                HTMLDocument htmlDoc = (HTMLDocument)ActiveBrowser.Document;

        //                if (htmlDoc != null)
        //                {
        //                    DispHTMLDocument doc = (DispHTMLDocument)htmlDoc;

        //                    //Record the basic Url
        //                    string address = ActiveBrowser.LocationURL;
        //                    //Get
        //                    IHTMLElement activeElement = doc.activeElement;

        //                    if (activeElement.tagName != null)
        //                    {
        //                        //do something

        //                        //then do the right thing
        //                    }
        //                }
        //            }
        //        }
        //    }
        //}

        //void mouseHook_MouseMove(object sender, MouseEventArgs e)
        //{ }

        //void mouseHook_MouseDown(object sender, MouseEventArgs e)
        //{ }

        //void mouseHook_MouseUp(object sender, MouseEventArgs e)
        //{

        //}

        //void mouseHook_MouseWheel(object sender, MouseEventArgs e)
        //{ }


        //[DllImport("user32.dll")]
        //static extern IntPtr GetForegroundWindow();

        //[DllImport("user32.dll")]
        //static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);

        //private string GetActiveWindowTitle()
        //{
        //    const int nChars = 256;
        //    IntPtr handle = IntPtr.Zero;
        //    StringBuilder Buff = new StringBuilder(nChars);
        //    handle = GetForegroundWindow();

        //    if (GetWindowText(handle, Buff, nChars) > 0)
        //    {
        //        return Buff.ToString();
        //    }
        //    return null;
        //}
        //private const int WH_KEYBOARD_LL = 13;

        //protected const int WH_MOUSE_LL = 14;
        //protected const int WH_MOUSE = 7;
        //protected const int WH_KEYBOARD = 2;
        //protected const int WM_MOUSEMOVE = 0x200;
        //protected const int WM_LBUTTONDOWN = 0x201;
        //protected const int WM_RBUTTONDOWN = 0x204;
        //protected const int WM_MBUTTONDOWN = 0x207;
        //protected const int WM_LBUTTONUP = 0x202;
        //protected const int WM_RBUTTONUP = 0x205;
        //protected const int WM_MBUTTONUP = 0x208;
        //protected const int WM_LBUTTONDBLCLK = 0x203;
        //protected const int WM_RBUTTONDBLCLK = 0x206;
        //protected const int WM_MBUTTONDBLCLK = 0x209;
        //protected const int WM_MOUSEWHEEL = 0x020A;

        //protected const int WM_KEYDOWN = 0x100;
        //protected const int WM_KEYUP = 0x101;
        //protected const int WM_SYSKEYDOWN = 0x104;
        //protected const int WM_SYSKEYUP = 0x105;

        //protected const byte VK_SHIFT = 0x10;
        //protected const byte VK_CAPITAL = 0x14;
        //protected const byte VK_NUMLOCK = 0x90;

        //protected const byte VK_LSHIFT = 0xA0;
        //protected const byte VK_RSHIFT = 0xA1;
        //protected const byte VK_LCONTROL = 0xA2;
        //protected const byte VK_RCONTROL = 0x3;
        //protected const byte VK_LALT = 0xA4;
        //protected const byte VK_RALT = 0xA5;

        //protected const byte LLKHF_ALTDOWN = 0x20;

        //private static LowLevelMouseProc _proc = HookCallback;
        //private static IntPtr _hookID = IntPtr.Zero;


        //private static IntPtr SetHook(LowLevelMouseProc proc)
        //{
        //    using (Process curProcess = Process.GetCurrentProcess())
        //    using (ProcessModule curModule = curProcess.MainModule)
        //    {
        //        IntPtr handle = GetModuleHandle(curModule.ModuleName);
        //        IntPtr ret = SetWindowsHookEx(WH_MOUSE_LL, proc,
        //            handle, 0);
        //        //MessageBox.Show(Marshal.GetLastWin32Error().ToString());
        //        return ret;
        //    }
        //}

        //private delegate IntPtr LowLevelMouseProc(
        //    int nCode, IntPtr wParam, IntPtr lParam);

        //private static IntPtr HookCallback(
        //    int nCode, IntPtr wParam, IntPtr lParam)
        //{
        //    if (nCode >= 0 && wParam == (IntPtr)WM_LBUTTONUP)
        //    {
        //        int vkCode = Marshal.ReadInt32(lParam);
        //        //Console.WriteLine((Keys)vkCode);
        //        if (UserBar.instance != null)
        //        {
        //            //Get Web Browser
        //            if (Recorder.HostInstance != null && Recorder.HostInstance.BrowserRef != null)
        //            {
        //                IWebBrowser2 ActiveBrowser = Recorder.HostInstance.BrowserRef as SHDocVw.IWebBrowser2;

        //                if (ActiveBrowser != null)
        //                {
        //                    //Get the current document
        //                    HTMLDocument htmlDoc = (HTMLDocument)ActiveBrowser.Document;

        //                    if (htmlDoc != null)
        //                    {
        //                        DispHTMLDocument doc = (DispHTMLDocument)htmlDoc;

        //                        //Record the basic Url
        //                        string address = ActiveBrowser.LocationURL;
        //                        //Get
        //                        IHTMLElement activeElement = doc.activeElement;

        //                        if (activeElement != null)
        //                        {
        //                            MessageBox.Show(activeElement.tagName);
        //                        }
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    return CallNextHookEx(_hookID, nCode, wParam, lParam);
        //}

        //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //private static extern IntPtr SetWindowsHookEx(int idHook,
        //    LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);

        //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //[return: MarshalAs(UnmanagedType.Bool)]
        //private static extern bool UnhookWindowsHookEx(IntPtr hhk);

        //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
        //    IntPtr wParam, IntPtr lParam);

        //[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //private static extern IntPtr GetModuleHandle(string lpModuleName);


        //void HookMouseUp(object sender, Microsoft.Win32.MouseHookEventArgs e)
        //{
        //    if (UserBar.instance != null)
        //    {
        //        //Get Web Browser
        //        if (Recorder.HostInstance != null && Recorder.HostInstance.BrowserRef != null)
        //        {
        //            IWebBrowser2 ActiveBrowser = Recorder.HostInstance.BrowserRef as SHDocVw.IWebBrowser2;

        //            if (ActiveBrowser != null)
        //            {
        //                //Get the current document
        //                HTMLDocument htmlDoc = (HTMLDocument)ActiveBrowser.Document;

        //                if (htmlDoc != null)
        //                {
        //                    DispHTMLDocument doc = (DispHTMLDocument)htmlDoc;

        //                    //Record the basic Url
        //                    string address = ActiveBrowser.LocationURL;
        //                    //Get
        //                    IHTMLElement activeElement = doc.activeElement;

        //                    if (activeElement != null)
        //                    {
        //                        MessageBox.Show(activeElement.tagName);
        //                    }
        //                }
        //            }
        //        }
        //    }
        //}


        void Recorder_OnDocumentComplete(object pDisp, ref object url)
        {
            if (UserBar.instance != null)
            {
                //Get Web Browser
                if (Recorder.HostInstance != null && Recorder.HostInstance.BrowserRef != null)
                {
                    IWebBrowser2 ActiveBrowser = Recorder.HostInstance.BrowserRef as SHDocVw.IWebBrowser2;

                    if (ActiveBrowser != null)
                    {
                        //Get the current document
                        HTMLDocument htmlDoc = (HTMLDocument)ActiveBrowser.Document;

                        DispHTMLDocument doc = (DispHTMLDocument)htmlDoc;

                        //Record the basic Url
                        string address = ActiveBrowser.LocationURL;

                        if (htmlDoc != null)
                        {
                            //Bind events
                            DOMEventHandler onclickhandler = new DOMEventHandler(doc, null);
                            onclickhandler.NewEventHandlers += new DOMEvent(DOMEventMethods._click);
                            doc.onclick = onclickhandler;



                            DOMEventHandler onclickhandler1 = new DOMEventHandler(doc, doc.onclick);
                            onclickhandler1.NewEventHandlers += new DOMEvent(DOMEventMethods._link_click);
                            doc.onmouseup = onclickhandler1;

                            //Bind Href Click
                            //foreach (mshtml.HTMLAnchorElement link in htmlDoc.anchors)
                            //{

                            //    ((HTMLAnchorEvents_Event)link).onmouseup += new HTMLAnchorEvents_onmouseupEventHandler(() =>
                            //    {
                            //        DOMEventMethods._link_click(link);
                            //        //return true;
                            //    });
                            //}

                            //Bind IFrame events
                            //IHTMLElementCollection elems = htmlDoc.getElementsByTagName("iframe");
                            //foreach (IHTMLElement elem in elems)
                            //{
                            //    HTMLFrameElement frm = (HTMLFrameElement)elem;
                            //    DispHTMLDocument frm_doc = (DispHTMLDocument)((SHDocVw.IWebBrowser2)frm).Document;
                            //    DOMEventHandler onclickfrmhandler = new DOMEventHandler(frm_doc);
                            //    onclickfrmhandler.Handler += new DOMEvent(DOMEventMethods._click);
                            //    (frm as DispHTMLDocument).onclick = onclickfrmhandler;
                            //}
                        }
                    }
                }
            }
        }
        private static void registerEvents(DispHTMLDocument doc)
        {
            IHTMLWindow2 wnd = (doc as IHTMLDocument2).parentWindow;

            deRegisterEvents(doc, wnd);
            registerClickEvents(doc, wnd);
            registerChangeEvents(doc, wnd);
            registerContextEvent(doc, wnd);
        }
 private static void deRegisterChangeEvents(DispHTMLDocument document, IHTMLWindow2 window)
 {
     if (changeHandler != null)// && clickHandler.SourceHTMLWindow.Equals(window))
     {
         Helper.getHelper().removeEventListener(document, "change", changeHandler);
         Helper.getHelper().removeEventListener(document, "focus", focusHandler);
         Helper.getHelper().removeEventListener(document, "blur", blurHandler);
     }
 }
 private static void registerChangeEvents(DispHTMLDocument document, IHTMLWindow2 window)
 {
     changeHandler = new HtmlHandler(recordChangeEvent, window);
     focusHandler  = new HtmlHandler(onFocusEvent, window);
     blurHandler   = new HtmlHandler(onBlurEvent, window);
     Helper.getHelper().addEventListener(document, "change", changeHandler);
     Helper.getHelper().addEventListener(document, "focus", focusHandler);
     Helper.getHelper().addEventListener(document, "blur", blurHandler);
 }
コード例 #13
0
        private static void searchElements(List <HObject> objects)
        {
            DispHTMLDocument doc = Helper.getHelper().getDocument() as DispHTMLDocument;

            foreach (HObject x in objects)
            {
                DispHTMLDocument document = getDocument(x.frame, doc);
                searchElement(x, doc);
            }
        }
コード例 #14
0
        private static Element getElementByName(String Name, DispHTMLDocument doc)
        {
            Element element = new Element();

            try
            {
                element = getFromCollection(doc.getElementsByName(Name));
            }
            catch { }
            return(element);
        }
コード例 #15
0
        private static Element getElementByCSS(String Xpath, DispHTMLDocument doc)
        {
            Element element = new Element();

            try
            {
                element = getFromCollection(doc.querySelectorAll(Xpath));
            }
            catch { }
            return(element);
        }
コード例 #16
0
 internal void removeEventListener(DispHTMLDocument doc, String eventName, HtmlHandler handler)
 {
     try
     {
         doc.removeEventListener(eventName, handler, true);
     }
     catch
     {
         doc.detachEvent("on" + eventName, handler);
     }
 }
コード例 #17
0
        internal List <DispHTMLDocument> getDocumentList()
        {
            List <DispHTMLDocument> documents = new List <DispHTMLDocument>();
            DispHTMLDocument        doc       = (DispHTMLDocument)getDocument();
            IHTMLWindow2            window    = (doc as IHTMLDocument2).parentWindow;

            window.name = "";
            documents.Add(doc);
            documents.AddRange(getFrameDocuments());
            return(documents);
        }
コード例 #18
0
        private static Element getElementById(String Id, DispHTMLDocument doc)
        {
            Element element = new Element();

            try
            {
                element.element = doc.getElementById(Id);
                element.count   = 0;
            }
            catch { }
            return(element);
        }
コード例 #19
0
        private static void searchElement(HObject x, DispHTMLDocument doc)
        {
            String  exist  = "false";
            Element result = findElement(x.prop, doc);

            if (result != null && result.element != null)
            {
                exist = result.count > 1 ? "partial" : "true";
                highlightElements(result.element);
            }
            CognizantITS.sendHealResult(x.pageName, x.objectname, exist);
        }
 private void registerEvents(DispHTMLDocument doc)
 {
     try
     {
         if (Recorder.isRunning())
         {
             Recorder.register(doc);
         }
         else if (Spy.isRunning())
         {
             Spy.register(doc);
         }
     }
     catch (Exception dd) { MessageBox.Show(dd.ToString()); }
 }
コード例 #21
0
 private static Element getElementByClassName(String className, DispHTMLDocument doc)
 {
     if (className.Contains(" "))
     {
         return(getElementByCSS(className.Replace(" ", "."), doc));
     }
     else
     {
         Element element = new Element();
         try
         {
             element = getFromCollection(doc.getElementsByClassName(className));
         }
         catch { }
         return(element);
     }
 }
コード例 #22
0
 private static Element findElement(List <Property> x, DispHTMLDocument doc)
 {
     foreach (Property prop in x)
     {
         String property = prop.property;
         String value    = prop.value;
         if (!String.IsNullOrEmpty(value))
         {
             Element result = getElement(property, value, doc);
             if (result != null && result.element != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }
コード例 #23
0
 private static String getFrameValue(DispHTMLDocument FrameDoc)
 {
     try
     {
         IHTMLWindow2 window = (FrameDoc as IHTMLDocument2).parentWindow;
         if (window.name != null && window.name.Trim().Length > 0)
         {
             return(window.name);
         }
         IHTMLWindow4 frameWindow = (FrameDoc as IHTMLDocument2).parentWindow as IHTMLWindow4;
         IHTMLElement frame       = frameWindow.frameElement as IHTMLElement;
         if (!String.IsNullOrEmpty(frame.id))
         {
             return(frame.id);
         }
     }
     catch { }
     return(null);
 }
コード例 #24
0
        private static Element getElementByLinkText(String LinkText, DispHTMLDocument doc)
        {
            Element element = new Element();

            try
            {
                IHTMLElementCollection Collection = doc.getElementsByTagName("a");
                foreach (IHTMLElement Element in Collection)
                {
                    String Link = Element.innerText;
                    if (Link != null && Link.Trim().Equals(LinkText))
                    {
                        element.element = Element;
                        element.count   = 0;
                        return(element);
                    }
                }
            }
            catch { }
            return(element);
        }
コード例 #25
0
ファイル: Plugin.cs プロジェクト: iesus17/recordanywhere
        private void _BindDomEvent(DispHTMLDocument doc)
        {
            DOMEventHandler onclickHandler = new DOMEventHandler(doc, null);

            onclickHandler.NewEventHandlers += new DOMEvent(_click);
            doc.onmouseup = onclickHandler;

            DOMEventHandler onmouseoverHandler = new DOMEventHandler(doc, null);

            onmouseoverHandler.NewEventHandlers += new DOMEvent(_mouseover);
            doc.onmouseover = onmouseoverHandler;

            DOMEventHandler onmouseoutHandler = new DOMEventHandler(doc, null);

            onmouseoutHandler.NewEventHandlers += new DOMEvent(_mouseout);
            doc.onmouseout = onmouseoutHandler;

            DOMEventHandler onkeyupHandler = new DOMEventHandler(doc, null);

            onkeyupHandler.NewEventHandlers += new DOMEvent(_keyup);
            doc.onkeyup = onkeyupHandler;
        }
コード例 #26
0
        internal IEnumerable <DispHTMLDocument> getFrameDocuments()
        {
            List <DispHTMLDocument> documents = new List <DispHTMLDocument>();

            try
            {
                FramesCollection frames = Helper.getHelper().getDocumentProperty("frames") as FramesCollection;
                for (int i = 0; i < frames.length; i++)
                {
                    Object       frameObject = frames.item(i);
                    IHTMLWindow2 frame       = (IHTMLWindow2)frameObject;
                    frameObject = CrossFrameIE.GetDocumentFromWindow(frame).activeElement.document;
                    DispHTMLDocument FrameDoc  = (DispHTMLDocument)frameObject;
                    string           framedata = getFrameValue(FrameDoc);
                    frame.name = framedata != null ? framedata : i + "";
                    documents.Add(FrameDoc);
                }
            }
            catch (Exception ex)
            {
            }
            return(documents);
        }
コード例 #27
0
 public DOMEventHandler(DispHTMLDocument doc)
 {
     this.Document = doc;
 }
コード例 #28
0
        private void _BindDomEvent(DispHTMLDocument doc)
        {
            DOMEventHandler onclickHandler = new DOMEventHandler(doc, null);
            onclickHandler.NewEventHandlers += new DOMEvent(_click);
            doc.onmouseup = onclickHandler;

            DOMEventHandler onmouseoverHandler = new DOMEventHandler(doc, null);
            onmouseoverHandler.NewEventHandlers += new DOMEvent(_mouseover);
            doc.onmouseover = onmouseoverHandler;

            DOMEventHandler onmouseoutHandler = new DOMEventHandler(doc, null);
            onmouseoutHandler.NewEventHandlers += new DOMEvent(_mouseout);
            doc.onmouseout = onmouseoutHandler;

            DOMEventHandler onkeyupHandler = new DOMEventHandler(doc, null);
            onkeyupHandler.NewEventHandlers += new DOMEvent(_keyup);
            doc.onkeyup = onkeyupHandler;
        }
コード例 #29
0
 public DOMEventHandler(DispHTMLDocument doc, object existingHandlers)
 {
     this.Document = doc;
     OriginalEventHandlers = existingHandlers;
 }
コード例 #30
0
 private static void registerMouseOut(DispHTMLDocument document, IHTMLWindow2 window)
 {
     mouseOutHandler = new HtmlHandler(deHighlightOnMouseOut, window);
     Helper.getHelper().addEventListener(document, "mouseout", mouseOutHandler);
 }
コード例 #31
0
 private static void deRegisterEvents(DispHTMLDocument doc, IHTMLWindow2 wnd)
 {
     deRegisterMouseOver(doc, wnd);
     deRegisterMouseOut(doc, wnd);
     deRegisterContextEvent(doc, wnd);
 }
コード例 #32
0
        private static void deRegisterEvents(DispHTMLDocument doc)
        {
            IHTMLWindow2 wnd = (doc as IHTMLDocument2).parentWindow;

            deRegisterEvents(doc, wnd);
        }