commit
b3f76fb2b8
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.13.2" targetFramework="net48" />
|
||||
<package id="NUnit3TestAdapter" version="4.2.0" targetFramework="net48" />
|
||||
</packages>
|
@ -0,0 +1,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
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
This code illustrates how to detect movement and mouse event information coming from a Tablet
|
||||
Bear in mind that when AHI receives input from a tablet...
|
||||
... the "packet" of information always includes movement AND button state information
|
||||
When AHI fires the callbacks, it always fires movement callbacks before button callbacks...
|
||||
... so you can be sure that when ButtonEvent() fires, it always has the latest coordinates
|
||||
*/
|
||||
#SingleInstance force
|
||||
#Persistent ; If you have no hotkeys or GUI in the script, you need this else the script will instantly exit
|
||||
#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("ButtonEvent"))
|
||||
; Subscribe to movement coming from the tablet
|
||||
AHI.SubscribeMouseMoveAbsolute(mouseId, true, Func("OnMouseMove"))
|
||||
return
|
||||
|
||||
ButtonEvent(state){
|
||||
global lastX, lastY
|
||||
tooltip % "LMB State: " state " ( Event was at " lastX ", " lastY " )", 0, 30, 2
|
||||
}
|
||||
|
||||
; Store coordinates on move, so they can be used in ButtonEvent
|
||||
OnMouseMove(x, y){
|
||||
global lastX, lastY
|
||||
lastX := x
|
||||
lastY := y
|
||||
tooltip % "Coords: " x ", " y, 0, 0, 1
|
||||
}
|
||||
|
||||
^Esc::
|
||||
ExitApp
|
@ -0,0 +1,58 @@
|
||||
#SingleInstance force
|
||||
;~ #Persistent
|
||||
#include Lib\AutoHotInterception.ahk
|
||||
|
||||
;~ pk := GetKeySC("Pause")
|
||||
;~ dk := GetKeySC("Delete")
|
||||
;~ RCtrl := GetKeySC("RCtrl")
|
||||
msgbox % GetKeySC("ScrollLock")
|
||||
;~ return
|
||||
;~ msgbox % Format("{:d}", GetKeySC("Pause"))
|
||||
return
|
||||
|
||||
clipboard := ""
|
||||
log := "`n// ============ DUPES ==================`n"
|
||||
keys := {}
|
||||
|
||||
Loop 512 {
|
||||
hex := Format("{:x}", A_Index)
|
||||
name := GetKeyName("sc" hex)
|
||||
if (name == "")
|
||||
continue
|
||||
str := "{" A_Index " /*(0x" hex ")*/, " """" name """" "}"
|
||||
;~ if (A_Index == 86 || A_Index = 342)
|
||||
;~ break = true
|
||||
if (keys.HasKey(name)){
|
||||
log .= "// " str " (Also " keys[name] ")`n"
|
||||
} else {
|
||||
clipboard .= str ",`n"
|
||||
keys[name] := A_Index
|
||||
}
|
||||
}
|
||||
clipboard .= log
|
||||
return
|
||||
state := true
|
||||
AHI := new AutoHotInterception()
|
||||
|
||||
;~ keyboardId := AHI.GetKeyboardId(0x04F2, 0x0112)
|
||||
;~ AHI.SubscribeKey(keyboardId, GetKeySC("1"), true, Func("KeyEvent"))
|
||||
mouseId := AHI.GetMouseId(0x046D, 0xC00C)
|
||||
AHI.SubscribeMouseMove(mouseId, true, Func("OnMouseMove"))
|
||||
return
|
||||
|
||||
KeyEvent(state){
|
||||
ToolTip % "State: " state
|
||||
}
|
||||
|
||||
OnMouseMove(x, y){
|
||||
Tooltip % x ", " y, 0, 0
|
||||
}
|
||||
|
||||
F1::
|
||||
state := !state
|
||||
AHI.SetState(state)
|
||||
Tooltip
|
||||
return
|
||||
|
||||
^Esc::
|
||||
ExitApp
|
Loading…
Reference in New Issue