Question / Help Hotkeys don't work if OBS isn't the foreground application? :(

Trejkaz

New Member
My setup:
- Windows 10
- AutoHotkey 1.1.30.03

I'm using Oculus to launch VR games, not Steam VR, and aiming to get replay clips.

I have an AutoHotkey script:

Code:
#include auto_oculus_touch.ahk

InitOculus()

Loop
{
    Poll()
    down     := GetButtonsDown()
    pressed  := GetButtonsPressed()
    if ((down & ovrA) && (pressed & ovrX)) || ((down & ovrX) && (pressed & ovrA))
    {
        SoundBeep
        ControlSend, ahk_parent, ^{F12}, OBS
    }

    Sleep 10
}

So every time I press the A and X buttons together on the Oculus Touch controllers, it makes a beep sound and then sends Ctrl+F12 to OBS.
I then bind Ctrl+F12 as the hotkey for Save Replay.
I then start the replay buffer recording.

If I focus OBS, pick up the controllers and press A and X, I get a new replay file in the output directory.
If I focus another application, say a game, and press A and X, I get no file at all.
If I use the physical keyboard to press Ctrl+F12 myself for real, I do get a file. (This isn't useful, but it's good to know for diagnostics)

So there is something particular about how AutoHotkey is delivering events to OBS, and I'm wondering whether anyone knows whether there is a way to make this work.

My workaround for this at the moment is to enhance the script a bit to activate the OBS window before I send the keystroke. This does work, but it's a suboptimal solution as some day the OBS window appearing on top might be a problem.

As a side-note, considering how many people use this to record gameplay stuff, it would be really nice to be able to use game controllers as hotkeys in OBS directly without having to install additional tools. I'm a developer myself, but I don't know how involved this would be.
 
Top