Jump to content

Looping for 2 Hours


bvr
 Share

Recommended Posts

The program I am making is an anti-idle bot for a game. For the character not to expire, I need to be in a game for 2 hours. So I was going to make him walk around every few seconds in a game for 2 hours, then I want it to pick another character and do the same. There is 8 characters. How do I make it loop for 2 hours? Like I will have 4 movments, then I want it to repeat those movements for 2 hours, then pick another char.

Link to comment
Share on other sites

The help file will have everything that you are looking for. Try looking up loops, mouse movement and making the script sleep. Try making the script and then post the code if it doesn't work, gotta put some effort into it before asking for help. It's all in the help file.

Good luck :lmao:

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Link to comment
Share on other sites

The program I am making is an anti-idle bot for a game. For the character not to expire, I need to be in a game for 2 hours. So I was going to make him walk around every few seconds in a game for 2 hours, then I want it to pick another character and do the same. There is 8 characters. How do I make it loop for 2 hours? Like I will have 4 movments, then I want it to repeat those movements for 2 hours, then pick another char.

I know that my answer is not a very good solution, but I seems to work. :lmao:

$end = 5000; 1000*60*60*2 for 2 Hours
$begin = TimerInit()
$dif =0 
While $dif < $end
$dif = TimerDiff($begin)
; do your movements
WEnd
MsgBox(0,"Time Difference",$dif)

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

$hour = @HOUR
While @HOUR <> $hour + 2
;-------do moves----------
;-------add a sleep here for a few seconds or something--------
WEnd
;---------go pick next character--------
;do the loop 8 times

--somethin liek that?

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

  • Moderators

Local $EndTime = 2;# of hours
Local $StartTime = TimerInit()
Local $TimesToLoop = ''
GoToActionFunc()
While 1
    If TimerDiff($StartTime) / 1000 / 60 / 60 >= $EndTime Then
        GoToActionFunc()
        $TimesToLoop = $TimesToLoop + 1
        $StartTime = TimerInit()
    EndIf
    If $TimesToLoop = 4 Then ExitLoop
    Sleep(10000)
WEnd

Func GoToActionFunc()
 ;Do your grab function here
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

geezzz, i thought this was something new... well, let me know how this works... or dont work

;*********** Use **************
; based on a full screen
; Press Esc to terminate script
; Press F9 to get the characters colors & position
; Press F8 to Start the Game
; 
; by Valuater...... Enjoy!!!  
;******************************
;#include <GuiConstants.au3>

Dim $win_Left = 100; you need to set these 4 to the size of the screen you are working with
Dim $win_Top =100
Dim $win_Right =500
Dim $win_Bottom =500

Dim  $var, $Lpos[9], $Rpos[9], $x, $pos
Dim $charactor[9], $Chars = 8, $L

HotKeySet("{ESC}", "Terminate")
HotKeySet("{F9}", "Get_Charactor")
HotKeySet("{F8}", "Start_Game")

ToolTip('Game Bot - is Running',0,0)
While 1
    Sleep(50) 
WEnd

Func Terminate()
    Exit 0
EndFunc

Func Get_Charactor()
    $pos = MouseGetPos()
    $Svar = PixelGetColor( $pos[0] , $pos[1])
    $var = "0x" & Hex($Svar,6)
    For $x = 1 to $Chars
        If $charactor[$x] = "" Then
            $charactor[$x] = $var
            $Lpos[$x] = $pos[0]
            $Rpos[$x] = $pos[1]
            ExitLoop
        EndIf
    Next
    MsgBox(64, "Character #" & $x, "Color is " & $charactor[$x] & "   " & @CRLF & "Mouse position is X= " & $pos[0] & " Y= " & $pos[1] & "   ", 3)
EndFunc

Func Start_Game()
    For $t = 1 to $Chars
        If $charactor[$t] = "" Then
            MsgBox(64,"Sorry", "You Need to set Chraracter #" & $t & "   ", 3)
            Return
        EndIf
    Next
    For $L = 1 to $Chars
        Do_Action($L)
    Next
EndFunc

Func Do_Action($L)
    $My_Char = $charactor[$L]
    $Mx = $Lpos[$L]
    $My = $Rpos[$L]
    MouseMove( $mx, $my)
    $Hour = @HOUR
    
    ToolTip('Moving Character #' & $L & " - Started at Hour #" & $Hour & '  ',0,0)
    
    While @HOUR <> $Hour + 2
        
        $Color = PixelSearch( $mx-10, $my-10, $Mx+10, $my+10, $My_Char, 10, 2)
        If Not @error Then
            $Mx = Random($win_Left+10,$win_Right-10,1)
            $My = Random($win_Top+10,$win_Bottom-10,1)
            MouseDown("Left")
            MouseMove( $mx, $my)
            MouseUp("Left")
        Else
            MsgBox(64,"OOPS!!!", "We have lost Charactor #" & $L & "   ", 10)
            Return
        EndIf
    WEnd
    
EndFunc

not tested ( only in my head )( and good luck with that from a hobbiest)

8)

EDIT

