Skip to content

Instantly share code, notes, and snippets.

@horseslmao
Created December 29, 2025 22:21
Show Gist options
  • Select an option

  • Save horseslmao/8cc0d1f749bd25f207d46cf6fd7cae9a to your computer and use it in GitHub Desktop.

Select an option

Save horseslmao/8cc0d1f749bd25f207d46cf6fd7cae9a to your computer and use it in GitHub Desktop.
Run a shell command from OBS Advanced scene switcher while storing the output in a variable ... without a temporary file πŸ‘€ is OBS Python -> Batch -> Autohotkey
#Requires Autohotkey v2
outputtext := InputBox("put somethin here", "messageboxtitle",,A_Args[1]).value
stdout := FileOpen("*", 0x1)
stdout.Write(outputtext)
stdout.Close()
ExitApp
import obspython as obs
import subprocess as subprocess
shellcmmdmd = ["C:\\ETC\\STREAM\\wat.bat", "${wackytesting}"]
advss_var = "wackytesting"
def run():
si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output = subprocess.run(shellcmmdmd, check=True, capture_output=True, text=True, startupinfo=si).stdout.strip()
advss_set_variable_value(advss_var, output)
return True
#pulled from WarmUPTill's thingie
#https://github.com/WarmUpTill/SceneSwitcher/issues/1145
# variable with a given name.
# None is returned in case the variable does not exist.
def advss_get_variable_value(name):
proc_handler = obs.obs_get_proc_handler()
data = obs.calldata_create()
obs.calldata_set_string(data, "name", name)
obs.proc_handler_call(proc_handler, "advss_get_variable_value", data)
success = obs.calldata_bool(data, "success")
if success == False:
obs.script_log(obs.LOG_WARNING, f'failed to get value for variable "{name}"')
obs.calldata_destroy(data)
return None
value = obs.calldata_string(data, "value")
obs.calldata_destroy(data)
return value
# The advss_set_variable_value() function can be used to set the value of a
# variable with a given name.
# True is returned if the operation was successful.
def advss_set_variable_value(name, value):
proc_handler = obs.obs_get_proc_handler()
data = obs.calldata_create()
obs.calldata_set_string(data, "name", name)
obs.calldata_set_string(data, "value", value)
obs.proc_handler_call(proc_handler, "advss_set_variable_value", data)
success = obs.calldata_bool(data, "success")
if success == False:
obs.script_log(obs.LOG_WARNING, f'failed to set value for variable "{name}"')
obs.calldata_destroy(data)
return success
@echo off
chcp 65001 > nul
setlocal enableextensions
for /f "tokens=*" %%a in ('call "C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe" /CP65001 C:\ETC\STREAM\askuser.ahk %1') do ( set num=%%a )
echo %num%
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment