TapHoldManager - Long Press / Multi Tap / Multi Tap and Hold / Any number of Taps / Multi-Keyboard / Joystick buttons

Post your working scripts, libraries and tools

tfpp
Posts: 2
Joined: 27 Dec 2020, 03:28

Re: TapHoldManager - Long Press / Multi Tap / Multi Tap and Hold / Any number of Taps / Multi-Keyboard / Joystick button

Post by tfpp » 27 Dec 2020, 03:47

Has anyone managed to evilC's THM to reprogram the surface pen side buttons?
I would like to double click the lower side button to map to undo previous action, i.e. CTRL-Z

Avastgard
Posts: 54
Joined: 30 Sep 2016, 21:54

Re: TapHoldManager - Long Press / Multi Tap / Multi Tap and Hold / Any number of Taps / Multi-Keyboard / Joystick button

Post by Avastgard » 03 Jan 2021, 15:17

evilC wrote:
27 Jun 2020, 20:11
Only support for the same key is built into the library, but no reason you could not implement that functionality yourself by just subscribing to e and space, and only enabling the space subscription once e was tapped twice

Code: Select all

#include Lib\TapHoldManager.ahk

thm := new TapHoldManager()

thm.add("e", func("eFunc")) 
thm.add("Space", func("spaceFunc"))
thm.PauseHotkey("Space")

eFunc(isHold, taps, state){
    global thm
    if (taps == 2 && !isHold){
        thm.ResumeHotkey("Space")
    }
}

spaceFunc(isHold, taps, state){
    global thm
    if (taps == 1 && isHold && state){
        thm.PauseHotkey("Space")
        Msgbox You tapped e twice then held space
    }
}

Hi there, and sorry it took me so long to report back, but I only managed to test this now. Your pass-through code worked fine, but I had to change one isHold to taps to get it working.

The quoted part of the code you provided (tap followed by hold) worked, but apparently it only works every other time (works once, doesn't work the next time, works the following time). Do you have any idea why this is happening and how to fix it?

Edit: quoted the wrong code

Post Reply

Return to “Scripts and Functions”