How to stop a hotkey firing if held?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
BaconCatBug
Posts: 7
Joined: 15 Jun 2014, 10:08

How to stop a hotkey firing if held?

17 Jul 2014, 08:08

Hi all! I have a very simple script that I am utilising that simply loops an action when I hit a button until it gets pressed again:

However, if I accidentally or otherwise hold down the X key, it'll keep sending the action and will no longer stop when I hit X again. I'd be very grateful if someone could point me in the direction of how to fix this. :)
Last edited by BaconCatBug on 18 Jul 2014, 13:41, edited 1 time in total.
User avatar
fischgeek
Posts: 435
Joined: 29 Jan 2014, 21:39

Re: How to stop a hotkey firing if held?

17 Jul 2014, 19:23

Checkout GetKeyState to see if you can implement. Let us know if you get stuck.
BaconCatBug
Posts: 7
Joined: 15 Jun 2014, 10:08

Re: How to stop a hotkey firing if held?

17 Jul 2014, 19:45

fischgeek wrote:Checkout GetKeyState to see if you can implement. Let us know if you get stuck.
Thanks for the help! :D

I eventually found a solution with Google-fu that uses SetTimer instead:

Code: Select all

#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir %A_ScriptDir%

SetTimer TimerName, 1000

X::
Toggle := !Toggle

TimerName:
    If (!Toggle)
        Return
	send ABC{space}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, doanmvu and 376 guests