Advertisement
Guest User

Untitled

a guest
Jan 18th, 2016
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     #SingleInstance Force
  2.     #UseHook
  3.     SurfacePenBegin()
  4.     Return
  5.  
  6. ; trap pen taps with the top button pressed
  7. #If (SurfacePenState = "tap down with upper side button pressed (seen in AutoHotkey as RButton event)")
  8. RButton::{WheelUp 1}
  9.  
  10. ; trap pen taps with the bottom button pressed
  11. #If (SurfacePenState = "tap down with bottom side button pressed (seen in AutoHotkey as LButton event)")
  12. LButton::{WheelDown 1}
  13.  
  14. ; initialize to trap input messages
  15.   SurfacePenBegin( )
  16.   {
  17.     Global SurfacePenState
  18.     SurfacePenState := ""
  19.     AHKHID_Register(1, 2, A_ScriptHwnd, RIDEV_INPUTSINK := 0x00000100)
  20.     OnMessage(WM_INPUT := 0xFF, "SurfacePenEvent")
  21.   }
  22.  
  23. ; trap wm_input messages and analyze them
  24.   SurfacePenEvent( wParam, lParam, msg, hwnd )
  25.   {
  26.     Global SurfacePenState
  27.     Critical
  28.     AnyType := AHKHID_GetInputInfo(lParam, II_DEVTYPE := 0)
  29.     AnyFlag := AHKHID_GetInputInfo(lParam, II_MSE_FLAGS := (08 + A_PtrSize * 2) | 0x0100)
  30.     AnyButt := AHKHID_GetInputInfo(lParam, II_MSE_BUTTONFLAGS := ((12 + A_PtrSize * 2) | 0x0100))
  31.     AnyData := AHKHID_GetInputInfo(lParam, II_MSE_EXTRAINFO := 28 + A_PtrSize * 2)
  32.     SurfacePenState := ""
  33.     If (AnyType = 0 And AnyFlag <> 0 And AnyButt <> 0)
  34.     {
  35.       If (AnyButt = 1 And (AnyData & 3) = 2)
  36.         SurfacePenState := "tap down with no side button pressed (seen in AutoHotkey as LButton event)"
  37.       If (AnyButt = 2 And (AnyData & 3) = 2)
  38.         SurfacePenState := "tap up with no side button pressed (seen in AutoHotkey as LButton up event)"
  39.       If (AnyButt = 1 And (AnyData & 3) = 3)
  40.         SurfacePenState := "tap down with bottom side button pressed (seen in AutoHotkey as LButton event)"
  41.       If (AnyButt = 2 And (AnyData & 3) = 3)
  42.         SurfacePenState := "tap up with bottom side button pressed (seen in AutoHotkey as LButton up event)"
  43.       If (AnyButt = 4)
  44.         SurfacePenState := "tap down with upper side button pressed (seen in AutoHotkey as RButton event)"
  45.       If (AnyButt = 8)
  46.         SurfacePenState := "tap up with upper side button pressed (seen in AutoHotkey as RButton up event)"
  47.       OutputDebug, SurfacePenEvent [%SurfacePenState%]
  48.     }
  49.   }
  50.  
  51.  
  52. #Include <hidfuncs>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement