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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...