Exemple #1
0
        private void Hook_OnMouseClicked(int vmID, WindowsAccessBridgeInterop.AccessibleContextNode ac)
        {
            lastElement = new JavaElement(ac);
            lastElement.SetPath();
            Log.Debug("OnMouseClicked: " + lastElement.id + " " + lastElement.role + " " + lastElement.Name);
            if (lastElement == null)
            {
                return;
            }

            var re = new RecordEvent(); re.Button = MouseButton.Left;
            var a  = new GetElement {
                DisplayName = lastElement.title
            };
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            JavaSelector sel = null;

            // sel = new JavaSelector(e.Element.rawElement, null, true);
            sel = new JavaSelector(lastElement, null, true);
            if (sel == null)
            {
                return;
            }
            if (sel.Count < 2)
            {
                return;
            }
            a.Selector      = sel.ToString();
            a.Image         = lastElement.ImageString();
            a.MaxResults    = 1;
            re.Element      = lastElement;
            re.Selector     = sel;
            re.X            = lastElement.X;
            re.Y            = lastElement.Y;
            re.a            = new GetElementResult(a);
            re.SupportInput = lastElement.SupportInput;

            Log.Debug(string.Format("Java.Recording::OnMouseClicked::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            OnUserAction?.Invoke(this, re);
        }
        private void Hook_OnMouseClicked(int vmID, WindowsAccessBridgeInterop.AccessibleContextNode ac)
        {
            if (string.IsNullOrEmpty(Selector))
            {
                return;
            }
            var element = new JavaElement(ac);

            element.SetPath();
            Log.Debug("OnMouseClicked: " + element.id + " " + element.role + " " + element.Name);

            var pathToRoot = new List <JavaElement>();

            while (element != null)
            {
                if (pathToRoot.Contains(element))
                {
                    break;
                }
                try
                {
                    if (element.Parent != null)
                    {
                        pathToRoot.Add(element);
                    }
                }
                catch (Exception)
                {
                }
                try
                {
                    element = element.Parent;
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "");
                    return;
                }
            }
            JavaSelector selector = new JavaSelector(Selector);

            if (pathToRoot.Count < (selector.Count - 1))
            {
                return;
            }
            if (pathToRoot.Count > (selector.Count - 1))
            {
                return;
            }
            pathToRoot.Reverse();
            for (var i = 0; i < pathToRoot.Count; i++)
            {
                element = pathToRoot[i];
                if (selector.Count > (i + 1))
                {
                    JavaSelectorItem s = new JavaSelectorItem(selector[(i + 1)]);
                    if (!s.Match(element))
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            var _e = new DetectorEvent(element);

            OnDetector?.Invoke(this, _e, EventArgs.Empty);
        }
Exemple #3
0
 private void Hook_OnMouseEntered(int vmID, WindowsAccessBridgeInterop.AccessibleContextNode ac)
 {
     lastElement = new JavaElement(ac);
     lastElement.SetPath();
     Log.Verbose("MouseEntered: " + lastElement.id + " " + lastElement.role + " " + lastElement.Name);
 }