3

我能够成功注入指针/触摸消息,但无法接收在应用程序上注入的所有消息(在应用程序中捕获消息),即使所有消息都已成功注入而没有任何错误。请为该问题提供任何建议/解决方案。

InitializeTouchInjection(10, TOUCH_FEEDBACK_INDIRECT);

//
// initialize the touch info structure
//
memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));

contact.pointerInfo.pointerType = PT_TOUCH; //we're sending touch input
contact.pointerInfo.pointerId = 0;          //contact 0
contact.pointerInfo.ptPixelLocation.x = 300;
contact.pointerInfo.ptPixelLocation.y = 300;
contact.pointerInfo.pointerFlags = POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
contact.touchFlags = TOUCH_FLAG_NONE;
contact.touchMask = TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
contact.orientation = 90;
contact.pressure = 32000;

//
// set the contact area depending on thickness
//
// 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;
//
// inject a touch down
//
bRet = InjectTouchInput(1, &contact);

//Setting the Pointer Flag to Drag

contact.pointerInfo.pointerFlags = POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
bRet = InjectTouchInput(1, &contact);
for(int i=0;i<100;i++)
{

    contact.pointerInfo.ptPixelLocation.y--; 
    bRet =InjectTouchInput(1, &contact);
}
//
// if touch down was succesfull, send a touch up
//
if (bRet) {
    contact.pointerInfo.pointerFlags = POINTER_FLAG_UP;

    //
    // inject a touch up
    //
    InjectTouchInput(1, &contact);
}
4

0 回答 0