Fix: random jitter for command

This commit is contained in:
MaMe82 2018-11-23 17:18:51 +01:00
parent 2bf2596fad
commit ffca3c079f
2 changed files with 1 additions and 2 deletions

View File

@ -407,7 +407,7 @@ func (ctl *HIDController) jsLayout(call otto.FunctionCall) (res otto.Value) {
func (ctl *HIDController) jsTypingSpeed(call otto.FunctionCall) (res otto.Value) {
if ctl.Keyboard == nil { log.Println(ErrNoKeyboard); oErr,_ := otto.ToValue(ErrNoKeyboard); return oErr }
typeDelay := call.Argument(0) //delay between keypresses in milliseconds
typeJitter := call.Argument(0) //additional random jitter between keypresses, maximum in milliseconds
typeJitter := call.Argument(1) //additional random jitter between keypresses, maximum in milliseconds
if delay,err:= typeDelay.ToInteger();err != nil || delay < 0 {
log.Printf("HIDScript typingSpeed: First argument has to be positive integer, representing the delay between key presses in milliseconds\n")

View File

@ -413,7 +413,6 @@ func (kbd *HIDKeyboard) PressKeySequence(reports []KeyboardOutReport) (err error
delay := kbd.KeyDelay
if kbd.KeyDelayJitter > 0 { delay += rand.Intn(kbd.KeyDelayJitter)}
if delay > 0 { time.Sleep(time.Millisecond * time.Duration(delay)) }
return nil
}