Prevent double pressing while keeping constant pressing

Get help with using AutoHotkey and its commands and hotkeys
hiurt
Posts: 1
Joined: 17 Dec 2017, 19:13

Prevent double pressing while keeping constant pressing

17 Dec 2017, 19:44

When I press the space bar in my keyboard, sometimes it will input the space character twice. I got a script from AutoHotkey's subreddit that fixed my problem, though now nothing happens if I press the space bar constantly. The script is:

Code: Select all

$Space::
    If (A_TimeSincePriorHotkey>100 OR A_TimeSincePriorHotkey=-1)
        Send {Space}
Return
I have tried changing it to

Code: Select all

$Space::
    If (A_TimeSincePriorHotkey>100 OR A_TimeSincePriorHotkey=-1 OR A_TimeSincePriorHotkey<40)
        Send {Space}
Return
It did fix it... kind of. When typing something, it now responds to constant pressing, but in games and in https://www.microsoft.com/appliedscienc ... gDemo.aspx, pressing the space bar (even if not constantly) does nothing unless ctrl or shift is being held. I honestly have no clue why this happens.

Is it possible to create a script that blocks double spaces while allowing pressing constantly (without having to press Ctrl or Shift too)? If so, what do I have to change/add/remove to the code above?

Thank you in advance!
Rohwedder
Posts: 1519
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Prevent double pressing while keeping constant pressing

18 Dec 2017, 02:37

Hallo,
try:

Code: Select all

$Space::
	Send {Space Down}
	Sleep, 100
	SetKeyDelay,10,10
	While GetKeyState("Space","P")
		Send {Space Down}
	Send {Space Up}
Return

Return to “Ask For Help”

Who is online

Users browsing this forum: AnotherUser, Bing [Bot], Google [Bot], Sarah92, swagfag and 32 guests