01-31-2026, 07:39 PM
A starting point.
Function Long_press_key_trigger
Function Long_press_key_trigger
int hh=SetWindowsHookEx(WH_KEYBOARD_LL &sub.Hook _hinst 0)
opt waitmsg 1
wait -1
UnhookWindowsHookEx hh
#sub Hook
function# nCode message KBDLLHOOKSTRUCT&k
if(nCode<0) goto gNext
if(k.flags&LLKHF_INJECTED) goto gNext
;FormatKeyString k.vkCode 0 &_s; out "%s %s%s" _s iif(k.flags&LLKHF_UP "up" "down") iif(k.flags&LLKHF_INJECTED ", injected" "") ;;debug
sel k.vkCode
,case ['A','E','I','O','U'] ;;TODO: edit if need. Note: these are keys (US or similar keyboard), not characters.
,case else goto gNext
int-- t_key t_time t_triggerOnce
if !(k.flags&LLKHF_UP) ;;key down
,if k.vkCode!=t_key or k.time-t_time>10000
,,t_key=k.vkCode
,,t_time=k.time
,,t_triggerOnce=0
,,;out "key down: %c" k.vkCode
,else
,,if !t_triggerOnce and k.time-t_time>=950 ;;TODO: edit the trigger time 950 ms if need
,,,t_triggerOnce=1
,,,mac "sub.Triggered" "" k.vkCode
,,,;note: this code uses the auto-repeat feature. Will not work if it is turned off.
,,,
,,ret 1 ;;prevent auto-repeat
else ;;key up
,t_key=0
;gNext
ret CallNextHookEx(0 nCode message &k)
#sub Triggered
function vk
key B ;;Backspace erases the character
out "trigger for key: %c" vk
;TODO: add your code here
;example: replace 'a' with 'ą'
int upper=ifk(S)^ifk(K 1)
sel vk
,case 'A'
,if(upper) key "Ą"; else key "ą"
,
,case 'E'
,;...