Skip to content

Instantly share code, notes, and snippets.

@mkosmo
Created August 11, 2021 17:36
Show Gist options
  • Save mkosmo/ed07cfe3246fb38ef26620453a3fedce to your computer and use it in GitHub Desktop.
Save mkosmo/ed07cfe3246fb38ef26620453a3fedce to your computer and use it in GitHub Desktop.
DCS Monitoring
#SingleInstance Force
#Persistent
#NoEnv
#Warn
SetWorkingDir %A_ScriptDir%
EnvGet, vUserProfile, USERPROFILE
FileAppend, %vUserProfile%\DCS_Monitor.log
SetTimer, dcsChecker, 10000
dcsChecker:
; Check for DCS Crash window. If found, kill app.
if WinExist("DCS Crash")
{
Process, WaitClose, DCS.exe, 5
FileAppend, %vDateTime% - Killed DCS`n, %vUserProfile%\DCS_Monitor.log
}
; Check for process exist - if not, restart.
Process, Exist, DCS.exe
if ErrorLevel < 1
{
FormatTime, vDateTime, , yyyyMMddHHmmss
Run "C:\Program Files\Eagle Dynamics\DCS World OpenBeta\bin\DCS.exe" --server --norender --webgui
FileAppend, %vDateTime% - Restarted DCS`n, %vUserProfile%\DCS_Monitor.log
}
; Check for DCS Login Failed.
if WinExist("DCS Login Failed")
{
WinActivate, DCS Login Failed
WinWaitActive, DCS Login Failed
Send {Enter}
}
; Check for DCS Login window.
if WinExist("DCS Login")
{
WinActivate, DCS Login
WinWaitActive, DCS Login
; Username
Send {Ctrl down}a{Ctrl up}USERNAME
; Password
Send {Tab}{Ctrl down}a{Ctrl up}PASSWORD
; Submit
Send {Tab}{Tab}{Tab}{Tab}{Tab}{Enter}
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment