Block keystroke inputs from the user

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fromit
Posts: 1
Joined: 22 Mar 2018, 09:03

Block keystroke inputs from the user

22 Mar 2018, 10:04

Hello, im very new here and need some help
Im trying to synchronize barcode scanner with memory with a program for sells, which isn't buffering incoming data and is making slow SQL requests..
After 'Enter' key i need to interrupt incoming keystrokes and Sleep for about a second and then continue with buffered data.. The problem is that i have tried everything until now and still have no solution. The only available keystroke interrupts is with BlockInput On/Off in which case im losing data..
The other try is:

Code: Select all

SendMode Play
SetKeyDelay, 500, 10, Play
~Enter::
Send qwerty
In this case keystroke inputs are interrupted and buffered until Send operator finish his job with all the delays in it
The result is terrable - Enter isnt always captured in the buffered data and unnecessary characters must be send to use these delays..
Anyway.. the main problem is that i can't find anywhere a way to block and buffer incoming keystrokes, so please help me!

Any suggestions and ideas will be appreciated! Thank you!
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Block keystroke inputs from the user

22 Mar 2018, 11:31

You could assign every key on the keyboard to an #If hotkey that just returns, and turn that hotkey on when you want to block input.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Block keystroke inputs from the user

22 Mar 2018, 11:37

fromit wrote:The only available keystroke interrupts is with BlockInput On/Off in which case im losing data..

what??
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Block keystroke inputs from the user

22 Mar 2018, 11:59

Take a look at Input

Example:

Code: Select all

#NoEnv
SetBatchLines, -1
keybuffer := []
keybuffer.Ready := true

Loop
{
    Input, bufferedkeystrokes, I, {Enter}
    ; < validate bufferedkeystrokes here >
    if (bufferedkeystrokes = "")
        continue
    keybuffer.push(bufferedkeystrokes)
    if (keybuffer.Ready)
        SetTimer, keyHandler, -1
}

keyHandler:
    keybuffer.Ready := false
    Loop
    {
        Sleep 1000
        Send % keybuffer.RemoveAt(1) . "{Enter}"
    }until (keybuffer.Length() = 0)
    keybuffer.Ready := true 
return
Adjust as needed maybe it will work for you.

HTH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 271 guests