AutoHotkey - 如何注入多点触控单点触控有效

如何解决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.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?