Question / Help OBS can't accept VB triggered keystroke (Hotkey triggers without modifier)

WeeemRCB

New Member
Hi
I was trying to use an OBS Hotkey bound to 'e' to on/off trigger an audio clip when streaming a game (pubg).

My 'e' in PUBG is bound to a healing drink and so the on/off trigger would play the media audio file (burp after health drink) every other time for comedy effect. But ... it also triggers even when I press a modifier 'Shift+e' (in-game pain pills) which makes it way too frequent an effect - esp if I'm in a fight and spamming keys for healing.

I use Voicemeeter as my software audio mixer and it includes macro buttons which do accept strict Hotkey commands as well as wildcard hotkeys. So, as a workaround, I tried setting up a macro so that when the 'e' is pressed, it would call a simple VB script to trigger F15 for OBS to then play the audio clip.

I created the simple script with a 5s delay so I could
1) Run the script
2) Activate the Hotkey
And then the script should deliver the keystroke for OBS to record.

But all OBS recorded was 'Num Lock'
Wut?

I tried with a few other keys, including a basic 'e' and each time it reads the keystroke as Num Lock.
So I tested the script with notepad and it delivers the keystrokes perfectly.

Even if I set the script to deliver an 'e' and I set the OBS trigger the audio clip on 'e', the script doesn't trigger the clip.
(this would be so much easier if OBS had a wildcard option for each keybind like Voicemeeter)

I'm not sure why OBS would pick it up scripted keystrokes this way, but I've attached the VB for reference
Code:
'Presses F15 to work as a HotKey / Keybind
Set oShell = WScript.CreateObject ("WScript.Shell")
'Disable seep once mapped
WScript.Sleep 5000
oShell.SendKeys "{F15}"

Log file: https://obsproject.com/logs/_E-rd7NDKzqMveHX
 
Last edited:

WeeemRCB

New Member
Here's my workaround for now (in case someone else is trying the same thing)

1) Create a macro action in VoiceMeeter to watch for the 'e' key
2) Create a macro action in VoiceMeeter to watch for the 'F13' key
3) Have (1) trigger a VB script to check to see if your program/process is running and if so, simulate pressing "F13"
4) If (2) is triggered, play the audio clip.


Step 1
The VoiceMeeter Macro for (1) is Push Button watching for E and in the Request for Button ON / Trigger IN section, put:
Code:
System.Execute("%windir%\system32\wscript.exe","D:\MyScriptPath\VB","/C CheckProcess.vbs");

Step 2
This CheckProcess.vbs contains the following code to check if a specific process is running and if yes, then simulate pressing F13:
(My example below checks for PUBG's process which is "TslGame.exe")
Code:
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
Function IsProcessRunning( strComputer, strProcess )
    Dim Process, strObject
    IsProcessRunning = False
    strObject   = "winmgmts://" & strComputer
    For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
    If UCase( Process.name ) = UCase( strProcess ) Then
        objShell.SendKeys "{F13}"
        Exit Function
    End If
    Next
End Function
IsProcessRunning ".","TslGame.exe"

Step 3
Last of all, create the second Macro button as "2 Position" so it triggers every other keypress in VoiceMeeter as per (3) watching for the F13 keypress and in the Request for Button ON / Trigger IN section, put:
Code:
recorder.load="D:/Audio/SFX/Burp.mp3"
recorder.play=1
 
Last edited:

WeeemRCB

New Member
This would be so much easier if OBS had a wildcard on/off option for each keybind (like VoiceMeeter)
 
Top