Esempio n. 1
0
        private void OnHtmlClick(object sender, EventArgs e)
        {
            if (this.IsRecording && (this.ClickAction != null) && (this.recLastMouseUpPackage != null))
            {
                this.pendingWin32Click = false;

                // On google.com for instance, clicking on a label attached to a radio will trigger another onclick for radio.
                // Duplicate statements must e filtered out.
                if (this.pendingWin32Action &&
                    ((DateTime.Now - this.lastWin32Time).TotalMilliseconds <= MAXIMUM_TIME_FOR_PENDING_CLICKS))
                {
                    this.pendingWin32Action = false;
                    this.lastWin32Time      = DateTime.Now;

                    RecEventArgs recPackage = this.recLastMouseUpPackage;
                    this.recLastMouseUpPackage = null;

                    // Notify listeners about a recorded click action.
                    this.ClickAction(this, recPackage);
                    return;
                }
            }

            this.recLastMouseUpPackage = null;
        }
Esempio n. 2
0
        // If onmouseup is canceled and onclick is not we'll fall back on OnCanceledClick case.
        private void OnHtmlMouseUp(object sender, EventArgs e)
        {
            // Reset any previous mouse up package.
            this.recLastMouseUpPackage = null;

            // On www.xero.com the source element we get on click event is messed up I don't know why.
            // Just keep the source recorder package we correctly get on mouseup event and use it with onclick event.
            if (this.IsRecording && (this.ClickAction != null))
            {
                HtmlHandler  htmlHandler = (HtmlHandler)sender;
                IHTMLElement htmlSource  = [email protected];

                if (!IsValidForClickRec(htmlSource))
                {
                    return;
                }

                // For non <img> elements take a parent anchor. Example: a <b> inside an <a>. Skip anchor with names (page bookmarks).
                IHTMLImgElement imgElem = htmlSource as IHTMLImgElement;
                if (imgElem == null)
                {
                    IElement sourceElement = this.twebstCore.AttachToNativeElement(htmlSource);
                    IElement parentAnchor  = sourceElement.FindParentElement("a", "name="); // A parent anchor without a name.

                    if (parentAnchor != null)
                    {
                        htmlSource = parentAnchor.nativeElement;
                    }
                }

                this.recLastMouseUpPackage = RecEventArgs.CreateRecEvent(htmlSource, twebstBrowser);
            }
        }
Esempio n. 3
0
        private void OnCanceledClick(IntPtr ieWnd, Point screenPos)
        {
            // Reset any mouseup package.
            this.recLastMouseUpPackage = null;

            if (!Win32Api.IsWindow(ieWnd))
            {
                return;
            }

            IHTMLElement htmlElem = GetHtmlElementFromScreenPoint(ieWnd, screenPos);
            if (htmlElem == null)
            {
                return;
            }

            if (!IsValidForClickRec(htmlElem))
            {
                return;
            }

            RecEventArgs recPackage = RecEventArgs.CreateRecEvent(htmlElem, twebstBrowser);

            // Notify listeners about a recorded click action.
            this.ClickAction(this, recPackage);
        }