Please help. I have a keyboard (Rapoo E9260) with a defect: characters are randomly doubled when I type. I need a way to fix this defect. Perhaps an .ahk script.
For example, if a character "a" is entered and the same character is entered after less than 150 milliseconds, then the extra character will be deleted, or the "aa" will be replaced with "a". Else, if the interval between inputs is more than 150 milliseconds – no action.
Sample (not working):
#NoEnv
SendMode Input
previousKey := ""
previousTime := 0
SetTimer, DeleteDuplicate, -150
DeleteDuplicate:
currentTime := A_TickCount
if (currentTime - previousTime < 150)
{
SendInput {Backspace}
SendInput {%previousKey%}
}
previousKey := ""
previousTime := 0
return
$*::
currentKey := A_ThisHotkey
currentTime := A_TickCount
if (currentKey = previousKey && currentTime - previousTime < 150)
{
previousKey := currentKey
previousTime := currentTime
return
}
previousKey := currentKey
previousTime := currentTime
return
#NoEnv
#SingleInstance Force
#UseHook
keys = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0 ;...
Loop,Parse,keys, `,
Hotkey, %A_LoopField%, DeleteDuplicate
return
DeleteDuplicate:
If (A_PriorHotKey = A_ThisHotkey AND A_TimeSincePriorHotkey < 300)
return ; don't send it
SendInput, %A_ThisHotkey%
return
EDIT:
If you are using multiple keyboard layouts for different languages, replace each key in "keys" by its scancode and SendInput, %A_ThisHotkey%
by SendInput, {%A_ThisHotkey%}
.
E.g. on my system SC01E is the scancode for the a key, SC030 for b, SC02E for c, SC020 for d, and this works in all keyboard layouts:
#NoEnv
#SingleInstance Force
#UseHook
keys = SC01E,SC030,SC02E,SC020
Loop,Parse,keys, `,
Hotkey, %A_LoopField%, DeleteDuplicate
return
DeleteDuplicate:
If (A_PriorHotKey = A_ThisHotkey AND A_TimeSincePriorHotkey < 300)
return ; don't send it
SendInput, {%A_ThisHotkey%}
return
And make sure that your script is saved as UTF-8 with BOM.