Send and SendInput Problems

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
whereyomomsat_
Posts: 4
Joined: 02 Dec 2022, 03:11

Send and SendInput Problems

Post by whereyomomsat_ » 05 Dec 2022, 01:11

Hello all,

I've tried many variations of a script whose purpose is to send rapid clicks when either mouse button is held down. In my own script I have both left and right click loops but here is the simplest version I tried:

Code: Select all

SetKeyDelay, -1

$RButton::
While GetKeyState("RButton", "P")
{
	Send, {RButton}
}
Return
When using this, I get about 20 clicks per second. However, I would like to achieve 30 or so. What I infer from this, is that the send command has a 50 ms delay (1000ms/20 clicks). I would also like to use the {Blind} modifier but that slows it down even more (to about 16 clicks per second).

The obvious answer I think is to use SendInput, and I was able to achieve desired clicks per second using SendInput. However, it came with undesirable side effects. Namely, the key buffering is very unwanted in my use case. In addition, no matter if I used a while loop with GetKeyState or a Button up configuration with SetTimer and Gosub, the right click and left click loops would get stuck occasionally (interference?). The loops getting stuck was not a problem with Send.

I have also tried SendPlay and SendEvent to no success. Also, I tried using V2 although most of my testing has been in 1.1.35.00.

I don't think it is CPU or memory related as SendInput is able to hit the clicks per second goal of 30 and both CPU and memory stay at about 60%. I could be wrong here though. I also don't think the application I am using is restricting the click rate for the same reason of it being able to register 30 with SendInput.

I greatly appreciate anyone who takes the time to read this! Happy Holidays!

Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Send and SendInput Problems

Post by Rohwedder » 05 Dec 2022, 05:09

Hallo,
your target application is to blame for key buffering.
It's like feeding a baby. You can't speed it up by connecting the feeding bottle to an air compressor.

whereyomomsat_
Posts: 4
Joined: 02 Dec 2022, 03:11

Re: Send and SendInput Problems

Post by whereyomomsat_ » 05 Dec 2022, 06:16

Rohwedder wrote:
05 Dec 2022, 05:09
Hallo,
your target application is to blame for key buffering.
It's like feeding a baby. You can't speed it up by connecting the feeding bottle to an air compressor.
That may be. I was under the impression key buffering was a feature of SendInput. I read this on the documentation: "SendInput and SendPlay use the same syntax as Send but are generally faster and more reliable. In addition, they buffer any physical keyboard or mouse activity during the send, which prevents the user's keystrokes from being interspersed with those being sent" (https://www.autohotkey.com/docs/commands/Send.htm).

That described key buffering was specifically what my issue with SendInput was, as well as the loop sometimes getting stuck. I took this to mean buffering is a native feature of SendInput. But maybe I'm wrong?

Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Send and SendInput Problems

Post by Rohwedder » 05 Dec 2022, 10:48

With physical keyboard or mouse activities are meant the inputs of the user. The resulting data processing of Autohotkey and the target application are logical, although they are actually also based on physics (voltage, current, energy).

adrianh
Posts: 135
Joined: 28 Jul 2014, 15:34

Re: Send and SendInput Problems

Post by adrianh » 05 Dec 2022, 11:24

Rohwedder wrote:
05 Dec 2022, 05:09
Hallo,
your target application is to blame for key buffering.
It's like feeding a baby. You can't speed it up by connecting the feeding bottle to an air compressor.
Oh, the image that this conjured made my Monday. :D

Post Reply

Return to “Ask for Help (v1)”