Suppress auto repeat in THM (TapHoldManager)
Posted: 25 May 2022, 15:56
Hi. I have THM installed, it seems to be working normally, but I'm not being able to implement something like if letter m is hold, send shift down; when released, send shift up. Basically, I want to be able to use the letter m as shift when pressed down.
Here is the script I'm trying:
The problem I run into is that although shift gets pressed when holding m (it could be any other key or at least the alphanumeric keys), m is sent as well and it doesn't send shift up upon release from hold, so what happens is that it starts to spam "MMMMMMMMMMMMMMMMM" and when I release m, shift is still down, stuck.
I really don't know what i'm doing wrong, I thought ascribing a key to THM would block it so it wouldn't send the letter unless I added it to the function. When instead of making a "key down; key up" pair it works normally, I hold the key and it's only sent once and sends something else if I make an if with state=0 (release). But I don't know how to implement what I want in this case.
Searching on this forum I found this post by evilC: viewtopic.php?t=45020 in which he teaches how to suppress repetition of hotkeys:
And it works flawlessly. But I don't know how to adapt it to work with THM's ishold, taps, state. I don't even know if it's possible to adapt it.
Could a brighter mind please help me? Should I post this on THM's own topic? Thanks in advance!
Here is the script I'm trying:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance Force ; Forces to keep only one version of the script active at a time
#include <TapHoldManager> ; Initializes the TMH library
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
thm := new TapHoldManager() ; TapTime/Prefix can now be set here
thm.Add("m", Func("func1"))
Func1(isHold, taps, state){
if (isHold=0) & (taps=1) & (state){
Send, m
}
if (isHold=1) & (taps=1) & (state=1){
Send, {Shift down}
}
if (isHold=1) & (taps=1) & (state=0){
Send, {Shift up}
}
I really don't know what i'm doing wrong, I thought ascribing a key to THM would block it so it wouldn't send the letter unless I added it to the function. When instead of making a "key down; key up" pair it works normally, I hold the key and it's only sent once and sends something else if I make an if with state=0 (release). But I don't know how to implement what I want in this case.
Searching on this forum I found this post by evilC: viewtopic.php?t=45020 in which he teaches how to suppress repetition of hotkeys:
Code: Select all
rcState := 0
akState := 0
*<#RCtrl:: ; LeftWin + RightControl => Left-click (hold down Control/Shift to Control-Click or Shift-Click).
if (rcState)
return ; Suppress repeats
rcState := 1
SendEvent {Blind}{LButton down}
return
*<#RCtrl up::
SendEvent {Blind}{LButton up}
rcState := 0
return
*<#AppsKey:: ; LeftWin + AppsKey => Right-click
if (akState)
return
akState := 1
SendEvent {Blind}{RButton down}
return
*<#AppsKey up::
SendEvent {Blind}{RButton up}
akState := 0
return
Could a brighter mind please help me? Should I post this on THM's own topic? Thanks in advance!