Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • CLI / Batching / Client sorting Tutorials - Learn how to use Quickstart!


    QuestLog

    Recommended Posts

    Welcome everyone! 

    This is a short guide to mostly show the script/code I created to allow for ease of use of the Quickstart feature.

    Quickstart is the use of the command line to open up your DreamBot clients with code.

    To start, you need the template to load a client

    (for example: java -jar C:\Users\YOURNAME\DreamBot\BotData\client.jar -script "Test Script" -account "Account 1" -covert)

    **more help at https://dreambot.org/guides/user-guide/quickstart/

     

     

    I have created a python script which will utilize this method of loading and create a template (which you can change!) for your account, script, and other client settings.

    This script will use each row you paste into the CSV file (using the format username:password:proxynickname) and plug it into the template I created or you adjusted. 

    The script will then create a single batch file which will use that template for all of the accounts.

    Running the batch file will check for an existing client with the username from CSV and create a client if it did not already exist.

    Otherwise it will skip, wait a few seconds, then attempt the next account.

    Below is the how to text file I created within the folder in case you don't want to download the package.

    Quote

    How to:

    use the convention user:pass:proxy nickname
    paste the data into account_details.csv.

    !before running the script!;


            :::: Batch code ::::
    :::: within the Batch code you will see the following ::::
    :::: vars with {xxxx} are already set and should not be changed ::::
    :::: vars without brackets are changeable. refer to https://dreambot.org/guides/user-guide/quickstart/ ::::
    :::: accounts are generated in +1 incremental value (account_1, account_2) ::::


    :::: Placeholders :::: 

    rem Account details for Account {account_number}  - used for shuffling. if you wish to re-shuffle, run the PY code again to create a new .bat
    set "USERNAME={username}"                         - loaded from the CSV file
    set "PASSWORD={password}"              - loaded from the csv file
    set "PROXY={proxy}"                               - loaded from the csv file
    set "BREAKS=break names - separate by comma"      - make sure to change these yourself to your custom break names (break1,break2)
    set "FPS=desired fps"                   - i generally keep it at 15-20
    set "FRESH=fresh/nofresh"               - fresh start for each client
    set "LAYOUT=no_preference"              - layouts = no_preference / fixed / resizeable_classic / resizeable_modern
    set "SCRIPT_NAME=script_name"                     - change script_name to your desired script
                     


    rem Launch the DreamBot client with Account {account_number} details
    start "" /b javaw -jar "%DREAMBOT_JAR%" -Xmx512M -accountUsername "%USERNAME%" -accountPassword "%PASSWORD%" -proxy "%PROXY%" 
    -world "%WORLD%" -covert -layout "%LAYOUT%" -breaks "%BREAKS%" -fps %FPS% -fresh %FRESH% -script "%SCRIPT_NAME%" >nul 2>&1 


    :::: these are the parameters for the client, called upon from the variables set earlier. ::::
    :::: Add script specific params at the end before '>nul' (-params "param") ::::
    :::: change or add parameters as needed. variables can be set up above then called in the client CLI. ::::
    :::: again, refer to refer to https://dreambot.org/guides/user-guide/quickstart/ for all the other params. ::::
    :::: refer to your script developer's forum page for script specific params! ::::


    :::: the batch "template" will be duplicated for each account row in the csv file. ::::
    :::: the batch file will also stagger opening of clients and check if clients already exist with the same username. ::::
    :::: the acc_client_storage.txt file will write the %USERNAME% if a client does not exist with that user. ::::
    :::: if the user already exists in the storage file, that user will be skipped in the client loading process. ::::

                        :::: adding new accounts ::::
    :::: to add new accounts open the account_details.csv. I have mine split between F2P and P2P lists and have provided them as such. ::::
    :::: import using the format username:password:proxyname (the nickname). use one row per account. it is necessary for the template. ::::
                            

                             :::: IMPORTANT ::::
    :::: after ANY new account imports run the python script again to generate your new batch file with all of the accounts in their templates ::::
    :::: you can rename your batch file to whatever script or task you created. example: F2P_Goldfarming_accounts ::::
     

     

    Now let's get into the code.

    Python main script:

    import os
    import random
    import csv
    import subprocess
    
    def read_account_details(file_path):
        accounts = []
        # Check if the file exists before attempting to open it
        if not os.path.exists(file_path):
            print(f"CSV file '{file_path}' not found.")
            return accounts  # Return an empty list if the file does not exist
        # Create the CSV file if it doesn't exist
        if not os.path.exists(file_path):
            try:
                with open(file_path, 'w') as file:
                    file.write('username:password:proxy\n')  # Write the header row
                print(f"CSV file '{file_path}' created successfully.")
            except Exception as e:
                print(f"Error creating CSV file: {e}")
        
    
        try:
            with open(file_path, 'r') as file:
                reader = csv.reader(file, delimiter=':')  # Assuming delimiter is ':'
                for i, row in enumerate(reader):
                    account_dict = {
                        "account_number": i + 1,
                        "username": None,
                        "password": None,
                        "proxy": None
                    }
                    if len(row) == 3:
                        username, password, proxy = row
                        account_dict.update({
                            "username": username if username else None,
                            "password": password if password else None,
                            "proxy": proxy if proxy else None
                        })
                        accounts.append(account_dict)
                    else:
                        print(f"Invalid account details at line {i + 1}. Skipping...")
        except Exception as e:
            print(f"Error reading from CSV file: {e}")
        return accounts
    
    def shuffle_accounts(accounts):
        try:
            random.shuffle(accounts)
            print("Accounts shuffled successfully.")
            for account in accounts:
                print(f"Account number {account['account_number']} shuffled.")
        except Exception as e:
            print("Error shuffling accounts:", e)
            raise
        return accounts
    
    def generate_check_existing_clients_command(username):
        """
        Constructs a PowerShell command string to check if a DreamBot client window
        with the specified username in its title exists.
    
        Args:
            username (str): The username to check for in window titles.
    
        Returns:
            str: PowerShell command string.
        """
        # PowerShell command to list all processes and filter by window titles containing the username
        ps_command = f'powershell "Get-Process | Where-Object {{$_.MainWindowTitle -match \'{username}\'}} | Select-Object -ExpandProperty MainWindowTitle"'
        return ps_command
    
    # Define the template for launching the DreamBot client with pre-launch check
    template = """
    @echo off
    rem Set the path to your DreamBot client JAR file
    set "DREAMBOT_JAR=%USERPROFILE%\\DreamBot\\BotData\\client.jar"
    
    rem Account details for Account {account_number}
    set "USERNAME={username}"
    set "PASSWORD={password}"
    set "PROXY={proxy}"
    set "BREAKS=//example_breaks_here//"
    set "WORLD=//example_world_here//"
    set "FPS=//example_fps_here//"
    set "FRESH=true"
    set "LAYOUT=no_preference"
    set "SCRIPT_NAME=//example_script_name_here//"
    
    rem Set the delay in seconds between clients
    set /a "delay=%RANDOM% %% (240 - 50 + 1) + 50"
    
    rem Check for existing DreamBot client for the same username
    set "existingClient="
    for /f "delims=" %%a in ('{check_cmd} 2^>^&1') do set existingClient=%%a
    if "%existingClient%"=="Get-Process : The term 'Get-Process' is not recognized" (
        echo PowerShell command execution failed. PowerShell might not be available or enabled on this system. Attempting to launch client...
    ) else if not "%existingClient%"=="" (
        echo DreamBot client for %USERNAME% is already running. Skipping...
        timeout /t 2 /nobreak >nul
    ) else (
        echo Launching DreamBot client for %USERNAME%, %PROXY% ...
        rem Launch the DreamBot client and redirect output to null
        start "" /b javaw -Xmx512M -jar "%DREAMBOT_JAR%" -accountUsername "%USERNAME%" -accountPassword "%PASSWORD%" -proxy "%PROXY%" -world "%WORLD%" -covert -layout "%LAYOUT%" -breaks "%BREAKS%" -fps %FPS% -fresh %FRESH% -script "%SCRIPT_NAME%" >nul 2>&1
        echo Waiting %delay% seconds before starting the next client...
        timeout /t %delay% /nobreak >nul
    )
    """
    
    file_path = 'account_details.csv' 
    accounts = read_account_details(file_path)
    
    if not accounts:
        print("No valid account details found or file is missing. Exiting...")
        exit(1)  # Exit the script if no accounts were found or file is missing
    
    accounts = shuffle_accounts(accounts)
    
    batch_script_content = ""
    for account in accounts:
        check_cmd = generate_check_existing_clients_command(account["username"])
        batch_script_content += template.format(account_number=account["account_number"], username=account["username"], password=account["password"], proxy=account["proxy"], check_cmd=check_cmd) + "\n"
    
    try:
        with open("launch_accounts.bat", "w") as f:
            f.write(batch_script_content)
        print("Batch script generated successfully.")
    except Exception as e:
        print("Error saving batch script:", e)

     

    This will create the CSV file for you if it doesn't exist. You must copy paste your accounts with the proper format (make sure you use ':' between user:pass:proxy). 

    There is ~mostly~ proper error catching so if you should see errors in cmd or VScode/other workstations.

     

    After pasting info into the CSV, run the script again and it will update the batch file with all of your accounts.

    Next just run the batch file!

     

     

    That's all for the quickstart and batching sections. 

    I personally wanted to have a way to cleanly sort all of my clients, and have a good method of quickly identifying problems with a button.

    I currently use "Dexpot" application for setting up multiple desktops. I use a keybind to swap between desktops and I keep all my p2p/f2p clients

    on separated desktops. You can also set up Dexpot to send all DB clients to a specific desktop (but only works if all clients go to the same location, so just p2p or f2p etc).

    Within Dexpot there is a convenient settings called windows catalogging.

    What this does is with a keybind you can instantly dynamically see all of your programs within a grid view to check for any visual problems with your bots, or find the name for the client easily.

     

     

    This is good, but not quite enough for me as I would have all the clients in a single stacked spot on the screen.

    Enter AutoHotKey.

    AHK allows you to use code to sort all of your clients to a specified monitor using whatever layout you prefer.

    NOTE: I have a large 4k monitor and I am not proficient with C++ and I am positive the code can be improved to be more dynamic across all screen sizes. If you have any suggestions please let me know so I can make it more universal.

    This function is more intended for those familiar with coding to adjust to their monitor size and other needs.

    But that doesn't mean you can't try it and tweak it how you wish. It's pretty straightforward.

    Here is the code:

    ; Define the width and height of the DreamBot client window
    WindowWidth := 765
    WindowHeight := 503
    
    ; Define the overlapping width and height
    OverlapWidth := 410
    OverlapHeight := 150
    
    ; Calculate the number of rows and columns
    NumRows := 5
    NumColumns := 6
    
    ; Calculate the total width and height of each row and column
    TotalRowWidth := (WindowWidth - OverlapWidth) * NumColumns + OverlapWidth
    TotalColumnHeight := (WindowHeight - OverlapHeight) * NumRows + OverlapHeight
    
    ; Get all windows with the title "DreamBot"
    WinGet, DreamBotWindows, List, DreamBot
    
    ; Sort the windows alphabetically
    Sort, DreamBotWindows, R
    
    ; Calculate the starting position for the grid
    StartX := 0
    StartY := 0
    
    ; Get the screen width and height
    SysGet, ScreenWidth, 0
    SysGet, ScreenHeight, 1
    
    ; Loop through each window and position them in the grid formation
    Row := 1
    Column := 1
    Counter := 0
    Loop, %DreamBotWindows%
    {
        X := StartX + (Column - 1) * (WindowWidth - OverlapWidth)
        Y := StartY + (Row - 1) * (WindowHeight - OverlapHeight)
    
        ; Adjust the window position if it goes off-screen
        if (X + WindowWidth > ScreenWidth)
        {
            X := StartX
            Y := Y + (WindowHeight - OverlapHeight)
            Row++
        }
    
        if (Y + WindowHeight > ScreenHeight)
        {
            ; Handle the case when the screen height is not enough for all windows
            MsgBox, Not enough screen height to position all windows.
            break
        }
    
        WinMove, % "ahk_id " DreamBotWindows%A_Index%, , X, Y
    
        Counter++
        if (Counter >= NumColumns)
        {
            Counter := 0
            Column := 1
            Row++
        }
        else
        {
            Column++
        }
    }
    
    ; Focus on the first DreamBot window
    WinActivate, % "ahk_id " DreamBotWindows1

    you can adjust the columns/rows, and the overlapping.

    Save this as a .ahk file and you can just double click it to start the sorting. If you want to you can use the AHK program to compile it into an EXE.

     

    Below are the files and folders needed for those who don't want to copy paste the code and ensure proper file/folder structure (this is important)

     

    NOTE: I removed the downloads for now unless there are requests for it. I always preach safe browsing and I wouldn't trust a random download myself. Only if a moderator or verifiable source is willing to verify the folders/files will I put them up for download.

    Happy scaping!

     

    Please leave suggestions. I am willing to improve upon this as it would help everyone!

     

     

    Edited by QuestLog
    Removed downloads
    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
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.