#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.10.0
Author: Mixam
Script Function:
Run Awesom-O 24/7
#ce ----------------------------------------------------------------------------
#include <String.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include <File.au3>
#include <GuiToolBar.au3>
Global $thisprogram =
"MixamAO beta5" Global $redvexname =
IniRead($thisprogram &
".ini",
"Settings",
"RedVex",
"") Global $preventrd =
IniRead($thisprogram &
".ini",
"Settings",
"RDprevention",
"1") Global $managelogs =
IniRead($thisprogram &
".ini",
"Settings",
"ManageLogs",
"1") Global $maxgametimesecs =
IniRead($thisprogram &
".ini",
"Settings",
"MaxGameLength",
600) Global $banwait =
IniRead($thisprogram &
".ini",
"Settings",
"BanWaitTime",
3600000) Global $redvexdir =
IniRead($thisprogram &
".ini",
"Settings",
"RedVexDir",
"") Global $refreshtray =
IniRead($thisprogram &
".ini",
"Settings",
"RefreshTray",
1) Global $redvexexe =
($redvexdir &
$redvexname &
".exe") Global $gamelog =
$redvexdir &
"games.txt" Global $sleep =
IniRead($thisprogram &
".ini",
"Settings",
"Sleep",
"1000") Global $diablofull =
IniRead($redvexdir &
"Awesom-O.ini",
"Settings",
"GameExe",
"Diablo II.exe") Global $mixamAOlog =
(@ScriptDir &
"\MixamAO.log") Global $lastgamestr,
$runforsecs,
$rdgametime Global $newlogfolder =
@ScriptDir &
"\Game Logs\" &
@YEAR &
"-" &
@MON &
"-" &
@MDAY &
" " &
@HOUR &
"." &
@MIN &
"." &
@SEC
If _Singleton($thisprogram,
1) =
0 Then MsgBox(4096,
"Warning",
"An occurence of " &
$thisprogram &
" is already running") _FileWriteLog(@ScriptDir & "\MixamAO.log", "ERROR: An occurence of " & $thisprogram & " is already running")
Opt("OnExitFunc",
"_normalexit")
MsgBox(4096,
"Warning",
"RedVex is running already. Hitting OK will close redvex and D2 and start MixamAO") _FileWriteLog(@ScriptDir & "\MixamAO.log", "ERROR: RedVex is running already.")
_Kill()
MsgBox(4096,
"Error",
"Can't find " &
$thisprogram &
".ini :(") _FileWriteLog(@ScriptDir & "\MixamAO.log", "ERROR: Can't find " & $thisprogram & ".ini :(")
_FileCreate(@ScriptDir & "\MixamAO.log")
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: MixamAO.log was missing. It has been created")
MsgBox(4096,
"Error",
"Can't find " &
$redvexexe &
" :(") _FileWriteLog(@ScriptDir & "\MixamAO.log", "ERROR: Can't find " & $redvexexe & " :(")
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: MixamAO Started")
_Load()
_CrashCheck()
; _Load runs redvex then waits for Awesom-O to open. Then it sleeps for 2 mins to
; allow the first game to be made before _LastGameSecsAgo runs.
Run($redvexexe &
" -run -hide",
$redvexdir) _FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: Redvex Loaded")
; _Kill closes redvex and all D2's you have open. Be aware that it doesn't just
; close the bot's window, it closes all D2 windows. Also cleans the tray now.
; Also now saves all the log files to Game Logs folder in the MixamAO folder
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: Redvex and D2 killed")
IniWrite($redvexdir &
"Awesom-O.ini",
"Bot0",
"StartNumber",
$nextgamenumber) _FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: game start number changed to " & $nextgamenumber)
_CleanTray($redvexname, $refreshtray)
FileCopy ($redvexdir &
"\Awesom-O.log",
$newlogfolder &
"\" &
@YEAR &
"-" &
@MON &
"-" &
@MDAY &
" " &
@HOUR &
"." &
@MIN &
"." &
@SEC &
" Awesom-O.log")
; _CrashCheck checks if its been over your set max time since the last game was created
; or if redvex has closed and if either happens, it kills and restarts D2 and RedVex
; It now also checks for r/d and if some errors pop up.
$lastgamestr = _FindLastGame()
$runforsecs = _LastGameSecsAgo()
$rdgametime = _RDGameSecsAgo()
If $lastgamestr =
"Empty" Then $nextgamenumber = 1
$nextgamenumber = _FindLastGameNumber() + 1
Local $bansleep =
$banwait
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: IP Ban detected")
_Kill()
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: Waiting " & $bansleep & "ms for ban to be over")
$bansleep = $bansleep * 2
_Load()
$lastgamestr = _FindLastGame()
If $runforsecs >
$maxgametimesecs Then _FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: " & $maxgametimesecs & "secs is up. Crash detected")
_Kill()
_Load()
_Kill()
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: 19 games made in " & $rdgametime & "secs. Waiting " & (3660 - $rdgametime) & "secs to restart")
Sleep((3660 -
$rdgametime) *
1000) _Load()
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: End Program window detected. Closing D2")
WinClose("Diablo_0: Diablo II.exe - Application Error") _FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: Application Error window detected. Closing D2")
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: Redvex Error Detected")
_Kill()
_Load()
WinClose("Microsoft Visual C++ Runtime Library") _FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: Microsoft Visual C++ Runtime Library Error detected")
_Kill()
_Load()
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: Detected that Redvex is not running")
_Kill()
_Load()
; _FindLastGame searches the log file for the last entry with the game name in it then
; returns a string with that last game name and the time the game was made. It also now
; returns a string if there is a ban message for r/d support
MsgBox(4096,
"Error",
"Unable to locate the game log.") _FileWriteLog(@ScriptDir & "\MixamAO.log", "ERROR: Unable to locate the game log")
$line = $line + 1
$line = $line - 1
$linstr = "Empty"
; _FindLastGameNumber() returns the last game number made in the games.txt file
Func _FindLastGameNumber
()
MsgBox(4096,
"Error",
"Unable to locate the game log.") _FileWriteLog(@ScriptDir & "\MixamAO.log", "ERROR: Unable to locate the game log")
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: No games found, setting last game number to 0")
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: No games found, setting last game number to last found lastgamenumber")
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: No games found, setting last game number to last found lastgamenumber")
$line = $line - 1
; _LastGameSecsAgo searches the string returned by _FindLastGame and compares its time
; to the current time to see how long ago the game was made. Not sure if Number()
; is required here or not yet. Have to test without it. The +86400 is for when the game was
; made at 00:??:??
If $lastgamestr =
"Empty" Then $lastgamestr = _FindLastGame()
If $lastgamestr =
"Empty" Then
Local $secsago =
(@HOUR *
3600 +
@MIN *
60 +
@SEC) -
($gamehour *
3600 +
$gamemin *
60 +
$gamesec)
$secsago = $secsago + 86400
; This function checks how long ago the 19th game was made. This is so i can detect if
; it is likely that 20 games will be made in an hour or less. For preventing r/d.
Local $secsago =
(@HOUR *
3600 +
@MIN *
60 +
@SEC) -
($gamehour *
3600 +
$gamemin *
60 +
$gamesec)
$secsago = $secsago + 86400
; This function clicks on each icon with the name = $iTitle to remove the old icons at the moment it does
; The Redvex icons, but if kingsob brings back the Awesom-O icon then I can clean that too.
Func _CleanTray
($iTitle,
$a) Local $hToolbar,
$ItemCount,
$ID,
$i $hToolbar =
ControlGetHandle('[Class:Shell_TrayWnd]',
'',
'[Class:ToolbarWindow32;Instance:1]')
$ItemCount = _GUICtrlToolbar_ButtonCount($hToolbar)
For $i =
0 To $ItemCount -
1 $ID = _GUICtrlToolbar_IndexToCommand($hToolbar, $i)
_GUICtrlToolbar_ClickButton2($hToolbar, $ID)
_FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: Tray cleaned")
; #FUNCTION# ====================================================================================================
; Name...........: _GUICtrlToolbar_ClickButton
; Description ...: Clicks a specific button
; Syntax.........: _GUICtrlToolbar_ClickButton($hWnd, $iCommandID[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 1]]]])
; Parameters ....: $hWnd - Handle to the control
; $iCommandID - Button command ID
; $sButton - Button to click
; $fMove - Mouse movement flag:
; | True - Mouse will be moved
; |False - Mouse will not be moved
; $iClicks - Number of clicks
; $iSpeed - Mouse movement speed
; Return values .:
; Author ........: Paul Campbell (PaulIA)
; Modified.......: Gary Frost
; Remarks .......:
; Related .......: _GUICtrlToolbar_ClickAccel, _GUICtrlToolbar_ClickIndex
; Link ..........;
; Example .......; Yes
; ==============================================================================================================
Func _GUICtrlToolbar_ClickButton2
($hWnd,
$iCommandID,
$sButton =
"left",
$fMove =
False,
$iClicks =
1,
$iSpeed =
1) If $Debug_TB Then _GUICtrlToolbar_ValidateClassName
($hWnd) Local $tPoint,
$tRect,
$iX,
$iY,
$iMode,
$aPos
$tRect = _GUICtrlToolbar_GetButtonRectEx($hWnd, $iCommandID)
$tPoint = _WinAPI_PointFromRect2($tRect)
$tPoint = _WinAPI_ClientToScreen($hWnd, $tPoint)
_WinAPI_GetXYFromPoint2($tPoint, $iX, $iY)
$iMode =
Opt("MouseCoordMode",
1) Opt("MouseCoordMode",
$iMode) _WinAPI_ShowCursor
(False)EndFunc ;==>_GUICtrlToolbar_ClickButton
; #FUNCTION# ====================================================================================================
; Description ...: Returns the top/left coordinates of a tagRECT as a tagPOINT structure
; Parameters ....: $tRect - tagRECT structure
; $fCenter - If True, the return will be a point at the center of the rectangle, otherwise the left/top
; +coordinates are returned.
; Return values .: Success - tagPOINT structure
; Author ........: Paul Campbell (PaulIA)
; Remarks .......: This function is used to get the click position for many of the click functions in the library
; Related .......:
; ===============================================================================================================
Local $iX1,
$iY1,
$iX2,
$iY2,
$tPoint
$iX1 = $iX1 + (($iX2 - $iX1) / 2)
$iY1 = $iY1 + (($iY2 - $iY1) / 2)
; #FUNCTION# ====================================================================================================
; Description ...: Returns the X/Y values from a tagPOINT structure
; Parameters ....: $tPoint - tagPOINT structure
; $iX - X value
; $iY - Y value
; Return values .:
; Author ........: Paul Campbell (PaulIA)
; Remarks .......: This function extracts the X/Y values from a tagPOINT structure
; Related .......: _Lib_GetPointFromXY, _Lib_GetXYFromRect
; ===============================================================================================================
; This function changes the defualt exit for auto it to run _kill then exit so exiting MixamAO
; will also exit D2 and Redvex
_FileCreate ($gamelog & ".temp.txt")
Local $lines =
_FileCountLines($gamelog)
For $x =
($lines -
39) to $lines
FileMove($gamelog &
".temp.txt",
$gamelog,
1)
_Kill()
IniWrite($redvexdir &
"Awesom-O.ini",
"Bot0",
"StartNumber",
1) _FileWriteLog(@ScriptDir & "\MixamAO.log", "Notice: MixamAO Closed Manually. Game start number changed back to 1")
FileMove (@ScriptDir &
"\MixamAO.log",
$newlogfolder &
"\MixamAO.log") _FileCreate(@ScriptDir & "\MixamAO.log")
FileCopy ($gamelog,
$newlogfolder &
"\games.txt") _cleangameslog()
$line = 0