Sign in to follow this  
Followers 0
qwee

Bot, need help to make it run minimized!

1 post in this topic

#1 ·  Posted (edited)

Hey!

I've downloaded a Bot a while ago, and I'm sick if that it can't run minimized! Well, it can run minimized in games, but not in channel! So if someone could fix so it can run minimized in channel aswell, that would be so awesome!

I TAKE NO CREDITS IN THIS SCRIPT! I'M NOT THE CREATOR! I JUST WANT TO MAKE IT ABLE TO RUN MINIMIZED!

;=======================================================
;Smorg's Diablo II LOD Mini OOG Controller for Battlenet
;Version 1.0
;=======================================================
opt("PixelCoordMode", 2)
opt("MouseCoordMode", 2)
opt("RunErrorsFatal", 0)
opt("SendKeyDelay", 200)

Global $RestoreRealm = 0;

$RunLoop = 0
$CurrentCDkey = IniRead(@ScriptDir & "\Config.ini", "Settings", "LastCDkeyused", "")

#Include "IniRead.au3"
#Include "Checksums.au3"

If $CDkeyCount > 0 Then
    SetNextCDkey()
EndIf

FileCopy(@ScriptDir & "\_Database\use", $D2PathName & "\data\local\use",9)

If WinExists($D2WinName) Then
   MsgBox(0, "", "Looks like a d2 window is already open! Close it before launching the bot.")
   Exit
EndIf

;AdLibEnable("ShowSum", 200) ;for debugging... replace the checksum in ShowSum() to adjust what to look for

If LaunchD2() = 0 Then
   MsgBox(0, "", "Oh noes! we failed to log in! Better check the error log to find out why...")
   Exit
Else
   LogEvent(0, "Launched Diablo II and successfully logged in to the Lobby.")
EndIf

if ($Use = 1) OR ($Use = 2) Then
    ChannelJoin()
endif

;

Func ChannelJoin()
    opt("SendKeyDelay", 40)
    MouseClick("Left", 90, 470, 1, $MenuMouseSpeed)
    ScreenWait("Channel", 15000)
    if $Use = 1 Then
        send("/j " & $Channel_,1)
        send("{ENTER}")
        Sleep(750)
    endif
    send($InitMSG,1)
    send("{ENTER}")
    Sleep(750)
    opt("SendKeyDelay", 200)
EndFunc

Func ChannelMSG($TheMessageNow)
if ($Use = 1) OR ($Use = 2) Then
    opt("SendKeyDelay", 40)
    MouseClick("Left", 35, 430, 1, $MenuMouseSpeed)
    send($TheMessageNow,1)
    send("{ENTER}")
    Sleep(750)
    opt("SendKeyDelay", 200)
endif
EndFunc 

;===============================
;Main Loop: Your code goes here!
;===============================
While 1
   For $RunCount = 1 To 9999
      $RunLoop = $RunLoop + 1
      If CreateGame() = 1 Then
         $begin__ = TimerInit()
         while ((ScreenCheck("Lobby") = 0) AND (ScreenCheck("Channel") = 0))
            Sleep(1000)
            If (TimerDiff($begin__) > IniRead(@ScriptDir & "\Config.ini", "Settings", "GameTimeout", "120000")) Then
               ExitLoop
            EndIf
         wend
         If ($RunLoop > 9) AND ($CDkeyCount > 0) Then
            Sleep(1000+($GameCreateDelay*1000))
         Else
            Sleep(5000+($GameCreateDelay*1000))
         EndIf
      Else
         $RunLoop = 0
         LogEvent(0, "Restarting D2 - New keys!! (If available)")
         opt("SendKeyDelay", 5)
         D2Kill()
         if $CDkeyCount > 0 Then
            SetNextCDkey()
         endif
         for $loopage = 1 to 50
            If LaunchD2() = 0 Then
               LogEvent(0, "Failed to login #" & $loopage)
               D2Kill()
               Sleep(300000)
            Else
               ExitLoop
            EndIf
         Next
         opt("SendKeyDelay", 200)
        if ($Use = 1) OR ($Use = 2) Then
             ChannelJoin()
        endif
      EndIf
      If ($RunLoop > 9) AND ($CDkeyCount > 0) Then
          ChannelMSG($LogoutMSG)
         $RunLoop = 0
         LogEvent(0, "Restarting D2 - New keys!! (If available)")
         opt("SendKeyDelay", 5)
         D2Kill()
         SetNextCDkey()
         for $loopage = 1 to 50
            If LaunchD2() = 0 Then
               LogEvent(0, "Failed to login #" & $loopage)
               D2Kill()
               Sleep(300000)
            Else
               ExitLoop
            EndIf
         Next
         opt("SendKeyDelay", 200)
         if ($Use = 1) OR ($Use = 2) Then
             ChannelJoin()
        endif
      EndIf
      ;Chicken()
      ;Exit
   Next
