Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance Force
- #UseHook
- SurfacePenBegin()
- Return
- ; trap pen taps with the top button pressed
- #If (SurfacePenState = "tap down with upper side button pressed (seen in AutoHotkey as RButton event)")
- RButton::{MButton down}
- #If (SurfacePenState = "tap up with upper side button pressed (seen in AutoHotkey as RButton event)")
- RButton::{MButton up}
- ; initialize to trap input messages
- SurfacePenBegin( )
- {
- Global SurfacePenState
- SurfacePenState := ""
- AHKHID_Register(1, 2, A_ScriptHwnd, RIDEV_INPUTSINK := 0x00000100)
- OnMessage(WM_INPUT := 0xFF, "SurfacePenEvent")
- }
- ; trap wm_input messages and analyze them
- SurfacePenEvent( wParam, lParam, msg, hwnd )
- {
- Global SurfacePenState
- Critical
- AnyType := AHKHID_GetInputInfo(lParam, II_DEVTYPE := 0)
- AnyFlag := AHKHID_GetInputInfo(lParam, II_MSE_FLAGS := (08 + A_PtrSize * 2) | 0x0100)
- AnyButt := AHKHID_GetInputInfo(lParam, II_MSE_BUTTONFLAGS := ((12 + A_PtrSize * 2) | 0x0100))
- AnyData := AHKHID_GetInputInfo(lParam, II_MSE_EXTRAINFO := 28 + A_PtrSize * 2)
- SurfacePenState := ""
- If (AnyType = 0 And AnyFlag <> 0 And AnyButt <> 0)
- {
- If (AnyButt = 1 And (AnyData & 3) = 2)
- SurfacePenState := "tap down with no side button pressed (seen in AutoHotkey as LButton event)"
- If (AnyButt = 2 And (AnyData & 3) = 2)
- SurfacePenState := "tap up with no side button pressed (seen in AutoHotkey as LButton up event)"
- If (AnyButt = 1 And (AnyData & 3) = 3)
- SurfacePenState := "tap down with bottom side button pressed (seen in AutoHotkey as LButton event)"
- If (AnyButt = 2 And (AnyData & 3) = 3)
- SurfacePenState := "tap up with bottom side button pressed (seen in AutoHotkey as LButton up event)"
- If (AnyButt = 4)
- SurfacePenState := "tap down with upper side button pressed (seen in AutoHotkey as RButton event)"
- If (AnyButt = 8)
- SurfacePenState := "tap up with upper side button pressed (seen in AutoHotkey as RButton up event)"
- OutputDebug, SurfacePenEvent [%SurfacePenState%]
- }
- }
- #Include <hidfuncs>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement