A donation alone isn't enough of a gesture of gratitude for this awesome project, so here's my own little way of paying it forward a bit. Hopefully this will help others like me in the minority of (Windows) users who aren't using it exclusively for gaming and want to do television style broadcasting.
If a scene gets focus (user chooses another OBS scene), script sleeps until focus is changed. Includes blocks for a game capture source and DroidCam app to add an old Android phone as one source.
Should work out of the box, but plenty of room for improvement - e.g., allow focus change without scene switch.
SETUP:
Create desired sources and scenes in OBS
Name scenes to auto switch Scene1, Scene2, etc
Download AutoHotKey
Create a new Notepad file, rename with .ahk extension
Right-click > Edit Script
Adapt variables in the following code to reflect your sources and cut time preferences:
Save AHK file
Right-click > Compile Script to create .exe, if desired
Right-click > Run Script
OBS > Preview Stream
Select any scene to pause auto switching
Click outside of Scenes box to resume auto switching
Right-click AHK taskbar icon > Pause Script or Exit to stop auto switching
If a scene gets focus (user chooses another OBS scene), script sleeps until focus is changed. Includes blocks for a game capture source and DroidCam app to add an old Android phone as one source.
Should work out of the box, but plenty of room for improvement - e.g., allow focus change without scene switch.
SETUP:
Create desired sources and scenes in OBS
Name scenes to auto switch Scene1, Scene2, etc
Download AutoHotKey
Create a new Notepad file, rename with .ahk extension
Right-click > Edit Script
Adapt variables in the following code to reflect your sources and cut time preferences:
Code:
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;END AHK TEMPLATE
;VARIABLES
camsNum = 2 ; Number of sources, scenes, cameras (if DroidCamOn and/or SLon = 1, AHK adds to camsNum)
camNum = 1 ; Start with Scene1
DroidCamOn = 0 ; Android phone as a source with DroidCam app
SLon = 0 ; Game to capture
manualSwitch = 0 ; Initialize manual source switching
; Cut times in milliseconds using golden ratio
randVar = 2 ; Default cut time
cutTime = 10000 ; Initialize cutTime
cutTime1 = 6000
cutTime2 = 10000
cutTime3 = 16000
; Add additional cutTimeN variables if desired
; END VARIABLE DECLARATION
; START OBS (And other sources, if enabled)
DetectHiddenWindows, On ; OBS and other applications may be minimized
SetTitleMatchMode, 2 ; Application names need not be exact
Target := "Kyle TV" ; OBS Profile name/window title
DroidCam := "DroidCam" ; Application window title
SL := "Firestorm-Release" ; Game window title
;Open OBS if it isn't already
IfWinNotExist %Target%
{
Run "C:\Program Files\OBS\OBS.exe"
WinWait, %Target%
}
;Alert user if unable to open OBS for some reason
IfWinNotExist %Target%
{
MsgBox Unable to open OBS
Return
}
; Game block
if SLon = 1
{
camsNum := ++camsNum ; Add scene
IfWinNotExist %SL% ; Open game if it isn't already
{
;Run, appName.exe, C:\Path\to\application, Min - run app minimized
Run, Firestorm-Release.exe, C:\Program Files (x86)\Firestorm-Release, Min
; WinWait, %appVarName% - wait for app to open
WinWait, %SL%
;Alert user if unable to open app for some reason
IfWinNotExist %SL%
{
MsgBox Unable to open %SL%
Return
}
}
}
;DroidCam block
if DroidCamOn = 1
{
camsNum := ++camsNum ; Add scene
IfWinNotExist %DroidCam% ; Open DroidCam if it isn't already
{
;Run, appName.exe, C:\Path\to\application, Min - run app minimized
Run, DroidCamApp.exe, C:\Program Files (x86)\DroidCam, Min
; WinWait, %appVarName% - wait for app to open
WinWait, %DroidCam%
;ControlClick, buttonName, appWindowTitle - AHK "clicks" buttonName in appWindowTitle
ControlClick, Start, DroidCam
}
;Alert user if unable to open app for some reason
IfWinNotExist %DroidCam%
{
MsgBox Unable to open DroidCam
Return
}
}
; SCENE SWITCHING
Loop ; loop through different cut times for manual switching illusion
{
; RANDOM CUT TIME
Random, randVar, 1, 3 ; Random, randVar, 1, totalTimes
randVar := Round(randVar)
if randVar = 1
{
cutTime = %cutTime1%
}
else if randVar = 2
{
cutTime = %cutTime2%
}
else if randVar = 3
{
cutTime = %cutTime3%
}
; Add else blocks if desired
; SKIP SWITCH if manually selecting scene
; Get active control
ControlGetFocus, manualSwitch, A
; Switch source if user is not selecting one manually
if manualSwitch != ListBox1 ; OBS Scenes box, Right-click AHK taskbar icon > Window Spy to find control and
menu names
{
; SWITCH SCENE
if (camNum <= camsNum)
{
Control, ChooseString, Scene%camNum%, ListBox1, ahk_class OBSWindowClass ; AHK selects SceneN
; Get next scene and wait for cutTime milliseconds
camNum := ++camNum
Sleep %cutTime%
}
else
{
camNum = 1 ; Back to Scene1 if we've cycled through the rest
}
}
; else auto switching suspended until focus removed (click something besides a scene)
}
Save AHK file
Right-click > Compile Script to create .exe, if desired
Right-click > Run Script
OBS > Preview Stream
Select any scene to pause auto switching
Click outside of Scenes box to resume auto switching
Right-click AHK taskbar icon > Pause Script or Exit to stop auto switching