Can't send the space key

53 Views Asked by At

I'm trying to fix double-typing on my keyboard.

For this I want to use an AutoHotkey (2) script like this:

SendMode "Input"
#SingleInstance

*g::
{
    Send "{g}"
    Sleep 50
}

Space::
{
    Send "{Space}"
    Sleep 50
}

The problem is that the "Space" key is not being sent at all. It does detect the key, because if I replace "Space" with "g", it sends g's properly, but I've tried the following (ThisHotkey also returns "Space") and it's still not being sent:

SendMode "Input"
#SingleInstance

*g::
{
    Send "{g}"
    Sleep 50
}

Space::
{
    Send ThisHotkey
    SendInput ThisHotkey
    
    Send "{Space}"
    Sleep 50
    Send "{Enter}"
    Sleep 50
    
    SendInput "{Space}"
    Sleep 50
    
    Send "{Space down}"
    Sleep 500
    Send "{Space up}"
    Sleep 500
    
    SendInput "{Space down}"
    Sleep 500
    SendInput "{Space up}"
    Sleep 500
}

"Enter" gets sent properly, for example. Am I overlooking something obvious? What can I do? Thank you.

2

There are 2 best solutions below

0
Dieisson Silva dos Santos On BEST ANSWER
SendMode "Input"
#SingleInstance

*g::
{
    Send "{g}"
    Sleep 50
}

~Space::    ;   ~ hotkey modifier
{
    Send "{Space 5}"
    Sleep 50
}

Source

0
V0RT3X On

Since your handle is TryingToLearn, another possibility to simply send a space is to look into A_Space...

Send, %A_SPACE%

There is also A_TAB, but that's a tool for another day.