如何解决AutoHotkey - 如何注入多点触控单点触控有效
因此,我一直在尝试并设法重新创建“触摸并保持”和“触摸并拖动”事件。但是由于某种原因,我无法创建第二次触摸。我知道代码很乱,我只是想了解每个部分的含义。
我一直在尝试的是在创建第二个触控 ID 时将这部分从 0 更改为 1,但似乎不起作用。
Numput(0,contact1,4,"UInt") ; .pointerInfo.pointerId //contact 0
.
.
.
Numput(1,contact2,"UInt") ; .pointerInfo.pointerId //contact 1
这里是完整的代码供参考,我觉得我错过了一些微不足道的东西。
#Requires AutoHotkey v1.1.33+
is32bit := A_PtrSize = 4
; ****************
; TOUCH 1
; ****************
F2::
; 2] Initialize the Touch Injection API refer code below.
VarSetCapacity(contact1,is32bit ? 136 : 144,0)
TOUCH_FeedBACK_DEFAULT := 0x1
DllCall("InitializetouchInjection","UInt",1,TOUCH_FeedBACK_DEFAULT) ; Here number of contact point is declared as 1.
; 3] Define the contact Point,this deFinition contains contact type,contact location,contact area,pressure and orientation .
PT_TOUCH := 2
Numput(PT_TOUCH,"UInt") ; .pointerInfo.pointerType
Numput(0,"UInt") ; .pointerInfo.pointerId //contact 0
Numput(x := 1200,is32bit ? 24 : 32,"Int") ; .pointerInfo.ptPixelLocation.x // X co-ordinate of touch on screen
Numput(y := 200,is32bit ? 28 : 36,"Int") ; .pointerInfo.ptPixelLocation.y // Y co-ordinate of touch on screen
; #define TOUCH_FLAG_NONE 0x00000000 // Default
TOUCH_FLAG_NONE := 0x00000000
Numput(TOUCH_FLAG_NONE,is32bit ? 88 : 96,"UInt") ; .touchFlags
TOUCH_MASK_CONTACTAREA := 0x00000001
TOUCH_MASK_ORIENTATION := 0x00000002
TOUCH_MASK_PRESSURE := 0x00000004
Numput(TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE,is32bit ? 92 : 100,"UInt") ; .touchMask
Numput(90,is32bit ? 128 : 136,"UInt") ; .orientation // Orientation of 90 means touching perpendicular to screen.
Numput(32000,is32bit ? 132 : 140,"UInt") ; .pressure
; defining contact area (I have taken area of 4 x 4 pixel)
Numput(y - 2,is32bit ? 100 : 108,"Int") ; .rcContact.top
Numput(y + 2,is32bit ? 108 : 116,"Int") ; .rcContact.bottom
Numput(x - 2,is32bit ? 96 : 104,"Int") ; .rcContact.left
Numput(x + 2,is32bit ? 104 : 112,"Int") ; .rcContact.right
; 4] Implementing use case 1,Injecting Touching down on screen.
POINTER_FLAG_DOWN := 0x00010000
POINTER_FLAG_INRANGE := 0x00000002
POINTER_FLAG_INCONTACT := 0x00000004
Numput(POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT,12,"UInt") ; .pointerInfo.pointerFlags
DllCall("InjectTouchInput","Ptr",&contact1) ; Injecting the touch down on screen
; Touch and Hold
POINTER_FLAG_UPDATE := 0x00020000
POINTER_FLAG_INRANGE := 0x00000002
POINTER_FLAG_INCONTACT := 0x00000004
Numput(POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT,"UInt") ; .pointerInfo.pointerFlags
Loop,100
{
DllCall("InjectTouchInput",&contact1) ; Injecting the touch down on screen
Sleep,10
}
return
F3::
; 5] Implementing use case 2,Injecting Touching Up from screen.
POINTER_FLAG_UP := 0x00040000
Numput(POINTER_FLAG_UP,&contact1) ; Injecting the touch Up from screen
return
; ****************
; TOUCH 2
; ****************
F7::
; 2] Initialize the Touch Injection API refer code below.
VarSetCapacity(contact2,TOUCH_FeedBACK_DEFAULT) ; Here number of contact point is declared as 1.
; 3] Define the contact Point,pressure and orientation .
PT_TOUCH := 2
Numput(PT_TOUCH,"UInt") ; .pointerInfo.pointerType
Numput(1,"UInt") ; .pointerInfo.pointerId //contact 1
Numput(x := 1200,"Int") ; .pointerInfo.ptPixelLocation.x // X co-ordinate of touch on screen
Numput(y := 400,&contact2) ; Injecting the touch down on screen
; Touch and Hold
POINTER_FLAG_UPDATE := 0x00020000
POINTER_FLAG_INRANGE := 0x00000002
POINTER_FLAG_INCONTACT := 0x00000004
Numput(POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT,&contact2) ; Injecting the touch down on screen
Sleep,10
}
return
F8::
; 5] Implementing use case 2,&contact2) ; Injecting the touch Up from screen
return
#Esc::
ExitApp
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。