0

I am trying to remap the button on the Samsung Galaxy Book Pen using AutoHotKey but I can't work out the button code.

So far I have remapped the ctrl key and the "left click" to be right click, but I just want to be able to press the button or even press button and pen down (left click) at the same time.

Would anyone know the key code or know a program I can use to find it out.

I have tried using similar code as for the Surface pro but it doesn't seem to work.

Code I have so far is:

^LButton::RButton
return

Code example from Surface was

#f20::Rbutton
return

Thanks

drume
  • 33
  • 10
  • likely it is impossible without the device having software on its own. My guess is it is hard coded to be a mouse button on the pen. So AHK will always see it as a mouse click. – Zack Tarr Mar 01 '18 at 20:33
  • I know I have seen a question before in regards to the issues I mentioned. But I cant find it. I did fine a possible solution to the issue though. See [here](https://stackoverflow.com/questions/47758315/lua-macros-for-second-keyboard) – Zack Tarr Mar 01 '18 at 20:38
  • I checked out HIDMacros, while I don't know how to remap to right click yet it did return me the trigger of the button being Mouse1 18(). Do you think that is something AHK might understand? – drume Mar 02 '18 at 11:48
  • How does that click compare to the click on your mouse? – Zack Tarr Mar 02 '18 at 13:44
  • The trackpad triggered as keyb1 Right button down. – drume Mar 03 '18 at 14:29

1 Answers1

1

This is for anyone looking for a way around this, that includes modifiers useage (useful for pretty much any and all drawing app). It's not perfect, but I hope this can help you and everyone else looking to restore the right click function. This works on the current Book 3 models and alt pens.

SendMode Input
SetWorkingDir %A_ScriptDir%

global PEN_NOT_HOVERING := 0x0 ; Pen away from screen.
global sPen_Thread := 0 
;global sPen_Timer := 0 ;OFF Timer to figure out right button hold
global sPen_RBtn := 0 ; Store right button click

; Send Alt, Ctrl and Shift keys along with the right-click if necessary
SendModifierKeys() {
    static lastAlt := 0
    static lastCtrl := 0
    static lastShift := 0
    AltState := GetKeyState("Alt")
    CtrlState := GetKeyState("Ctrl")
    ShiftState := GetKeyState("Shift")
    
    if (AltState <> lastAlt) {
        if (AltState) {
            Send {Alt Down}
        } else {
            Send {Alt Up}
        }
    lastAlt := AltState
    }

    if (CtrlState <> lastCtrl) {
        if (CtrlState) {
        Send {Ctrl Down}
        } else {
        Send {Ctrl Up}
        }
    lastCtrl := CtrlState
    }

    if (ShiftState <> lastShift) {
        if (ShiftState) {
            Send {Shift Down}
        } else {
        Send {Shift Up}
        }
    lastShift := ShiftState
    }
}

TimerThreadEnd() {
    SetTimer, TimerThreadEnd, Off
    sPen_Thread := 0
    
    if (sPen_RBtn <> 0){ ; Right button pressed
        SendModifierKeys() ;send modifier if pressed
        Send {RButton Up} ;button released
    }
}
TimerThreadOn(){
    sPen_Thread := 1 ;active
    SetTimer, TimerThreadEnd, 30 ; 30 milliseconds
}

#include AHKHID.ahk

WM_INPUT := 0xFF
USAGE_PAGE := 13
USAGE := 2

AHKHID_UseConstants()

AHKHID_AddRegister(1)
AHKHID_AddRegister(USAGE_PAGE, USAGE, A_ScriptHwnd, RIDEV_INPUTSINK)
AHKHID_Register()

OnMessage(WM_INPUT, "Work")

Work(wParam, lParam) {
    Local type, inputInfo, inputData, raw, proc
    static lastInput := PEN_NOT_HOVERING
    static penIn := 0

    Critical

    type := AHKHID_GetInputInfo(lParam, II_DEVTYPE)

    if (type = RIM_TYPEHID) {
        inputData := AHKHID_GetInputData(lParam, uData)
    ;TimerThreadOn() ;off this triggers unwanted right clicks using eraser
    raw := NumGet(uData, 0, "UInt")
        proc := (raw >> 0) & 0xFFFF

    if (proc <> lastInput) {
        
    if (proc == 10242) { ;need to figure out what this number does
        ;sPen_RBtn := 1 ;OFF
        ;SendModifierKeys() ;OFF
        ;Send {RButton Down} ;OFF 
        if (lastInput = 8194) { 
        SendModifierKeys()
        Click right
        ;Send {RButton Up} 
        }
    ;sPen_RBtn := 0
        }
        lastInput := proc
    }
    }
}
Cribble
  • 11
  • 1