WEnd
;===============================

Func SetNextCDkey()

If ($CDkeyCount > 1) Then
    $ClaKey_M = "\data\global\sfx\cursor\wavindx.wav"
    $ExpKey_M = "\data\global\chars\am\cof\amblxbow.cof"
    If (FileCopy(@ScriptDir & "\CDkeys\" & $CurrentCDkey & "\wavindx.wav", $D2PathName & $ClaKey_M,9) = 1) AND (FileCopy(@ScriptDir & "\CDkeys\" & $CurrentCDkey & "\amblxbow.cof", $D2PathName & $ExpKey_M,9) = 1) Then
       LogEvent(0, "CDkey was injected successfully ~#" & $CurrentCDkey)
    Else
       LogEvent(0, "CDkey was NOT injected successfully ~#" & $CurrentCDkey)
    EndIf
    
    $CurrentCDkey = $CurrentCDkey + 1
    if ($CDkeyCount < $CurrentCDkey) THEN
       $CurrentCDkey = 1
    endif
    
    IniWrite(@ScriptDir & "\Config.ini", "Settings", "LastCDkeyused", $CurrentCDkey)
EndIF
    
EndFunc

;Launches D2, logs in, and gets you to the lobby. Returns 0 if failed, 1 if success.
Func LaunchD2()
   LogEvent(0, "Smorg's Mini OOG controller is launching Diablo II LOD for Battlenet...")
   If Run($D2PathName & "\" & $D2Executable & " " & $Paramaters,$D2PathName) = 0 Then
      LogEvent(1, "Failed to launch Diablo at " & $D2PathName & "\" & $D2Executable & " Check your D2PathName key in Config.ini")
      Return 0
   Else
      LogEvent(0, "D2 Loaded successfully!")
   EndIf
   WinWaitActive($D2WinName)
    For $kuk = 1 to 1000
        $WINsize = WinGetPos($D2WinName)
        if ($WINsize[2] > 800) then
            exitloop
        else
            sleep(100)
        endif
    Next
   WinMove($D2WinName, "", 0, 0)
   MouseClick("Left", 100, 100, 1, $MenuMouseSpeed)
   If ScreenWait("TitleScreen", 15000) = 0 Then Return 0
   MouseClick("Left", 394, 353, 1, $MenuMouseSpeed)
   If ScreenWait("LoginScreen", 20000) = 0 Then Return 0
   MouseClickDrag("Left", 477, 336, 300, 336, $MenuMouseSpeed)
   Sleep($MenuStaticDelay)
   Send($A,1)
   Sleep($MenuStaticDelay)
   Send("{TAB}")
   Sleep($MenuStaticDelay)
   Send($P,1)
   Sleep($MenuStaticDelay)
   MouseClick("Left", 395, 470, 1, $MenuMouseSpeed)
   If ScreenWait("CharacterSelect", 20000) = 0 Then Return 0
       
       $Xclix = 0
       $Yclix = 0
        If $CharSlot = 1 Then
           $Xclix = 180
        $Yclix = 130
       ElseIf $CharSlot = 2 Then
           $Xclix = 450
       $Yclix = 130
       ElseIf $CharSlot = 3 Then
           $Xclix = 180
       $Yclix = 225
       ElseIf $CharSlot = 4 Then
           $Xclix = 450
       $Yclix = 225
       ElseIf $CharSlot = 5 Then
           $Xclix = 171
       $Yclix = 318
       ElseIf $CharSlot = 6 Then
           $Xclix = 447
       $Yclix = 315
       ElseIf $CharSlot = 7 Then
           $Xclix = 180
       $Yclix = 410
       ElseIf $CharSlot = 8 Then
           $Xclix = 458
       $Yclix = 406
       Else
           MsgBox(0, "", "You must pick a character slot! 1-8")
           EXIT(0)
        EndIf
   MouseClick("Left", $Xclix, $Yclix, 1, $MenuMouseSpeed)
   Sleep($MenuStaticDelay)
   MouseClick("Left", 692, 557, 1, $MenuMouseSpeed)
   If ScreenWait("Lobby", 20000) = 0 Then Return 0
   Return 1
EndFunc

;Create a game with dynamic waits & retries. Returns 0 if failed, 1 if success.
Func CreateGame()
   For $Retry = 0 to 4
    ;If ScreenCheck("Lobby") = 0 Then
   If (IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "WasDeadStatus", "1")) = 1 Then
      LogEvent(0, "Bot Died. Stopping due to that...")
      EXIT(0)
  EndIf
  
  
    If (IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "WasHostiled", "1")) = 1 Then
       IniWrite(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "WasHostiled", "0")
      $RunCount = Random(1, 5000, 1)
   EndIf

$RunCount = $RunCount+$Retry

   LogEvent(0, "Attempting to create the game " & $GameName & $RunCount & " This is attempt number " & $Retry)
   
    if ScreenCheck("Channel") = 1 Then
    ChannelMSG(StringReplace ( $NGMSG, "_GN_", $GameName & $RunCount))
endif
   
   MouseClick("Left", 590, 462, 1, $MenuMouseSpeed)
   If ScreenWait("CreateButton", 15000) = 0 Then
      MouseClick("Left", 712, 461, 1, $MenuMouseSpeed)
      Sleep(2000)
      ContinueLoop
   EndIf
   
   Send($GameName & $RunCount)
   Sleep(200)

    If $GamePassLength = 1 Then
        Send("{TAB}")
        Send($RunCount)
    ElseIf $GamePassLength = 9 Then
        Sleep(10)
    ElseIf $GamePassLength > 1 Then
        Send("{TAB}")
        For $lll = 1 to $GamePassLength
            Send(Random(1, 9, 1))
        Next
    else
        Send("{TAB}")
        Send($GamePassLength)
    EndIf
   MouseClick("Left", 676, 418, 1, $MenuMouseSpeed)
    If ScreenWait("GameJoin", 15000) = 0 Then
        If IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0") = 0 Then
            LogEvent(1, "Game create screen not detected after 5 seconds... will retry the game join.")
            MouseClick("Left", 711, 461, 1, $MenuMouseSpeed)
            ContinueLoop
        EndIf
   EndIf
   Local $Timeout = TimerInit()
   While ScreenCheck("GameJoin") = 1
      If IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0") = 0 Then
          If TimerDiff($Timeout) > 30000 Then
             LogEvent(1, "Looks like we got stuck on the game create screen for over 30 seconds...")
             Return 0
          EndIf
      EndIF
      Sleep(500)
  WEnd
  
  If IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0") = 1 Then
   IniWrite(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0")
   Return 1
  Endif
  
   If (ScreenCheck("Lobby")+ScreenCheck("Channel")) = 1 Then
      LogEvent(1, "Failed to Join! Bnet needs to fix their damn servers!!! Lets just retry...")
      ContinueLoop
   ElseIf ScreenCheck("GUIBar") = 1 Then
      LogEvent(0, "Successfully joined the game after " & Round((TimerDiff($Timeout)/1000), 2) & " seconds.")
      Return 1
   Elseif IniRead(@ScriptDir & "\Kuk_Bot.ini", "Intercom", "IsInGame", "0") = 1 Then
    Return 1
   Else
      LogEvent(1, "Hmm, looks like we got lost somewhere while attempting to create a game...")
      Return 0
   EndIf
Next
LogEvent(1, "Failed to create a game after 5 retries.")
Return 0
EndFunc

;Dynamic wait for a screen. Feed a screen to wait for from Checksums.au3, or define your own. Also supply a timeout. Returns 0 if failed, 1 if success
Func ScreenWait($ScreenName, $Timeout)
   Local $Checksum[5]
   Local $Sum
   $Checksum = Eval($ScreenName)
   $Time = TimerInit()
   Do
      Sleep(200)
      $Sum = PixelChecksum($Checksum[1], $Checksum[2], $Checksum[3], $Checksum[4])
      If $Sum = $Checksum[0] Then Return 1
   Until TimerDiff($Time) > $Timeout
   LogEvent(1, $Sum & " does not match the expected the checksum of " & $Checksum[0] & " for the menu " & $ScreenName & " at coordinates (" & $Checksum[1] & " ," & $Checksum[2] & " ," & $Checksum[3] & " ," & $Checksum[4] & ") and timed out after " & $TimeOut & " milliseconds.")
   Return 0
EndFunc

;Simple screen detection, so you don't have to type out the pixelchecksum every time. Returns 1 if the screen matches, 0 if failed.
Func ScreenCheck($ScreenName)
   Local $Checksum[5]
   $Checksum = Eval($ScreenName)

;LogEvent(1, PixelChecksum($Checksum[1], $Checksum[2], $Checksum[3], $Checksum[4]) & " is checksum for: " & $ScreenName)

   If PixelChecksum($Checksum[1], $Checksum[2], $Checksum[3], $Checksum[4]) = $Checksum[0] Then
      Return 1
   Else
      Return 0
   EndIf
EndFunc

;Quit D2. will try to chicken first if you are in-game.
Func D2Kill()
   For $Retry = 0 To 9
      Send("{ESC}")
      If Not WinExists($D2WinName) Then ExitLoop
      Sleep(500)
   Next
   WinClose($D2WinName)
   WinKill($D2WinName)
EndFunc

;Do a quick & effective game exit. Suitable for both emergency chickens, and standard save & exits.
Func Chicken()
   For $Retries = 1 To $ChickenRetries
      Send($KEY_ClearScreen)
      MouseUp("Right")
      MouseUp("Left")
      Send("{ESC}")
      $Timeout = TimerInit()
      While 1
         If (PixelGetColor(481, 535) <> 5406092) AND (PixelGetColor(320, 537) <> 6521492) Then
            ExitLoop
         ElseIf TimerDiff($Timeout) > 500 Then
            LogEvent("Failed to open the main menu, will retry... Retry # " & $Retries)
            ContinueLoop 2
         EndIf
         Sleep(100)
      WEnd
      MouseClick("Left", 400, 280, 1, 0)
      $Timeout = TimerInit()
      While TimerDiff($Timeout) < $ChickenTimeout
         If (PixelGetColor(600, 575) <> 6512995) AND (PixelGetColor(5, 575) <> 2697257) Then ExitLoop 2
         Sleep(100)
      WEnd
      If $Retries >= $ChickenRetries Then
         LogEvent("Max Retries exceeded, Will terminate the Game.exe process")
         ProcessClose("Game.exe")
      Else
         LogEvent("Failed to chicken, Will retry the chicken...")
      EndIf
   Next
   LogEvent("Chicken was a success! ^^")
EndFunc

;Returns 0 if either a menu is open or we aren't in game, and returns 1 if the minipanel is in its expected position. (this requires it to be open)
Func IsMenuOpen()
   If PixelGetColor(325, 559) <> 5274764 Then
      If PixelGetColor(462, 559) <> 8429760 Then
         Return 0
      EndIf
   EndIf
   Return 1
EndFunc

;Simple logging function
Func LogEvent($Code, $String)
   $LogFile = FileOpen(@ScriptDir & "\Logs\Events.txt", 1)
   Select
      Case $Code = 0
         FileWriteLine($LogFile, @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " [I]> " & $String)
      Case $Code = 1
         FileWriteLine($LogFile, @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " [E]> " & $String)
   EndSelect
   FileClose($LogFile)
EndFunc

;Debug function... replace the search pattern with whatever you need.
Func ShowSum()
   ToolTip(PixelCheckSum($GameJoin[1], $GameJoin[2], $GameJoin[3], $GameJoin[4]), 0, 0)
EndFunc

Thanks!

Edited by qwee

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0