add timer to existing code block

Ask gaming related questions
johannarenfold
Posts: 6
Joined: 11 Jun 2023, 23:00

add timer to existing code block

28 Jan 2024, 05:05

Code: Select all

#HotIf auto
LButton:: {
 SetKeyDelay 20, 20
 While GetKeyState(ThisHotkey, "P")
  SendEvent '{' ThisHotkey '}'
I would like to add an action so that in addition to the rapid left mouse click it will give a beep sound every 4 seconds whilst left mouse is physically held down. When left mouse is released timer will reset and begin again whenever left mouse is pressed.


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
User avatar
mikeyww
Posts: 27315
Joined: 09 Sep 2014, 18:38

Re: add timer to existing code block

28 Jan 2024, 08:42

Code: Select all

#Requires AutoHotkey v2.0

LButton:: {
 Static beep := SoundBeep.Bind(1500)
 SetKeyDelay 20, 20
 SetTimer(beep, 4000), beep()
 While GetKeyState(ThisHotkey, 'P')
  SendEvent '{' ThisHotkey '}'
 SetTimer beep, 0
}
johannarenfold
Posts: 6
Joined: 11 Jun 2023, 23:00

Re: add timer to existing code block

29 Jan 2024, 00:18

Thank you so much, works well except a minor point is that the first beep comes immediately lmb is pressed whereas it's better if it first beeps after the 4 seconds
johannarenfold
Posts: 6
Joined: 11 Jun 2023, 23:00

Re: add timer to existing code block

29 Jan 2024, 05:14

ok thanks, I did it.....just removed the beep()

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 4 guests