Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Wacom Stylus Middle Mouse Button Emulation


  • Please log in to reply
No replies to this topic
specter333
  • Members
  • 627 posts
  • Last active: Oct 07 2016 07:43 AM
  • Joined: 15 Jan 2007
I use a older tablet on the road quite a bit, a HP TC1100. I'm sure it could be used on other models that don't have a center click. This script emulates having a middle mouse button by setting the stylus on the screen(as if left clicking) then clicking the stylus (rightclick) button.

This script needs the AHKHID functions to be included to work correctly. This is an adaptation of a script from TheGood for using input from HID devices other than mice and keyboards. Credit and a big thank you for letting me use it goes to him.
http://www.autohotke...t=41397&start=0

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance, Force
;Must be in auto-execute section if I want to use the constants
#Include C:\Program Files\AutoHotkey\lib\AHKHID.ahk

;Create GUI to receive messages
Gui, +LastFound
hGui := WinExist()


;Intercept WM_INPUT messages
WM_INPUT := 0xFF
OnMessage(WM_INPUT, "InputMsg")

;Register Remote Control with RIDEV_INPUTSINK (so that data is received even in the background)
r := AHKHID_Register(13, 2, hGui, RIDEV_INPUTSINK)

InputMsg(wParam, lParam) {
    Local devh, iKey, sLabel
   
    Critical
   
    ;Get handle of device
    devh := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
   
    ;Check for error
    If (devh <> -1) ;Check that it is my HP remote
        And (AHKHID_GetDevInfo(devh, DI_DEVTYPE, True) = RIM_TYPEHID)
        And (AHKHID_GetDevInfo(devh, DI_HID_VENDORID, True) = 23587)
        And (AHKHID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = 0)
        And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 175) {
       
        ;Get data
        iKey := AHKHID_GetInputData(lParam, uData)
       
        ;Check for error
        If (iKey <> -1) {
           
            ;Get keycode (located at the 6th byte)
            iKey := NumGet(uData, 1, "UChar")
           
            ;Call the appropriate sub if it exists
            sLabel := sPrefix "_" iKey
            If IsLabel(sLabel)
                Gosub, %sLabel%
			;MsgBox, %sLabel%		
			}
    }
}

_161:
change163 = Yes
SetTimer, go163, 250
Return

_163:
If change163 = Yes
	{
	SetTimer, go163, off
	change163 = off
	MouseClick, M
	;Run, C:\Documents and Settings\Owner\My Documents\Incremental Build 1-1-2010\OSNP\OSNP.ahk
	GoTo go163
	}
Return

go163:
Sleep, 1000
change163 = off
SetTimer, go163, off
Return