Want to launch your bots with the command line and have it accept custom arguments? It’s easy, and today you will learn how. But first, let’s talk about why we should and show you some of the built-in command line arguments that secretly already exist in Ubot!
Why Do This?
If you’ve never used the command line before than you likely have no clue why this is important. That’s fine, you don’t have to be an expert at everything but you should know the how and the why for doing this.
Launch Bots Easily
Letting your bots accept command line arguments allows the bot to take action based on the argument. For instance, you can have a main bot call a helper bot to parse a file in the background by using the files path as an argument. This gives you a really easy way to integrate the bot with other tools and an easy way to launch it without having to hunt down the bot’s .exe.
No User Interface
It takes a lot of time to plan out a user interface. You have to decide how the user will use the bot by determining what buttons it will have and what they will do. You also have to make sure they aren’t pressed out of order if you have multiple buttons. It takes time to add these features, which is time many don’t have. User interfaces usually aren’t necessary for small bots that do a couple things. Instead of buttons you can have arguments that can trigger custom actions in your bot, saving you time from having to interact with buttons and text fields.
Command Line Arguments You Can Use With Ubot Bots
Did you know Ubot can already take 3 arguments already? It’s true!Â
- /play – by using this argument you can have a compiled bot AUTOMATICALLY run WITHOUT having to press the play button!
- /auto – closes a compiled bot when it is finished running.Â
- /hide – launches a compiled .exe bot hidden, so you don’t have to see the user interface.
These arguments can be used with bots that also accept custom arguments, just add it to the end of the command. For example:
C:\FolderPath\cle.exe sourceultra.com /play
In this example my compiled bot is cle.exe, and it is made to navigate to the first argument it receives. The last argument /play tells the bot to automatically run. The end result is the bot launches and navigates to sourceultra.com without having to click play!
How to Use Arguments in a Bot
Creating custom arguments for your bot is simple. This example is for the bot I mentioned above that navigates to the first argument it receives.Â
comment("This is the list the command line arguments will be added to")
plugin command("HeopasCustom.dll", "Heopas command line arguments list", %ARGUMENTS)
if($comparison($list total(%ARGUMENTS),"<",2)) {
    then {
        alert("Please provide at least 1 parameter")
        stop script
    }
    else {
    }
}
comment("Use the 1st argument")
add list to list(%nav list,$list from text($list item(%ARGUMENTS,1),","),"Delete","Global")
wait(1)
loop($list total(%nav list)) {
    navigate($next list item(%nav list),"Wait")
    wait(1)
}
alert("Done!")
This command comes from Heopas Custom plugin which is available in the Ubot forum here. There are other plugins that can accomplish this but they are either paid or hard to find.
How to Make it Even Easier to Launch Your Bot Via Command Line
Setting an environmental variable allows you to give your bot a name that can then save you from having to type its file path in the command line. This saves time, effort, and makes it easier to remember how to launch your bot. Here’s how to do it:
- Hit Win-key and search for environment variables, click the Edit the “System environment variables”
- Click the button at the bottom “Environment Variables”
- Add to User or System variables by clicking “New”
- Enter the variable name you want this shortcut to be in top field
- Enter the variable FILEPATH of the bot’s .exe in bottom field
Now when you enter the variable name in command prompt the bot will be opened! System variables are available for everyone, User are only available to you.Â
So now instead of typing the filepath for my bot C:\FolderPath\cle.exe, I can simply type the variable name!
You can use the Shell command to now launch this bot from any bot like this:
plugin command("Advanced Shell.dll", "shell batch hidden", "VariableName google.com /auto", "Yes")
You can find this command in the free plugin Advanced Shell. The shell command is extremely useful and can also be used to run batch and powershell scripts.
Â
Warning: Invalid argument supplied for foreach() in /home/actionreed/public_html/su/wp-content/themes/thrive-theme/inc/classes/class-thrive-theme-comments.php on line 463