I Just realized ( still in my hobbiest head) that this wont work to exactly 2 hours on each character.... oh well, if it works at all i would be happy

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Here is what I got, which works except for the ani-idling for 2 hours

;Software: bv muler_v1.0

;Author: bvr

;http://www.royersoft.com

$D2Path = IniRead("bvconfig.ini", "General", "D2Path", "")

$D2Exe = IniRead("bvconfig.ini", "General", "D2Exe", "")

$D2Parameters = IniRead("bvconfig.ini", "General", "D2Parameters", "")

$Account = IniRead("bvconfig.ini", "General", "Account", "")

$Password = IniRead("bvconfig.ini", "General", "Password", "")

$CharOne = IniRead("bvconfig.ini", "General", "CharOne", "")

$CharTwo = IniRead("bvconfig.ini", "General", "CharTwo", "")

$CharThree = IniRead("bvconfig.ini", "General", "CharThree", "")

$CharFour = IniRead("bvconfig.ini", "General", "CharFour", "")

$CharFive = IniRead("bvconfig.ini", "General", "CharFive", "")

$CharSix = IniRead("bvconfig.ini", "General", "CharSix", "")

$CharSeven = IniRead("bvconfig.ini", "General", "CharSeven", "")

$CharEight = IniRead("bvconfig.ini", "General", "CharEight", "")

$LoadSleep = IniRead("bvconfig.ini", "Delays", "LoadSleep", "")

$LoginSleep = IniRead("bvconfig.ini", "Delays", "LoginSleep", "")

$CharacterSleep = IniRead("bvconfig.ini", "Delays", "CharacterSleep", "")

$GameSleep = IniRead("bvconfig.ini", "Delays", "GameSleep", "")

D2Start()

D2Activate()

D2Login()

CharPicker()

D2GameMaker()

Antidle()

D2Exit()

;----Loading Diablo II----

Func D2Start()

Run($D2Path & '\' & $D2Exe & ' ' & $d2parameters, $D2Path )

WinWait ( 'Diablo II' )

WinActivate ( 'Diablo II' )

Sleep ( 500 )

WinMove ( 'Diablo II', '', 0, 0 )

Sleep ($LoadSleep)

EndFunc

;----D2 Activate----

Func D2Activate()

WinActivate("Diablo II")

WinMove("Diablo II", "", 0, 0)

EndFunc

;----Login----

Func D2Login()

Send("{TAB}")

Sleep(500)

Send($Account)

Sleep(500)

Send("{TAB}")

Sleep(500)

Send($Password)

Sleep(500)

Send("{ENTER}")

Sleep($LoginSleep)

EndFunc

;----Character Chooser-----

Func CharPicker()

Select

Case $CharOne = 1

Send("{ENTER}")

Case $CharTwo = 1

Send("{RIGHT}")

Sleep(250)

Send("{ENTER}")

Sleep($D2CharSelect)

Case $CharThree = 1

Send("{DOWN}")

Sleep(250)

Send("{Enter}")

Sleep($D2CharSelect)

Case $CharFour = 1

Send("{DOWN}")

Sleep(250)

Send("{RIGHT}")

Sleep(250)

Send("{ENTER}")

Sleep($D2CharSelect)

Case $CharFive = 1

Send("{DOWN}")

Sleep(250)

Send("{DOWN}")

Sleep(250)

Send("{ENTER}")

Sleep($D2CharSelect)

Case $CharSix = 1

Send("{DOWN}")

Sleep(250)

Send("{Down}")

Sleep(250)

Send("{Right}")

Sleep(250)

Send("{ENTER}")

Sleep($D2CharSelect)

Case $CharSeven = 1

Send("{DOWN}")

Sleep(250)

Send("{DOWN}")

Sleep(250)

Send("{DOWN}")

Sleep(250)

Send("{ENTER}")

Sleep($D2CharSelect)

Case $CharEight = 1

Send("{Down}")

Sleep(250)

Send("{Down}")

Sleep(250)

Send("{Down}")

Sleep(250)

Send("{RIGHT}")

Sleep(250)

Send("{ENTER}")

Sleep($CharacterSleep)

EndSelect

EndFunc

;----Game Maker----

Func D2GameMaker()

MouseClick("left", 593, 490)

Sleep(1000)

$name = Random(1000, 999999)

Send($name)

Sleep(1000)

Send("{TAB}")

Sleep(250)

$name = Random(1000, 999999)

Send($name)

Sleep(1000)

Send("{ENTER}")

Sleep($GameSleep)

EndFunc

;----Anti-Idle----

Func Antidle()

MouseMove(529, 268)

Sleep(1000)

MouseClick("left")

Sleep(60000)

MouseMove(501, 402)

Sleep(1000)

MouseClick("left")

Sleep(60000)

MouseMove(254, 362)

Sleep(1000)

MouseClick("left")

Sleep(60000)

MouseMove(261, 218)

Sleep(1000)

MouseClick("left")

Sleep(60000)

EndFunc

;----Exit Game----

Func D2Exit()

Send("{ESC}")

Sleep(200)

Send("{UP}")

Sleep(200)

Send("{ENTER}")

Sleep(2000)

EndFunc

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...