please dont cry all the time. I'm working on a solution and i think Makaveli works too. So please wait until it's done. I will post it as soon as possible.
freezes. ( havent tested it too much tho ) script pauses from pause key.
Code:
;===========================================================================
; Declare Variables
;===========================================================================
HotKeySet("{PAUSE}", "Pause")
Global $LogIt
Global $Paused
$Counter = 1
$Disconnected = 0
$Connected = 0
$Date = @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN & ":" & @SEC & " > "
$UseLxy = IniRead ("SRO_restart.ini", "Settings", "Silkroad_Lxy", "")
$SROPath = IniRead ("SRO_restart.ini", "Settings", "Silkroad_Path", "")
$SROLExe = IniRead ("SRO_restart.ini", "Settings", "Silkroad_LExe", "")
$SROExe = IniRead ("SRO_restart.ini", "Settings", "Silkroad_Exe", "")
$SROLauncher = IniRead ("SRO_restart.ini", "Settings", "Silkroad_Launcher", "")
$SROClient = IniRead ("SRO_restart.ini", "Settings", "Silkroad_Client", "")
$Account = IniRead ("SRO_restart.ini", "Login", "Login_Account", "")
$Password = IniRead ("SRO_restart.ini", "Login", "Login_Password", "")
$CharPos = IniRead ("SRO_restart.ini", "Login", "Login_Character_Pos", "")
$LDelay = IniRead ("SRO_restart.ini", "Delays", "Delay_Launcher", "")
$CDelay = IniRead ("SRO_restart.ini", "Delays", "Delay_Client", "")
$ADelay = IniRead ("SRO_restart.ini", "Delays", "Delay_Account", "")
$PDelay = IniRead ("SRO_restart.ini", "Delays", "Delay_Password", "")
$RDelay = IniRead ("SRO_restart.ini", "Delays", "Delay_Restart", "")
$SDelay = IniRead ("SRO_restart.ini", "Delays", "Delay_Server", "")
$GDelay = IniRead ("SRO_restart.ini", "Delays", "Delay_2InGame", "")
$C2Delay = IniRead ("SRO_restart.ini", "Delays", "Delay_Char", "")
;===========================================================================
; Main
;===========================================================================
FileDelete ("SRO_restart.log.txt")
SetLog("")
SetLog("========================================")
SetLog("julmuri's srobot restart script launched.")
SetLog("========================================")
SetLog("")
While $Connected = 0
Connect()
Wend
CharSelect()
StartBot()
While 1
While $Disconnected = 0
Disconnect()
Wend
While $Connected = 0
Connect()
Wend
CharSelect()
StartBot()
Wend
;===========================================================================
; Funcs
;===========================================================================
Func Disconnect()
If ProcessExists ($SROExe) Then
$Disconnected = 0
Else
$Disconnected = 1
EndIf
If PixelGetColor (403, 328) = 0x181818 AND PixelGetColor (592, 327) = 0x181818 Then
$Disconnected = 1
SetLog("Disconnected from the server.")
Sleep (5000)
Send ("{ESC}")
Do
Sleep ($RDelay)
Until WinExists ($SROClient) = 0
EndIf
EndFunc; => Disconnect()
Func Connect()
If $UseLxy = 1 Then
Send ("{F8}")
EndIf
Run ($SROPath & "\" & $SROLExe)
SetLog("Launching Silkroad online.")
Do
Sleep(1000)
SetLog("Waiting Silkroad launcher.")
If WinExists ("Silkroad Online", "OK") = 1 Then
SetLog("Server is undergoing inspection.")
ControlClick ( "Silkroad Online", "OK", 2)
WinWait ($SROLauncher)
ControlClick ($SROLauncher, "", 1002)
SetLog("Sleeping server delay.")
Sleep($SDelay * 60 * 1000)
SetLog("Server delay slept (" & $SDelay & " min.), reconnecting.")
EndIf
Until WinActive ($SROLauncher)
SetLog("Silkroad launcher found.")
SetLog("Sleeping launcher delay.")
Sleep ($LDelay)
SetLog("Launcher delay slept (" & $LDelay & " ms.)")
ControlClick ($SROLauncher, "", 1000)
SetLog("Waiting Silkroad client.")
Do
Sleep (1000)
If WinExists ("ERROR", "OK") = 1 AND WinExists ("Silkroad Online", "OK") = 1 Then
SetLog("Failed to to launch sro_client due low launcher delay.")
ControlClick ("ERROR", "OK", 2)
ControlClick ("Silkroad Online", "OK", 2)
SetLog("Increasing launcher delay by 1000ms.")
$LDelay = $LDelay + 1000
Sleep ($RDelay)
Run ($SROPath & "\" & $SROLExe)
SetLog("ReLaunching Silkroad online.")
Do
Sleep(1000)
SetLog("Waiting Silkroad launcher.")
If WinExists ("Silkroad Online", "OK") = 1 Then
SetLog("Server is undergoing inspection.")
ControlClick ( "Silkroad Online", "OK", 2)
WinWait ($SROLauncher)
ControlClick ($SROLauncher, "", 1002)
SetLog("Sleeping server delay.")
Sleep($SDelay * 60 * 1000)
SetLog("Server delay slept (" & $SDelay & " min.), reconnecting.")
EndIf
Until WinActive ($SROLauncher)
SetLog("Silkroad launcher found.")
SetLog("Sleeping launcher delay.")
Sleep ($LDelay)
SetLog("Launcher delay slept (" & $LDelay & " ms.)")
ControlClick ($SROLauncher, "", 1000)
SetLog("Waiting Silkroad client.")
EndIf
Until WinExists ($SROClient)
SetLog("Silkroad client found.")
SetLog("Sleeping client delay.")
Sleep ($CDelay)
SetLog("Client delay slept (" & $CDelay & " ms.)")
MouseClick ("Left", 400, 300, 1, 0)
Sleep (1000)
MouseClick ("Left", 542, 435, 1, 0)
Sleep (1000)
SetLog("Sending account information.")
Send ($Account)
SetLog("Sleeping account delay.")
Sleep ($ADelay)
SetLog("Account delay slept (" & $ADelay & " ms.)")
Send ("{TAB}")
SetLog("Sending password information.")
Send ($Password)
SetLog("Sleeping password delay.")
Sleep ($PDelay)
SetLog("Password delay slept (" & $PDelay & " ms.)")
MouseClick ("Left", 460, 560, 1, 0)
If PixelGetCOlor (626, 334) = 0 Then
SetLog("Trying to log in.")
Do
If PixelGetCOlor (626, 334) = 0 Then
Sleep (5000)
Send ("{Enter}")
EndIf
Until PixelGetCOlor (626, 334) <> 0
Sleep (2000)
Send ("{Enter}")
Sleep ($RDelay)
If WinExists ($SROClient) = 1 Then
SetLog("Connected to the server.")
$Connected = 1
Else
SetLog("Disconnected from the server, restarting.")
$Connected = 0
EndIf
EndIf
EndFunc; => Connect()
Func CharSelect()
$Connected = 0
$Disconnected = 0
SetLog("Choosing character.")
Select
Case $CharPos = 1
MouseClick ("Left", 330, 373, 1, 0)
SetLog("Char 1 selected.")
Sleep ($C2Delay)
MouseClick ("Left", 763, 704, 1, 0)
Case $CharPos = 2
MouseClick ("Left", 523, 381, 1, 0)
SetLog("Char 2 selected.")
Sleep ($C2Delay)
MouseClick ("Left", 763, 704, 1, 0)
Case $CharPos = 3
MouseClick ("Left", 712, 372, 1, 0)
SetLog("Char 3 selected.")
Sleep ($C2Delay)
MouseClick ("Left", 763, 704, 1, 0)
EndSelect
SetLog("Waiting to get ingame.")
SetLog("Sleeping loadgame delay")
Sleep ($GDelay)
SetLog("Loadgame delay slept (" & $GDelay & " ms.)")
EndFunc; => CharSelect()
Func StartBot()
If $UseLxy = 1 Then
SetLog("Restarting Lxy.")
Send ("{F5}")
SetLog("Lxy restarted.")
MouseClick ("Left", 985, 5, 1, 0)
EndIf
Sleep(2000)
SetLog("Restarting srobot.")
Send("{INSERT}")
SetLog("srobot restarted.")
SetLog("========================================")
SetLog("========================================")
SetLog("")
EndFunc; => StartBot()
Func SetLog($LogIt)
$Log = FileOpen("SRO_restart.log.txt", 1)
FileWrite ($Log, $Date & $LogIt & @CRLF)
FileClose ($Log)
EndFunc; => SetLog($LogIt)
Func Pause()
$Paused = NOT $Paused
While $Paused
Sleep (100)
ToolTip('"Restart script paused"',0,0)
WEnd
ToolTip("")
EndFunc