Ejemplo n.º 1
0
        public static void Scroll(int x, int y, int value, bool yAxis)
        {
            var scrollContact = new TouchInjectionCore.PointerTouchInfo[1];
            scrollContact[0] = CreateTouchDownContact(x, y, 2, 1);
            TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);

            scrollContact[0].PointerInfo.PointerFlags =
                TouchInjectionCore.PointerFlags.UPDATE
                | TouchInjectionCore.PointerFlags.INRANGE
                | TouchInjectionCore.PointerFlags.INCONTACT;

            if (yAxis)
            {
                //scroll
                if (value > 0)
                {
                    for (int i = 0; i < value; i++)
                    {
                        scrollContact[0].Move(0, +1);
                        TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
                    }
                }
                else if (value < 0)
                {
                    int n = Math.Abs(value);
                    for (int i = 0; i < n; i++)
                    {
                        scrollContact[0].Move(0, -1);
                        TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
                    }
                }
            }
            else
            {
                //scroll
                if (value > 0)
                {
                    for (int i = 0; i < value; i++)
                    {
                        scrollContact[0].Move(+1, 0);
                        TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
                    }
                }
                else if (value < 0)
                {
                    int n = Math.Abs(value);
                    for (int i = 0; i < n; i++)
                    {
                        scrollContact[0].Move(-1, 0);
                        TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
                    }
                }
            }

            scrollContact[0].PointerInfo.PointerFlags = TouchInjectionCore.PointerFlags.UP;
            TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
        }
Ejemplo n.º 2
0
        public static TouchInjectionCore.PointerTouchInfo CreateTouchDownContact(
            int x,
            int y,
            int radius,
            uint id,
            uint orientation = 90,
            uint pressure = 32000)
        {
            var contact = new TouchInjectionCore.PointerTouchInfo();

            contact.PointerInfo.pointerType = TouchInjectionCore.PointerInputType.TOUCH;
            contact.TouchFlags = TouchInjectionCore.TouchFlags.NONE;

            contact.Pressure = pressure;
            contact.Orientation = orientation;
            contact.PointerInfo.PointerId = id;

            contact.PointerInfo.PointerFlags =
                TouchInjectionCore.PointerFlags.DOWN
                | TouchInjectionCore.PointerFlags.INRANGE
                | TouchInjectionCore.PointerFlags.INCONTACT;

            contact.TouchMasks =
                TouchInjectionCore.TouchMask.CONTACTAREA
                | TouchInjectionCore.TouchMask.ORIENTATION
                | TouchInjectionCore.TouchMask.PRESSURE;

            contact.PointerInfo.PtPixelLocation.X = x;
            contact.PointerInfo.PtPixelLocation.Y = y;

            contact.ContactArea.left    = x - radius;
            contact.ContactArea.right   = x + radius;
            contact.ContactArea.top     = y - radius;
            contact.ContactArea.bottom  = y + radius;

            return contact;
        }
Ejemplo n.º 3
0
        public static void Zoom(int leftX, int rightX, int y, bool @in)
        {
            var contacts = new TouchInjectionCore.PointerTouchInfo[2];
            contacts[0] = CreateTouchDownContact(leftX, y, 2, 1);
            contacts[1] = CreateTouchDownContact(rightX, y, 2, 2);
            TouchInjectionCore.TouchInjector.InjectTouchInput(2, contacts);

            contacts[0].PointerInfo.PointerFlags =
                TouchInjectionCore.PointerFlags.UPDATE
                | TouchInjectionCore.PointerFlags.INRANGE
                | TouchInjectionCore.PointerFlags.INCONTACT;
            contacts[1].PointerInfo.PointerFlags =
                TouchInjectionCore.PointerFlags.UPDATE
                | TouchInjectionCore.PointerFlags.INRANGE
                | TouchInjectionCore.PointerFlags.INCONTACT;

            //zoom
            if (@in)
            {
                for (int i = 0; i < 70; i++)
                {
                    contacts[0].Move(+1, 0);
                    contacts[1].Move(-1, 0);
                    TouchInjectionCore.TouchInjector.InjectTouchInput(2, contacts);
                    Thread.Sleep(1);
                }
            }
            else
            {
                for (int i = 0; i < 70; i++)
                {
                    contacts[0].Move(-1, 0);
                    contacts[1].Move(+1, 0);
                    TouchInjectionCore.TouchInjector.InjectTouchInput(2, contacts);
                    Thread.Sleep(1);
                }
            }
            //Disposal
            contacts[0].PointerInfo.PointerFlags = TouchInjectionCore.PointerFlags.UP;
            contacts[1].PointerInfo.PointerFlags = TouchInjectionCore.PointerFlags.UP;
            TouchInjectionCore.TouchInjector.InjectTouchInput(2, contacts);
            contacts = null;
        }
Ejemplo n.º 4
0
        public static void Touch()
        {
            var scrollContact = new TouchInjectionCore.PointerTouchInfo[1];
            var p = MouseInjection.GetMousePos();

            // Down
            scrollContact[0] = CreateTouchDownContact(p.X, p.Y, 1, 1);
            TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);

            // Up
            scrollContact[0].PointerInfo.PointerFlags = TouchInjectionCore.PointerFlags.UP;
            TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
            scrollContact = null;
        }
Ejemplo n.º 5
0
        public static void Scroll(int x, int y, bool positive, bool yAxis = true)
        {
            var scrollContact = new TouchInjectionCore.PointerTouchInfo[1];
            scrollContact[0] = CreateTouchDownContact(x, y, 1, 1);
            TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);

            scrollContact[0].PointerInfo.PointerFlags =
                TouchInjectionCore.PointerFlags.UPDATE
                | TouchInjectionCore.PointerFlags.INRANGE
                | TouchInjectionCore.PointerFlags.INCONTACT;

            //scroll
            if (yAxis)
            {
                if (positive)
                {
                    for (int i = 0; i < y; i++)
                    {
                        scrollContact[0].Move(0, +1);
                        TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
                        if (i % 15 == 0)
                        {
                            Thread.Sleep(1);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < y; i++)
                    {
                        scrollContact[0].Move(0, -1);
                        TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
                        if (i % 15 == 0)
                        {
                            Thread.Sleep(1);
                        }
                    }
                }
            }
            else
            {
                if (positive)
                {
                    for (int i = 0; i < y; i++)
                    {
                        scrollContact[0].Move(+1, 0);
                        TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
                        if (i % 15 == 0)
                        {
                            Thread.Sleep(1);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < y; i++)
                    {
                        scrollContact[0].Move(-1, 0);
                        TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
                        if (i % 15 == 0)
                        {
                            Thread.Sleep(1);
                        }
                    }
                }
            }
            scrollContact[0].PointerInfo.PointerFlags = TouchInjectionCore.PointerFlags.UP;
            TouchInjectionCore.TouchInjector.InjectTouchInput(1, scrollContact);
        }