Ejemplo n.º 1
0
        public void OutOfRange()
        {
            _contact.pointerInfo.pointerFlags = TouchApi.POINTER_FLAG_UPDATE | TouchApi.POINTER_FLAG_UP;

            var args = new[] { _contact };

            if (!TouchApi.InjectTouchInput(1, args))
            {
                throw new ExternalException("Injection failed. Code: " + Marshal.GetLastWin32Error());
            }
        }
Ejemplo n.º 2
0
        public void Hover(int x, int y)
        {
            _contact.pointerInfo.ptPixelLocation.X = x; // Y co-ordinate of touch on screen
            _contact.pointerInfo.ptPixelLocation.Y = y; // X co-ordinate of touch on screen

            _contact.pointerInfo.pointerFlags = TouchApi.POINTER_FLAG_UPDATE | TouchApi.POINTER_FLAG_INRANGE;

            var args = new[] { _contact };

            if (!TouchApi.InjectTouchInput(1, args))
            {
                throw new ExternalException("Injection failed. Code: " + Marshal.GetLastWin32Error());
            }
        }
Ejemplo n.º 3
0
        public void Touchdown(int x, int y)
        {
            _contact.pointerInfo.ptPixelLocation.X = x; // Y co-ordinate of touch on screen
            _contact.pointerInfo.ptPixelLocation.Y = y; // X co-ordinate of touch on screen

            _contact.pointerInfo.pointerFlags = TouchApi.POINTER_FLAG_DOWN | TouchApi.POINTER_FLAG_INRANGE | TouchApi.POINTER_FLAG_INCONTACT;

            // defining contact area (I have taken area of 4 x 4 pixel)

            var args = new[] { _contact };

            if (!TouchApi.InjectTouchInput(1, args))
            {
                throw new ExternalException("Injection failed. Code: " + Marshal.GetLastWin32Error());
            }
        }
Ejemplo n.º 4
0
 public Pen(uint touchPoints, FeedbackMode mode)
 {
     if (!IsSupported)
     {
         throw new ExternalException("Not Supported on your OS.");
     }
     _contact = new POINTER_PEN_INFO();
     _contact.pointerInfo.pointerType = TouchApi.PT_PEN;
     _contact.pointerInfo.pointerId   = 0;
     _contact.pressure = 32000;
     _contact.penFlags = TouchApi.PEN_FLAG_NONE;
     _contact.penMask  = TouchApi.PEN_MASK_PRESSURE;
     if (!TouchApi.InitializeTouchInjection(touchPoints, (uint)mode))
     {
         throw new ExternalException("Initialisation failed. Code: " + Marshal.GetLastWin32Error());
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Keep pressed
        /// </summary>
        public void Hold()
        {
            //_contact.pointerInfo.ptPixelLocation.X = x; // Y co-ordinate of touch on screen
            //_contact.pointerInfo.ptPixelLocation.Y = y; // X co-ordinate of touch on screen

            _contact.pointerInfo.pointerFlags = TouchApi.POINTER_FLAG_UPDATE | TouchApi.POINTER_FLAG_INRANGE | TouchApi.POINTER_FLAG_INCONTACT;

            // defining contact area (I have taken area of 4 x 4 pixel)
            //_contact.rcContact.top = _contact.pointerInfo.ptPixelLocation.Y - 2;
            //_contact.rcContact.bottom = _contact.pointerInfo.ptPixelLocation.Y + 2;
            //_contact.rcContact.left = _contact.pointerInfo.ptPixelLocation.X - 2;
            //_contact.rcContact.right = _contact.pointerInfo.ptPixelLocation.X + 2;

            POINTER_TOUCH_INFO[] args = new[] { _contact };
            if (!TouchApi.InjectTouchInput(1, args))
            {
                throw new ExternalException("Initialisation failed. Code: " + Marshal.GetLastWin32Error());
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a Touch emulator instance
 /// </summary>
 /// <param name="touchPoints">Number of concurrent touch points</param>
 /// <param name="mode">Feedback mode</param>
 public Touch(int touchPoints, FeedbackMode mode)
 {
     if (!IsSupported)
     {
         throw new ExternalException("Not Supported on your OS.");
     }
     _contact = new POINTER_TOUCH_INFO();
     _contact.pointerInfo.pointerType = TouchApi.PT_TOUCH;
     _contact.pointerInfo.pointerId   = 0;  //contact 0
     _contact.orientation             = 90; // Orientation of 90 means touching perpendicular to screen.
     _contact.pressure   = 32000;
     _contact.touchFlags = TouchApi.POINTER_FLAG_NONE;
     _contact.touchMask  = TouchApi.TOUCH_MASK_CONTACTAREA |
                           TouchApi.TOUCH_MASK_ORIENTATION | TouchApi.TOUCH_MASK_PRESSURE;
     if (!TouchApi.InitializeTouchInjection((uint)touchPoints, (uint)mode))
     {
         throw new ExternalException("Initialisation failed. Code: " + Marshal.GetLastWin32Error());
     }
 }