Page 1 of 1

Help for OBS Studio script

Posted: 03 Aug 2020, 00:12
by Zamfir
Hi guys,

I would like to create a script for OBS Studio that will create a sequence of task;

1) Send 0 (zero) key to OBS Studio,
2) Wait 1 second,
2) Change scene to "TEST" at OBS Studio,
2) Send "!test" command to OBS Studio chat screen and do ENTER.

This script should be triggered by CTRL+L shortcut at my keyboard.

Please advise. :roll:

Thanks!

Re: Help for OBS Studio script

Posted: 03 Aug 2020, 20:29
by mshafer1
you can use ControlSend to specify the target process/window of a key press.

Your requested script my look something like this (untested)

Note: I'm running the 64 bit version of OBS, so for me, the process name is obs64.exe, but you can verify this using the Window Spy (https://amourspirit.github.io/AutoHotkey-Snippit/WindowSpy.html) tool.

Code: Select all


obs_exe := ahk_exe obs64.exe

^l::  ;trigger on ctrl l
    ControlSend, , 0, %obs_exe% ; send a zero to OBS
    Sleep, 1000 ; delay 1 second
    ControlSend, , ^t, %obs_exe% ; send CTRL + t to obs  -  note, use file->settings->Hotkeys->TEST->Switch to scene to set this to switch OBS to the desired scene
   
    ;; TODO: send !test to chat window - I don't have a chat plugin installed, but if it's a seperate window, you can use Window Spy to find the ahk process and/or class name to provide to CTRL send - if it's in the same window, use Window Spy to find the  desired control - or lookup what keyboard shortcuts exist that you can have AHK hit then type the message.
    
    return ; block the original keystroke

Re: Help for OBS Studio script

Posted: 03 Aug 2020, 20:31
by gregster
I think it should be obs_exe := "ahk_exe obs64.exe". It needs to be a string.

Also, afaik, OBS often requires a longer key delay, something like SetKeyDelay 50, 50 (or similar).

Re: Help for OBS Studio script

Posted: 05 Aug 2020, 00:12
by Zamfir
@gregster @mshafer0427

Many thanks for your help both!

I have installed the script and ran. However it didn't work. I have set the TEST scene shortcut to CTRL+T. When I press CTRL+L nothing happens. I have also confirmed that manually pressing CTRL+T switches the scene to TEST in OBS. I am using obs64.exe

I have also changed the script with obs_exe := "ahk_exe obs64.exe". Nothing changed.

Re: Help for OBS Studio script

Posted: 07 Aug 2020, 06:35
by Zamfir
Bumping to up. :dance: