#include #include Local $aGames $file = "C:\Games.exe.txt" _FileReadToArray($file, $aGames) Local $sRunning AdlibRegister("_CheckGame", 1000) ConsoleWrite("_CheckGame() was registered by Adlib" & @CRLF) While 1 Sleep(100) WEnd Func _CheckGame() ; Assign a static variable to hold the number of times games are checked for. Local Static $iGameCount = 0 Local Static $iCount = 0 While 1 For $i = 1 to UBound($aGames) -1 $iGameCount += 1 If $iGameCount > UBound($aGames) Then $iGameCount = 0 $iCount += 1 ConsoleWrite("Checked for a game " & $iCount & " time(s)" & @CRLF) EndIf If ProcessExists($aGames[$i]) Then $sRunning = FileReadLine($file, $i) ConsoleWrite($sRunning & " was launched. Terminating Rainmeter." & @CRLF) ProcessClose("Rainmeter.exe") ConsoleWrite("Rainmeter has been terminated." & @CRLF) ExitLoop 2 EndIf Sleep(100) Next WEnd ConsoleWrite("Running game is " & $sRunning & @CRLF) ConsoleWrite("Checking if Rainmeter can be restarted..." & @CRLF) While 1 If Not ProcessExists($sRunning) Then ConsoleWrite("Starting Rainmeter..." & @CRLF) ShellExecute("C:\Program Files\Rainmeter\Rainmeter.exe") WinWait("Rainmeter") ConsoleWrite("Rainmeter has been restarted." & @CRLF) ExitLoop EndIf WEnd AdlibUnRegister("_CheckGame") AdlibRegister("_CheckGame") EndFunc Exit