Fix autotype by adding 20ms delay

This commit is contained in:
Bernd Schoolmann 2023-08-20 21:06:19 +02:00
parent 7b0ec5c0a9
commit df82b68856
No known key found for this signature in database
3 changed files with 144 additions and 0 deletions

View File

@ -17,14 +17,18 @@ func (d Dvorak) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyAUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyA)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyB:
keyboard.KeyPress(uinput.KeyN)
break
case KeyBUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyN)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyC:
keyboard.KeyPress(uinput.KeyI)
@ -38,7 +42,9 @@ func (d Dvorak) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyDUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyH)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyE:
keyboard.KeyPress(uinput.KeyD)
@ -52,147 +58,189 @@ func (d Dvorak) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyFUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyY)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyG:
keyboard.KeyPress(uinput.KeyU)
break
case KeyGUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyU)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyH:
keyboard.KeyPress(uinput.KeyJ)
break
case KeyHUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyJ)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyI:
keyboard.KeyPress(uinput.KeyG)
break
case KeyIUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyG)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyJ:
keyboard.KeyPress(uinput.KeyC)
break
case KeyJUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyC)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyK:
keyboard.KeyPress(uinput.KeyV)
break
case KeyKUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyV)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyL:
keyboard.KeyPress(uinput.KeyP)
break
case KeyLUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyP)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyM:
keyboard.KeyPress(uinput.KeyM)
break
case KeyMUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyM)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyN:
keyboard.KeyPress(uinput.KeyL)
break
case KeyNUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyL)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyO:
keyboard.KeyPress(uinput.KeyS)
break
case KeyOUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyS)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyP:
keyboard.KeyPress(uinput.KeyR)
break
case KeyPUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyR)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyQ:
keyboard.KeyPress(uinput.KeyX)
break
case KeyQUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyX)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyR:
keyboard.KeyPress(uinput.KeyO)
break
case KeyRUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyO)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyS:
keyboard.KeyPress(uinput.KeySemicolon)
break
case KeySUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeySemicolon)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyT:
keyboard.KeyPress(uinput.KeyK)
break
case KeyTUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyK)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyU:
keyboard.KeyPress(uinput.KeyF)
break
case KeyUUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyF)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyV:
keyboard.KeyPress(uinput.KeyDot)
break
case KeyVUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyDot)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyW:
keyboard.KeyPress(uinput.KeyComma)
break
case KeyWUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyComma)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyX:
keyboard.KeyPress(uinput.KeyB)
break
case KeyXUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyB)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyY:
keyboard.KeyPress(uinput.KeyT)
break
case KeyYUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyT)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyZ:
keyboard.KeyPress(uinput.KeySlash)
break
case KeyZUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.ButtonBumperLeft)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case Key1:
keyboard.KeyPress(uinput.Key1)
@ -232,42 +280,58 @@ func (d Dvorak) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyExclamationMark:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key1)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyAtSign:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key2)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyHash:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key3)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyDollar:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key4)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyPercent:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key5)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyCaret:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key6)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyAmpersand:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key7)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyAsterisk:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key8)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyDot:
@ -278,7 +342,9 @@ func (d Dvorak) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyQuestionMark:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyLeftbrace)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeySemicolon:
@ -286,7 +352,9 @@ func (d Dvorak) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyColon:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyZ)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeySlash:

View File

@ -17,182 +17,234 @@ func (d Qwerty) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyAUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyA)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyB:
keyboard.KeyPress(uinput.KeyB)
break
case KeyBUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyB)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyC:
keyboard.KeyPress(uinput.KeyC)
break
case KeyCUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyC)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyD:
keyboard.KeyPress(uinput.KeyD)
break
case KeyDUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyD)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyE:
keyboard.KeyPress(uinput.KeyE)
break
case KeyEUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyE)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyF:
keyboard.KeyPress(uinput.KeyF)
break
case KeyFUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyF)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyG:
keyboard.KeyPress(uinput.KeyG)
break
case KeyGUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyG)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyH:
keyboard.KeyPress(uinput.KeyH)
break
case KeyHUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyH)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyI:
keyboard.KeyPress(uinput.KeyI)
break
case KeyIUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyI)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyJ:
keyboard.KeyPress(uinput.KeyJ)
break
case KeyJUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyJ)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyK:
keyboard.KeyPress(uinput.KeyK)
break
case KeyKUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyK)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyL:
keyboard.KeyPress(uinput.KeyL)
break
case KeyLUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyL)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyM:
keyboard.KeyPress(uinput.KeyM)
break
case KeyMUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyM)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyN:
keyboard.KeyPress(uinput.KeyN)
break
case KeyNUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyN)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyO:
keyboard.KeyPress(uinput.KeyO)
break
case KeyOUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyO)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyP:
keyboard.KeyPress(uinput.KeyP)
break
case KeyPUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyP)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyQ:
keyboard.KeyPress(uinput.KeyQ)
break
case KeyQUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyQ)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyR:
keyboard.KeyPress(uinput.KeyR)
break
case KeyRUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyR)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyS:
keyboard.KeyPress(uinput.KeyS)
break
case KeySUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyS)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyT:
keyboard.KeyPress(uinput.KeyT)
break
case KeyTUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyT)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyU:
keyboard.KeyPress(uinput.KeyU)
break
case KeyUUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyU)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyV:
keyboard.KeyPress(uinput.KeyV)
break
case KeyVUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyV)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyW:
keyboard.KeyPress(uinput.KeyW)
break
case KeyWUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyW)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyX:
keyboard.KeyPress(uinput.KeyX)
break
case KeyXUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyX)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyY:
keyboard.KeyPress(uinput.KeyY)
break
case KeyYUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyY)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case KeyZ:
keyboard.KeyPress(uinput.KeyZ)
break
case KeyZUpper:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeyZ)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
case Key1:
keyboard.KeyPress(uinput.Key1)
@ -232,42 +284,58 @@ func (d Qwerty) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyExclamationMark:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key1)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyAtSign:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key2)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyHash:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key3)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyDollar:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key4)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyPercent:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key5)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyCaret:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key6)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyAmpersand:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key7)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyAsterisk:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.Key8)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeyDot:
@ -278,7 +346,9 @@ func (d Qwerty) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyQuestionMark:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeySlash)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeySemicolon:
@ -286,7 +356,9 @@ func (d Qwerty) TypeKey(key Key, keyboard uinput.Keyboard) error {
break
case KeyColon:
keyboard.KeyDown(uinput.KeyLeftshift)
Sleep()
keyboard.KeyPress(uinput.KeySemicolon)
Sleep()
keyboard.KeyUp(uinput.KeyLeftshift)
break
case KeySlash:

View File

@ -169,3 +169,7 @@ func Paste(layout string) error {
keyboard.KeyUp(uinput.KeyLeftctrl)
return nil
}
func Sleep() {
time.Sleep(20 * time.Millisecond)
}