Exemplo n.º 1
0
        private void SimulateTouch(int x, int y)
        {
            // Touch Down Simulate
            PointerTouchInfo contact = MakePointerTouchInfo(x, y, 5, 1);
            PointerFlags     oFlags  = PointerFlags.DOWN | PointerFlags.INRANGE | PointerFlags.INCONTACT;

            contact.PointerInfo.PointerFlags = oFlags;
            bool bIsSuccess = TouchInjector.InjectTouchInput(1, new[] { contact });

            // Touch Move Simulate
            int nMoveIntervalX = this.GetRandomSeed().Next(-60, 60);
            int nMoveIntervalY = this.GetRandomSeed().Next(-60, 60);

            contact.Move(nMoveIntervalX, nMoveIntervalY);
            oFlags = PointerFlags.INRANGE | PointerFlags.INCONTACT | PointerFlags.UPDATE;
            contact.PointerInfo.PointerFlags = oFlags;
            TouchInjector.InjectTouchInput(1, new[] { contact });

            // Touch Up Simulate
            contact.PointerInfo.PointerFlags = PointerFlags.UP;
            TouchInjector.InjectTouchInput(1, new[] { contact });
        }
Exemplo n.º 2
0
        private PointerTouchInfo MakePointerTouchInfo(int x, int y, int radius,
                                                      uint orientation = 90, uint pressure = 32000)
        {
            PointerTouchInfo contact = new PointerTouchInfo();

            contact.PointerInfo.pointerType = PointerInputType.TOUCH;
            contact.TouchFlags  = TouchFlags.NONE;
            contact.Orientation = orientation;
            contact.Pressure    = pressure;
            contact.TouchMasks  = TouchMask.CONTACTAREA | TouchMask.ORIENTATION | TouchMask.PRESSURE;
            contact.PointerInfo.PtPixelLocation.X = x;
            contact.PointerInfo.PtPixelLocation.Y = y;
            uint unPointerId = IdGenerator.GetUinqueUInt();

            Console.WriteLine("PointerId    " + unPointerId);
            contact.PointerInfo.PointerId = unPointerId;
            contact.ContactArea.left      = x - radius;
            contact.ContactArea.right     = x + radius;
            contact.ContactArea.top       = y - radius;
            contact.ContactArea.bottom    = y + radius;
            return(contact);
        }