-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathSubscribeAbsolute dragging example.ahk
More file actions
56 lines (52 loc) · 1.73 KB
/
SubscribeAbsolute dragging example.ahk
File metadata and controls
56 lines (52 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
This code illustrates how to process drags (Press down pen and move) with a tablet
*/
#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk
Coordmode, Tooltip, Screen
; Initialize AHI
AHI := new AutoHotInterception()
mouseId := AHI.GetMouseId(0x0B57, 0x9091) ; Get VID/PID of your device from the Monitor app and paste it in here
; Subscribe to the "Left Mouse" (AKA pressing the pen on the tablet) event from the tablet
AHI.SubscribeMouseButton(mouseId, 0, true, Func("ProcessInput"))
; Subscribe to movement coming from the tablet
; We use .Bind("") here to pass "" to the newState parameter of the function
AHI.SubscribeMouseMoveAbsolute(mouseId, true, Func("ProcessInput").Bind(""))
return
ProcessInput(newState, nx := "", ny := ""){
static state := 0
static x := 0, y := 0
if (newState != "" && newState != state){
stateChanged := 1
state := newState
} else {
stateChanged := 0
}
if (nx != ""){
x := nx
y := ny
}
; At this point, regardless of whether the input was a move or click, the following variables tell us what has happened:
; x and y hold current x and current y
; state is the current state of the button
; stateChanged indicates whether state just changed or not
; ---- Start of your code ----
static dragStartX, dragStartY
tooltip % "Current Coords: " x ", " y, 0, 0, 1
if (stateChanged){
if (state){
; Process start of drag here
dragStartX := x
dragStartY := y
} else {
; Process end of drag here
tooltip % "NOT DRAGGING. Last drag was: x " x - dragStartX ", y " y - dragStartY, 0, 30, 2
}
} else if (state){
; If you want to do something during a drag, you would do it here
tooltip % "DRAGGING: dragged x " x - dragStartX ", y " y - dragStartY, 0, 30, 2
}
}
^Esc::
ExitApp