Originally Posted by
TheDank
Here is the code to close SWTOR if the game stays on the same screen for 1:30:
PixelChecksum() may delay a bots' ImageSearch(), so instead of using the former, one could make use of _Timer_GetIdleTime(). That "only" measures the last time since "user" interaction. The idea behind this is that when the game hangs, the bot will hang as well and not generate user input because what the bot is waiting for will not appear on the screen. The idle timer then keeps increasing to the point defined in the script, like 90 seconds.
So instead of looking at the screen, waiting for things to change, the script looks at when user or bot generated input has last occurred.
I've taken the liberty to change your code accordingly but haven't tested it yet:
Code:
#include <Timers.au3>
#include <ScreenCapture.au3>
$Count = 0
$CrashCount = 0
While 1
Sleep(100)
$idletimer = _Timer_GetIdleTime()
;ToolTip($idletimer, 0, 0);Remove the ";" from the beginning of this line to display the idle timer
If $idletimer >= 90000 Then
If WinExists("Star Wars™: The Old Republic™") Then
;ScreenCapture()
;Remove the ";" from the line above to enable the screenshot feature
WinClose("Star Wars™: The Old Republic™")
$Count = 0
Local $file = FileOpen("log.txt", 1)
$time = Time()
FileWriteLine($file, $time & "-- SWTOR was closed.")
FileClose($file)
EndIf
ExitLoop
EndIf
WEnd
Func ScreenCapture()
$Screen = _ScreenCapture_Capture("")
_ScreenCapture_SaveImage(@ScriptDir & "\Screen Logs\" & "Capture" & $CrashCount & ".jpg", $Screen)
$CrashCount += 1
EndFunc ;==>ScreenCapture
Func Time()
$DAY = @WDAY
Select
Case $DAY = 1
$DAY = "SUN"
Case $DAY = 2
$DAY = "MON"
Case $DAY = 3
$DAY = "TUE"
Case $DAY = 4
$DAY = "WED"
Case $DAY = 5
$DAY = "THU"
Case $DAY = 6
$DAY = "FRI"
Case $DAY = 7
$DAY = "SAT"
EndSelect
Return ($DAY & " " & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & " ")
EndFunc ;==>Time
Bayoya,
The error message in your screenshot appears when the script is trying to access an array when at the time of that access it was a string. An array is like a table or spreadsheet containing one or more values and requires something similar to coordinates to access these values. A string can only hold one value and doesn't know what to do when accessed using coordinates. That's the origin of the error.
Try replacing
Code:
MsgBox(0, "", $Size[0] & " " & $Size[1])
near the top of the script with the following:
Code:
While 1
$Size = WinGetClientSize("UntzBot v5.0x3 Lite")
If IsArray($Size) Then
ExitLoop
EndIf
Sleep(100)
WEnd
MsgBox(0, "", $Size[0] & " " & $Size[1])