LMB - normal behavior + key tap every 500ms

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
owsik930
Posts: 1
Joined: 04 Oct 2022, 13:54

LMB - normal behavior + key tap every 500ms

Post by owsik930 » 04 Oct 2022, 14:15

Hello,
I am totally new on autohotkey, but I can not find proper solution or merge it from more than one solution. :headwall:

What is my goal?
1) On LMB click, additionally tap "Q" key (maximum once per 500ms)
2) On LMB hold, tap "Q" once every 500ms (only tap "Q", do not emulate hold for this key)
3) LMB must work on unchanged way - just add tap "Q" button every 500ms

Examples
a) If I spam LMB 10x/sec - script additionally sends "Q" key 3x times (once every 500ms)
b) If I hold LMB for ~1sec - script additionally sends "Q" key 3x times (once every 500ms)
c) If I hold LMB for ~2secs - script additionally sends "Q" key 5x times (once every 500ms)

<3

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

Re: LMB - normal behavior + key tap every 500ms

Post by mikeyww » 04 Oct 2022, 17:38

Welcome to this AutoHotkey forum!

Code: Select all

~LButton Up::SetTimer, Stop, -200
~LButton::
If on
 Return
SetTimer, Q, 500
on := True
Q:
Send q
Return

Stop:
SetTimer, Q, Off
on := False
Return

Post Reply

Return to “Ask for Help (v1)”