JurgenW

New Member
I've been looking around for a while to find a way that would allow me to do something like what a Stream Deck does (but just without the cost of it).
Hotkeys in OBS have their limitations:
  • You have to choose keys that don't interfere with anything else
  • Using a keyboard for hotkeys means you have to remember which keys are for what (not easy to label them)
  • OBS doesn't seem to support F13-24 keys too well (plus you then need a keyboard that can generate them)
  • OBS doesn't support joystick/gamepad buttons

I'm not a programmer, although I can cobble together some simple scripts. What I've managed to figure out is a simple (?) way to use a joystick (or gamepad?) as scene switcher. This is pulled together from other bits that others have done so full credit to them. With some help this could probably be easily made into something more slick. The bits I'm using are:
(I also eagerly watching this Scripted OBS Controller thread, it could work well to do the same thing... and more!)

The advantage of using a joystick as input are:
  • Joysticks can support up to 32 buttons and 2 HAT switches
  • Pressing a joystick button should not interfere with other Windows apps
  • The Arduino Micro Pro running joystick library can enumerate as multiple joysticks giving even more buttons if needed
  • Above my immediate ability, but I'm sure the joystick axes could be used as faders to control volumes, etc. in OBS

The way that I done this is with a simple AHK script that triggers on a joystick button and then calls a command line to OBS to change the scene:
Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Joy1::
  Run "C:\OBS Streaming Service Folder\OBS Command Line\OBSCommand.exe" /scene="Scene 1", , Hide
  return
 
Joy2::
  Run "C:\OBS Streaming Service Folder\OBS Command Line\OBSCommand.exe" /scene="Scene 2", , Hide
  return

Prerequisites are OBS Websockets installed and running, the Command Line tool downloaded and extracted to a folder of your choice (from the above, on my machine this is in "C:\OBS Streaming Service Folder\OBS Command Line\") and Autohotkey installed. I haven't set any security/password on my websocket connection as I'm running it on the same machine, I'm sure it would be trivial to add that into the command line tool.

The manual thing is to know what your OBS Scene names are (case sensitive!) and then just add line to the script for as many joystick buttons and/or scenes as you need. I hope this is useful to someone.

Things that I think could fairly easily be improved upon:
  • A more complex AHK script that could probably communicate directly with OBS websockets? (doing away with the Command Line interface) This requires more coding and parsing json formats, etc. Above me at this stage.
  • AHK would also be able to read out the list of scenes from OBS and provide a GUI to the user to dynamically assign the keys/buttons to each scene
  • Through websockets AHK could also control faders, etc.

I managed to cobble this piece of AHK script code together that gets the list of scenes from OBS, but it is json format so I'm trying to parse that at the moment:
Code:
DetectHiddenWindows On
Run %ComSpec%,, Hide, pid
WinWait ahk_pid %pid%
DllCall("AttachConsole", "UInt", pid)
WshShell := ComObjCreate("Wscript.Shell")
exec := WshShell.Exec("C:\OBS Streaming Service Folder\OBS Command Line\OBSCommand.exe /command=GetSceneList")
output := exec.StdOut.ReadAll()
Maybe someone could help to develop this?
 

FishBytes

New Member
This isn't quite as involved as what you are asking, but CamController.com can manage control multiple PTZ cameras as well as send Keyboard shortcuts to OBS that can switch cameras via scene switching along with Switching cameras from Preview to Live. There is only support for a single joystick (xbox or ps4) at this time.

There are setup guides on the site, including a reverse integration where you can use OBS to change a camera preset via CamController.com
 

mattbatt

Member
This isn't quite as involved as what you are asking, but CamController.com can manage control multiple PTZ cameras as well as send Keyboard shortcuts to OBS that can switch cameras via scene switching along with Switching cameras from Preview to Live. There is only support for a single joystick (xbox or ps4) at this time.

There are setup guides on the site, including a reverse integration where you can use OBS to change a camera preset via CamController.com
I keep seeing you all over the forum hocking your CamController software If you're not careful someone might think you are spamming the site.
 

danimations

New Member
Just chiming in to say, I like your idea and approach, Jurgen. It'd be great if gamepad support was added and could be assigned as a scene switcher.
 

DanielCeregatti

New Member
Great post! I set this up in just a few minutes and have it fully working with OBS. It's a shame OBS doesn't support this directly though. It'd be a great feature for it.
 

zinob

New Member
Could you explain step by step please I am very interested
In case you are still curious or if some one else finds this post. What you need to do is:
to install the Websockets plugin:https://obsproject.com/forum/resources/obs-websocket-remote-control-obs-studio-from-websockets.466/
Restart OBS
Sadly bramas page does NOT support authentication, so you need to disable authentication in the Tools menu-> WebSocket server settings you should only do this if you are a on a private-ish network and know what you are doing.
After that you can open the page, press a button on the controller and the page should list all scenes and give you the option to bind a scene to a button.
 

PaulBM

New Member
I've been looking around for a while to find a way that would allow me to do something like what a Stream Deck does (but just without the cost of it).
Hotkeys in OBS have their limitations:
  • You have to choose keys that don't interfere with anything else
  • Using a keyboard for hotkeys means you have to remember which keys are for what (not easy to label them)
  • OBS doesn't seem to support F13-24 keys too well (plus you then need a keyboard that can generate them)
  • OBS doesn't support joystick/gamepad buttons

Thanks to your work and explanation, I've got these programs working, apart for using /command=TriggerHotkeyByName,hotkeyName= command via AHK. If I type the command into a cmd prompt, OBS responds and the key is pressed, but when in an AHK script, they do not work. Scene switching and mic toggling commands work via AHK. The AHK console is seeing the commands, but for some reason OBS isn't operating the hotkey.

Has anyone else tried using TriggerHotkeyByName via AHK? What could I be doing wrong.
 
Top