Keyboard button to graphic tablet button (AHKHID)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mk08ki
Posts: 2
Joined: 25 Mar 2017, 08:58

Keyboard button to graphic tablet button (AHKHID)

25 Mar 2017, 12:34

Hello! I have wacom graphic tablet with buttons that trigger specific functions (display toggle, etc), with AHKHID (https://github.com/jleb/AHKHID/blob/mas ... ntation.md) I was able to detect tablet buttons and make them trigger keyboard buttons. Now I'm trying to make it work the other way, but I feel like I don't have enough knowledge of AHK to do it, and I was hoping someone could help me, or point me in the right direction.

Here's the script that triggers keyboard button with tablet button, I've tried to map keys to Button_1, but none of that works, perhaps the script is not fit to work in reverse?

Code: Select all

;Loads the required AHKHID Script
#Include 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(65280, 10, 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 Wacom Graphic Tablet
        And (AHKHID_GetDevInfo(devh, DI_DEVTYPE, True) = RIM_TYPEHID)
        And (AHKHID_GetDevInfo(devh, DI_HID_VENDORID, True) = 1386)
        And (AHKHID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = 855)
        And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 291) 
    {
       
        ;Get data
        iKey := AHKHID_GetInputData(lParam, uData)
       
        ;Check for error
        If (iKey <> -1) 
	{
		byte1 := NumGet(uData, 1, "UChar")
		byte2 := NumGet(uData, 2, "UChar")
		byte3 := NumGet(uData, 3, "UChar")
		byte4 := NumGet(uData, 4, "UChar")

		sLabel := "UNDEFINED"
		
		If(byte1 = 0x13 And byte2 = 0x64 And byte3 = 0x0 And byte4 = 0x0)
			sLabel := "RELEASE"
		
		If(byte1 = 0x11 And byte2 = 0x1 And byte3 = 0x1 And byte4 = 0x0)
			sLabel := "Button_1"
					
		If IsLabel(sLabel)
			Gosub, %sLabel%
			
        }
    }
}

RELEASE: 	; Key released event
Return

Button_1: 	;  Top button 1
	SendInput {Enter}
Return
mk08ki
Posts: 2
Joined: 25 Mar 2017, 08:58

Re: Keyboard button to graphic tablet button (AHKHID)

26 Mar 2017, 05:33

I guess it is not possible with this script.
Now the question is, would it be possible to write AHK script that emulates input (assuming I know the values that tablet sends on button press)?
lampdoors
Posts: 5
Joined: 11 May 2020, 10:53

Re: Keyboard button to graphic tablet button (AHKHID)

11 May 2020, 12:51

Did you ever figure this out?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Hansielein, Lpanatt and 320 guests