Пример #1
0
 public static void MouseWheel(int left, int top, short delta)
 {
     lock (MouseKeyboardEventHandler.s_lockUiPath)
     {
         XmlNodePathRecorder.HandleUiEvent(ref s_strXmlNodes, EnumUiTaskName.MouseWheel, (int)delta, 0);
         s_strXmlNodes = null;
     }
     ResetRecordTimer();
 }
Пример #2
0
 public static void RightMouseUp(int left, int top)
 {
     lock (MouseKeyboardEventHandler.s_lockUiPath)
     {
         if (s_strXmlNodes != null)
         {
             XmlNodePathRecorder.HandleUiEvent(ref s_strXmlNodes, EnumUiTaskName.RightClick, 0, 0);
         }
     }
 }
Пример #3
0
        public static void LeftMouseUp(int left, int top)
        {
            ptCursorUp.X = left;
            ptCursorUp.Y = top;

            int dist = Math.Abs(left - ptCursorDown.X) + Math.Abs(top - ptCursorDown.Y);

            if (dist <= nMinDist)
            {
                //Check if it is double click
                if ((Environment.TickCount - tickLeftUp) < nDoubleClickDelta && (Environment.TickCount - tickLeftUp) > 1)
                {
                    lock (s_lockUiPath)
                    {
                        XmlNodePathRecorder.HandleUiEvent(ref s_strXmlNodes, EnumUiTaskName.LeftDblClick, 0, 0);
                    }
                }
                else
                {
                    // Create a click task
                    lock (s_lockUiPath)
                    {
                        if (!string.IsNullOrEmpty(s_strXmlNodes))
                        {
                            XmlNodePathRecorder.HandleUiEvent(ref s_strXmlNodes, EnumUiTaskName.LeftClick, 0, 0);
                        }
                    }
                }
            }
            else if (mouseState == MouseState.LeftMouseDrag) // drag stop - down and up are at different points
            {
                int dragDeltaX = ptCursorUp.X - ptCursorDown.X;
                int dragDeltaY = ptCursorUp.Y - ptCursorDown.Y;
                lock (s_lockUiPath)
                {
                    XmlNodePathRecorder.HandleUiEvent(ref s_strXmlNodes, EnumUiTaskName.DragStop, dragDeltaX, dragDeltaY);
                }
            }

            tickLeftUp = Environment.TickCount;

            mouseState = MouseState.LeftMouseUp;
        }
Пример #4
0
        static void PublishKeyboardInput()
        {
            string strBase64 = string.Empty;

            lock (s_lockUiPath)
            {
                if (s_listRecordedKeycode.Count == 0)
                {
                    return;
                }

                strBase64 = Convert.ToBase64String(s_listRecordedKeycode.ToArray());
                s_listRecordedKeycode.Clear();

                if (string.IsNullOrEmpty(strBase64) == false)
                {
                    XmlNodePathRecorder.AddKeyboardInputTask(ref strBase64, s_bCapsLock, s_bNumLock, s_bScrollLock);
                }
            }
        }
Пример #5
0
        private static void RecorderThread()
        {
            StringBuilder sb = new StringBuilder(NativeMethods.BUFFERSIZE);

            System.Drawing.Point pt = new System.Drawing.Point(0, 0);

            while (true)
            {
                bool bStartWalk = s_eventRecordNow.WaitOne(nDelayRecord);

                PublishKeyboardInput();

                if (s_eventQuitRecording.WaitOne(0))
                {
                    break;
                }

                NativeMethods.GetPhysicalCursorPos(out pt);
                int dist = Math.Abs(pt.X - ptUiWalking.X) + Math.Abs(pt.Y - ptUiWalking.Y);

                if (bStartWalk && MouseKeyboardHook.s_bPauseMouseKeyboard == false)
                {
                    // check if cursor has moved
                    if (dist > nMinDist)
                    {
                        NativeMethods.PostMessage(MainWindow.s_windowHandle, (int)MainWindow.UiThreadTask.Active, 0, 0);

                        ptUiWalking.X = pt.X;
                        ptUiWalking.Y = pt.Y;

                        var tick = Environment.TickCount;

                        NativeMethods.GetUiXPath(ptUiWalking.X, ptUiWalking.Y, sb, sb.Capacity);
                        AppInsights.LogMetric("GetUiXPathPerf", Environment.TickCount - tick);

                        if (MouseKeyboardHook.s_bPauseMouseKeyboard == true)
                        {
                            continue;
                        }

                        if (s_eventQuitRecording.WaitOne(0))
                        {
                            break;
                        }

                        string strXmlNode = sb.ToString();
                        if (!string.IsNullOrEmpty(strXmlNode))
                        {
                            int nHash = strXmlNode.GetHashCode();
                            if (nHash != s_nPathHash)
                            {
                                lock (s_lockUiPath)
                                {
                                    MouseKeyboardEventHandler.s_strXmlNodes = strXmlNode;

                                    s_nPathHash = nHash;
                                }

                                XmlNodePathRecorder.HandleUiEvent(ref s_strXmlNodes, EnumUiTaskName.Inspect, 0, 0);
                            }
                        }
                    }

                    s_eventRecordNow.Reset();
                }
            }
        }