예제 #1
0
        /// <summary>
        /// 若element是JAVA窗口,则里面的元素要按照JAVA节点方式获取
        /// </summary>
        /// <param name="element"></param>
        /// <param name="screenPoint"></param>
        /// <returns></returns>
        private bool inspectJavaUiNode(AutomationElement element, Point screenPoint)
        {
            if (element != null)
            {
                //判断是否是JAVA窗口
                var node = new UIAUiNode(element);
                if (JavaUiNode.accessBridge.Functions.IsJavaWindow(node.WindowHandle))
                {
                    //是JAVA窗口,内部节点按JAVA方式选择
                    Path <AccessibleNode> javaNodePath = JavaUiNode.EnumJvms().Select(javaNode => javaNode.GetNodePathAt(screenPoint)).Where(x => x != null).FirstOrDefault();
                    var currentJavaNode = javaNodePath == null ? null : javaNodePath.Leaf;
                    if (currentJavaNode == null)
                    {
                        return(false);
                    }

                    CurrentHighlightElement = new JavaUiNode(currentJavaNode);

                    var rect = currentJavaNode.GetScreenRectangle();
                    //计算鼠标点击时的相对元素的偏移,以供后期有必要时使用
                    CurrentHighlightElementRelativeClickPos = new Point(screenPoint.X - (int)rect?.Left, screenPoint.Y - (int)rect?.Top);

                    this.MoveRect((Rectangle)currentJavaNode.GetScreenRectangle());
                    return(true);
                }
            }
            //Console.WriteLine("return false ");
            return(false);
        }
예제 #2
0
        internal void StartHighlight()
        {
            hasDoSelect = false;

            installHook();

            JavaUiNode.EnumJvms(true);//重刷JVM列表

            this.Show();

            dispatcherTimer.Tick -= new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);

            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(100);
            dispatcherTimer.Start();

            keyStateDispatcherTimer.Tick -= new EventHandler(keyStateDispatcherTimer_Tick);
            keyStateDispatcherTimer.Tick += new EventHandler(keyStateDispatcherTimer_Tick);

            keyStateDispatcherTimer.Interval = TimeSpan.FromMilliseconds(30);
            keyStateDispatcherTimer.Start();
        }
예제 #3
0
 /// <summary>
 /// 初始化,由于JAVA的accessBridge.Initialize()生效有延迟,所以提前使其生效
 /// </summary>
 public static void Init()
 {
     JavaUiNode.EnumJvms(true);
 }