windowsscriptingwindows-10autohotkeyahk2

Can't send the space key


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.


Solution

  • SendMode "Input"
    #SingleInstance
    
    *g::
    {
        Send "{g}"
        Sleep 50
    }
    
    ~Space::    ;   ~ hotkey modifier
    {
        Send "{Space 5}"
        Sleep 50
    }
    

    Source