Code:
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;Updated 8/1/2012
;Version 4.3
;Frozen.exe is no longer needed!
#include <Imagesearch.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>
AutoItSetOption("WinTitleMatchMode", 3)
$Form1 = GUICreate("Focus4", 400, 200, @DesktopWidth - 410, @DesktopHeight - 275)
GUISetBkColor(0x0000FF)
GUISetState(@SW_SHOW)
HotKeySet("{F1}", "GetFocus")
HotKeySet("{F3}", "CloseAll")
HotKeySet("{F2}", "StartUp")
;HotKeySet("{F4}", "LockBoxes")
$x2 = 0
$y2 = 0
$CrashCount = 0
$PASSWORD = "YOUR PASSWORD HERE"
Global $Focus = False
$Exists = 0
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func LockBoxes()
;~ WinActivate("Star Wars™: The Old Republic™")
;~ Sleep(500)
;~ Send("i")
;~ Sleep(500)
;~ $result2 = _Imagesearcharea("Images/LockBoxes.PNG",1,0, 0, @DesktopWidth/2, @DesktopHeight/2,$x2,$y2,50)
;~ While $result2 = 1
;~ MouseClick("Right", $x2, $y2, 2, 0)
;~ $result2 = _Imagesearcharea("Images/LockBoxes.PNG",1,45, 200, 332, 433,$x2,$y2,50)
;~ WEnd
While 1
ControlClick("Star Wars: The Old Republic", "Close the program", "Button2")
WEnd
EndFunc
Func CloseAll()
Close()
Exit
EndFunc
Func Close()
$Exists = WinExists("UntzBot v5.0x3 Lite")
if $Exists = 1 Then
ControlClick("UntzBot v5.0x3 Lite", "SAVE", "Button4", "Left", 1)
Sleep(200)
Send("x")
Sleep(200)
EndIf
$Exists = WinExists("DeathCheck")
If $Exists = 1 Then
Send("f")
EndIf
EndFunc
Func Focus()
While $Focus = True
$Exists = WinExists("Star Wars™: The Old Republic™")
if $Exists = 0 Then
Send("e")
Launch()
Else
WinActivate("Star Wars™: The Old Republic™")
Sleep(250)
ShowFocus()
EndIf
WEnd
EndFunc
Func GetFocus()
$Focus = Not $Focus
ShowFocus()
Focus()
EndFunc
Func ShowFocus()
If $Focus = True Then
If _Timer_GetIdleTime() > 5000 Then
ToolTip(_Timer_GetIdleTime(), 0, 0)
Else
ToolTip("SWTOR has focus.", @DesktopWidth/2, @DesktopHeight/2)
EndIf
If _Timer_GetIdleTime() >= 90000 Then
$pid = ProcessExists("Star Wars™: The Old Republic™")
ProcessClose("Star Wars™: The Old Republic™")
WinClose("Star Wars™: The Old Republic™")
Local $file = FileOpen("log.txt", 1)
$time = Time()
FileWriteLine($file, $time & "-- SWTOR was closed.")
FileClose($file)
ToolTip("")
EndIf
Else
ToolTip("")
EndIf
EndFunc
Func StartUp()
$Exists = WinExists("UntzBot v5.0x3 Lite")
if $Exists = 0 Then
Run("UntzBot50x3.exe", @ScriptDir)
Sleep(500)
If WinExists("UntzBot") Then
WinClose("UntzBot")
EndIf
ControlClick("UntzBot Login v5.0x3", "&FreeMode", "Button3", "Left", 2)
Sleep(200)
$result = ControlClick("UntzBot v5.0x3 Lite", "LOAD", "Button5", "Left", 2)
Sleep(200)
EndIf
$Exists = WinExists("DeathCheck")
If $Exists = 0 Then
Run("DeathCheck50x3.exe", @ScriptDir)
Sleep(200)
EndIf
WinMove("UntzBot v5.0x3 Lite", "", @DesktopWidth - 310, 5)
WinMove("DeathCheck", "", @DesktopWidth - 310, 600)
Sleep(300)
WinMove("Focus4", "", @DesktopWidth - 410, @DesktopHeight - 275)
EndFunc
Func Icon()
If WinExists("STAR WARS™: The Old Republic™") Then
Sleep(100)
Else
$x2 = 0
$y2 = 0
MouseMove(@DesktopWidth,0,0)
WinMinimizeAll()
Sleep(500)
$result2 = _Imagesearcharea("Images/Icon.PNG",1,0,0,@DesktopWidth,@DesktopHeight,$x2,$y2,100)
If $result2 = 1 Then
Mouseclick("Left", $x2, $y2, 2, 0)
MouseMove(@DesktopWidth,0,0)
ToolTip("Waiting 30 seconds for the Login window to appear.", @DesktopWidth/2, @DesktopHeight/2)
Else
ToolTip("The SWTOR icon was not found on your Desktop.", @DesktopWidth/2, @DesktopHeight/2)
Sleep(2000)
EndIf
EndIf
EndFunc
Func LoginScreen()
$x2 = 0
$y2 = 0
If WinExists("STAR WARS™: The Old Republic™") Then WinActivate("STAR WARS™: The Old Republic™")
$result2 = _WaitForImageSearch("Images/Splash.PNG",30,1,$x2,$y2,100)
If $result2 = 1 Then
Close()
$Size = WinGetClientSize("STAR WARS™: The Old Republic™")
While IsArray($Size) = 0
$Size = WinGetClientSize("STAR WARS™: The Old Republic™")
WEnd
WinMove("STAR WARS™: The Old Republic™", "", 0,0, $Size[0], $Size[1])
Sleep(500)
MouseClick("Left", $Size[0]/2, $Size[1]/2, 1, 0)
Send($PASSWORD)
ElseIf $result2 = 0 Then
ToolTip("SWTOR took longer than 30 seconds to load.", @DesktopWidth/2, @DesktopHeight/2)
Sleep(2000)
EndIf
EndFunc
Func CheckWin()
If WinExists("STAR WARS: The Old Republic") Then
While WinExists("STAR WARS: The Old Republic")
$pid = WinGetProcess("STAR WARS: The Old Republic")
ProcessClose($pid)
WEnd
EndIf
If WinExists("STAR WARS™: The Old Republic™") Then
$pid = WinGetProcess("STAR WARS™: The Old Republic™")
ProcessClose($pid)
Launch()
EndIf
EndFunc
Func Launch()
$x2 = 0
$y2 = 0
Icon()
LoginScreen()
$Exists = WinExists("STAR WARS™: The Old Republic™")
While $Exists = 0
ToolTip("Trying to re-launch SWTOR.", @DesktopWidth/2, @DesktopHeight/2)
MouseClick("Right", @DesktopWidth, 0, 1, 0)
Sleep(1000)
MouseClick("Left", 0, 0, 1, 0)
Icon()
LoginScreen()
$Exists = WinExists("STAR WARS™: The Old Republic™")
WEnd
MouseMove(@DesktopWidth,0,0)
ToolTip("Looking for Login and Play buttons to appear.", @DesktopWidth/2, @DesktopHeight/2)
$result2 = _Imagesearcharea("Images/Login.PNG",1,0,0,@DesktopWidth,@DesktopHeight,$x2,$y2,100)
Mouseclick("Left", $x2, $y2, 1, 0)
MouseMove(@DesktopWidth,0,0)
$result2 = _WaitForImageSearch("Images/Play.PNG",30,1,$x2,$y2,100)
If $result2 = 1 Then
Mouseclick("Left", $x2, $y2, 1, 0)
MouseMove(@DesktopWidth,0,0)
While WinMove("Star Wars™: The Old Republic™", "", 0, 0, 800, 600, 0) = 0
WinMove("Star Wars™: The Old Republic™", "", 0, 0, 800, 600, 0)
WEnd
ToolTip("Waiting for the Character select screen to appear.", @DesktopWidth/2, @DesktopHeight/2)
$result2 = _WaitForImageSearch("Images/CharSelect.PNG",60,1,$x2,$y2,100)
Mouseclick("Left", $x2, $y2, 1, 0)
ToolTip("Waiting for character to load.", @DesktopWidth/2, @DesktopHeight/2)
$result2 = _WaitForImageSearch("Images/CharLoaded.PNG",60,1,$x2,$y2,100)
ToolTip("Character loaded! Starting up UntzBot.", @DesktopWidth/2, @DesktopHeight/2)
StartUp()
ElseIf $result2 = 0 Then
CheckWin()
EndIf
If $Focus = True Then
Send("q")
EndIf
EndFunc
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