Code:
$wowWindowTitle = "World of Warcraft"
$sGatherWindowTitle = "Nodes :"
$SGatherLogControl = "[NAME:Logs; INSTANCE:1]"
$sGatherMountSuccess = "\[BOT\] Mount success !\s*$"
$SGatherProsses = "SGather.exe"
$Time = TimerInit()
$MinStopAfter = IniRead("StopSGather.ini", "TIME", "MinStopAfter", "40") ; Minimum time to stop SGather (in minute)
$MaxStopAfter = IniRead("StopSGather.ini", "TIME", "MaxStopAfter", "70") ; Maximum time to stop SGather (in minute)
$MinLoginAfter = IniRead("StopSGather.ini", "TIME", "MinLoginAfter", "5") ; Minimum time to Login (in minute)
$MaxLoginAfter = IniRead("StopSGather.ini", "TIME", "MaxLoginAfter", "9") ; Maximum time to Login (in minute)
$timeleft = IniRead("StopSGather.ini", "TIME", "LoopNumber", "3") ; Number session you want
$LOGOUT = "{ENTER}/logout{ENTER}"
$sGatherInject = "["&IniRead("StopSGather.ini", "TEXT", "sGatherInject", "LOOP")&"]"
AutoItSetOption("SendKeyDownDelay", 100)
While $timeleft >= 0
$okok = 0
$endloop = 0
$sleeping = Random($MinStopAfter , $MaxStopAfter , 1) ; Random time to stop SGather
$sGatherLogText = ControlGetText($sGatherWindowTitle,"",$SGatherLogControl)
ControlSetText($sGatherWindowTitle, "", $SGatherLogControl, $sGatherLogText&$sGatherInject&" starting loop :"&@CRLF&$sGatherInject&" stoping in "&$sleeping&" minutes"&@CRLF&$sGatherInject& " Loop remaining : "&$timeleft &@CRLF)
sleep($sleeping * 60 * 1000)
$timeleft = ( $timeleft - 1 )
while $timeleft <= 0
$sGatherLogText = ControlGetText($sGatherWindowTitle,"",$SGatherLogControl)
If StringRegExp ($sGatherLogText, $sGatherMountSuccess) Then
If WinExists($wowWindowTitle) Then
sleep ( 2 * 1000 )
WinSetOnTop ( "Nodes", "", 1 )
WinActivate ( "Nodes" )
controlclick( "Nodes","","[NAME:button1]") ; Stop SGather
WinSetOnTop ( "Nodes", "", 0 )
ControlSetText($sGatherWindowTitle, "", $SGatherLogControl, $sGatherLogText & $sGatherInject & " Stop boting till you restart it" & @CRLF)
sleep ( 2 * 1000 )
ControlSend ($wowWindowTitle, "", "", $LOGOUT, 0) ; Logout the game
sleep ( 2 * 1000 )
$endloop = 1
ExitLoop
EndIf
EndIf
sleep (300)
WEnd
If $endloop == 1 Then ExitLoop
while $okok == 0
If ProcessExists($SGatherProsses) AND $timeleft > 0 Then
$sGatherLogText = ControlGetText($sGatherWindowTitle,"",$SGatherLogControl)
If StringRegExp ($sGatherLogText, $sGatherMountSuccess) Then
If WinExists($wowWindowTitle) Then
sleep ( 2 * 1000 )
WinSetOnTop ( "Nodes", "", 1 )
WinActivate ( "Nodes" )
controlclick( "Nodes","","[NAME:button1]") ; Stop SGather
WinSetOnTop ( "Nodes", "", 0 )
sleep ( 2 * 1000 )
ControlSetText($sGatherWindowTitle, "", $SGatherLogControl, $sGatherLogText & $sGatherInject & " stop boting" & @CRLF)
sleep ( 1 * 1000 )
ControlSend ($wowWindowTitle, "", "", $LOGOUT, 0) ; Logout the game
$sleepinglogout = Random($MinLoginAfter , $MaxLoginAfter , 1) ; Random time to login
ControlSetText($sGatherWindowTitle, "", $SGatherLogControl, $sGatherLogText & $sGatherInject & " relogin in "&$sleepinglogout&" Minutes" & @CRLF)
sleep ($sleepinglogout * 60 * 1000)
ControlSetText($sGatherWindowTitle, "", $SGatherLogControl, $sGatherLogText & $sGatherInject & " relogin..." & @CRLF)
ControlSend ($wowWindowTitle, "", "", "{ENTER}", 0) ; Login
sleep ( 45 * 1000 )
WinSetOnTop ( "Nodes", "", 1 )
WinActivate ( "Nodes" )
controlclick( "Nodes","","[NAME:button2]") ; Start SGather
WinSetOnTop ( "Nodes", "", 0 )
ControlSetText($sGatherWindowTitle, "", $SGatherLogControl, $sGatherLogText & $sGatherInject & " start boting" & @CRLF)
sleep ( 1 * 1000 )
ControlSetText($sGatherWindowTitle, "", $SGatherLogControl, $sGatherLogText & $sGatherInject & " reloop..." & @CRLF)
$okok = 1
EndIf
EndIf
EndIf
sleep (300)
WEnd
wend
This new code will read StopSGather.ini file located in the same directory as your script