#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.
#Persistent
SetTitleMatchMode, 2 ; match start of the title
SetTimer, checkTime, 30000
SetTimer, checkIfStillRunning, 10000
StartTime := 1847
StopTime := 1848
streaming := 0
obsPath := "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OBS Studio\OBS Studio (64bit)"
RunOBS(obsPath) {
Run %obsPath%,, Min
Sleep, 2000
WinMinimize OBS
Sleep, 500
ControlSend,,{F9},ahk_class Qt5QWindowIcon ; Go to right scene
Sleep, 500
ControlSend,,{F10},ahk_class Qt5QWindowIcon ;starts the stream
WinMinimize OBS
}
CheckIfOBSIsRunning(obsPath) {
Process, Exist, obs64.exe
if !ErrorLevel {
RunOBS(obsPath)
} else {
Process, Close, obs64.exe
Sleep, 1000
RunOBS(obsPath)
}
}
checkTime:
time := A_Hour . A_Min
If (time = StartTime && !streaming) {
streaming := 1
CheckIfOBSIsRunning(obsPath)
TrayTip STREAMING, Streaming lance jusque minuit
}
If (time = StopTime && streaming) {
streaming := 0
ControlSend,,{F12},ahk_class Qt5QWindowIcon ;stop the stream
TrayTip STREAMING, Arret du stream
Sleep, 2000
Process, Close, obs64.exe
}
return
checkIfStillRunning:
If (streaming) {
Sleep, 100
Process, Exist, obs64.exe
if !ErrorLevel {
RunOBS(obsPath)
}
}
return