@echo off
::
:: Comcave.Lazy.App.Launcher
:: v0.6
::
:: MADE BY
:: paypal.me/flyhost
::  ________  __                             ________  __           
:: |        \|  \                           |        \|  \          
:: | $$$$$$$$ \$$  ______    ______         | $$$$$$$$| $$ __    __ 
:: | $$__    |  \ /      \  /      \        | $$__    | $$|  \  |  \
:: | $$  \   | $$|  $$$$$$\|  $$$$$$\       | $$  \   | $$| $$  | $$
:: | $$$$$   | $$| $$   \$$| $$    $$       | $$$$$   | $$| $$  | $$
:: | $$      | $$| $$      | $$$$$$$$       | $$      | $$| $$__/ $$
:: | $$      | $$| $$       \$$     \ ______| $$      | $$ \$$    $$
::  \$$       \$$ \$$        \$$$$$$$|      \\$$       \$$ _\$$$$$$$
::                                    \$$$$$$             |  \__| $$
::                                                         \$$    $$
::                                                          \$$$$$$ 
:: Check for updates
start Update.bat
:: START launcher & login
:start
:: Estimating time and sleep timer
FOR /F "tokens=* delims= " %%a IN ("%TIME:~0,2%") DO SET hour=%%a
set /a human=%RANDOM% * 300 / 32768 + 20
set /a sleepbefore13=(13 * 60 - %hour% * 60) * 60

if %hour% LSS 13 (
		:: before 13:00 batch terminates
		Echo == Sorry its to early, we will wait till its 13:00 ==		
		timeout %sleepbefore13%
		goto start
) ELSE (
	if %hour% GEQ 20 (
		:: after 20:00 batch terminates
		Echo == Sorry its to late, terminating ==
		timeout 10
		EXIT
	) ELSE (
		:: kill all app instances
		taskkill /f /im java.exe
		taskkill /f /im java.exe
		taskkill /f /im java.exe
		:: atating app
		Echo == Starting AutoHotkey ==
		start "C:\AutoHotkey\AutoHotkey.exe" "C:\AutoHotkey\Comcave\Comcave.ahk"	
		:: wait for app to start
		Echo == Waiting for Launcher ==
		timeout 20
		Echo == Logging in ==
		:: wait 90 min
		Echo == Now we wait 60 Min ==
		timeout 3600
		:: kill all app instances
		taskkill /f /im java.exe
		taskkill /f /im java.exe
		taskkill /f /im java.exe
		Echo == Now we are emulating a Human (Waiting 20sec - 300sec) ==
		:: wait random 20sec - 300sec	to emulate a human								 
		timeout %human%
		:: back to start
		goto start
	)
)




:END