Measuring the time between keystrokes Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ryder
Posts: 61
Joined: 28 Apr 2022, 18:49

Measuring the time between keystrokes

Post by Ryder » 04 Oct 2022, 10:31

Hi all,

I have a keyboard and barcode scanner. I need to distinguish between keystrokes of the keyboard and those "keystrokes" produced by the barcode scanner.

To tell them apart, I want to measure the time between all keystrokes, and when they are below a certain threshold (<~50ms), to collect them to build up a "scanned input" string.

Since I know how long the scanned inputs are, I know that if I don't reach that length whilst maintaining a certain minimum time, that the input is from the keyboard and I can dump the string... and go back to square 1.

Basically:

If KeystrokeTime - PreviousKeystrokeTime < 50ms then ScanString = ScanString+Keystroke
Else
ScanString = ""

yada, yada...

The problem is that the timing has to be measured while an InputBox is open... which I think is going to prevent this from working :(

Thank you for your kind help.

R

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Measuring the time between keystrokes  Topic is solved

Post by mikeyww » 04 Oct 2022, 17:11

You can save the A_TickCount so that you can compute differences.

Ryder
Posts: 61
Joined: 28 Apr 2022, 18:49

Re: Measuring the time between keystrokes

Post by Ryder » 05 Oct 2022, 15:44

mikeyww wrote:
04 Oct 2022, 17:11
You can save the A_TickCount so that you can compute differences.
I found that indeed A_TickCount does work in this application...

However, I was able to take a different approach when I realized that I didn't actually need the measurement, and that in actuality all I needed was a countdown timer implementation, and made various use of SetTimer.

I continue to be impressed with how versatile AHK is... generally several ways to skin any cat.

Thanks for your kind help!

R

Post Reply

Return to “Ask for Help (v1)”