Learn how to program
by playing video games.

PyAutoGUI Video Game Bot Tutorial

Get Started with a Great Beginner AI Project!

November 15, 2019
Part of: PyAutoGUI Video Game Bot Tutorial

In this tutorial series, I'll show you how to use PyAutoGUI to write a video game bot in Python. This is a great beginner AI project to strengthen your programming skills, or to take your first steps into video game automation. We'll be playing Earth & Beyond, a space MMO, and in it we're going to automate a trade route to earn credits.

In this introductory video, I explain what we're going to build and how to install Earth & Beyond.

GitHub repo for this project: https://github.com/learncodebygaming/enb_bot
Download Earth & Beyond: https://www.net-7.org/
Earth & Beyond Emulator donations: https://forum.enb-emulator.com/index.php?/donate/make-donation/
Additional PyAutoGUI tutorial at Automate the Boring Stuff with Python: http://automatetheboringstuff.com/chapter18/

GUI automation is a botting technique where you control the mouse and keyboard using code, and you use the pixels on the screen to get information about the state of the game. We aren't bypassing the normal game inputs, and we aren't accessing any hidden information. With GUI automation, we're trying to emulate a human sitting at a computer.

Before doing this tutorial, you'll want to have a basic understanding of Python. If you're new to programming or Python, you should do an introductory Python tutorial first. But once you get through that, this is a great beginner programming project to help you get more experience writing Python.

We're going to be using the PyAutoGUI library. This is a great library to learn, even for things other than botting, as it can be used for automated testing, working with spreadsheets, or automating any other tedious, repetitive task.

In this tutorial we'll be botting Earth & Beyond, a space MMO. It's a good game for this project because it has a lot of repetitive gameplay, and it has keybindings that will making botting this game a little easier. Earth & Beyond also has many static items in its interface, and this will make it easier when we start to do image recognition.

Installing Earth & Beyond can be tricky, so here's how to do it: Go to https://www.net-7.org/, click on the FAQ link in the main menu, click on the "Game play and Issues" tab, and finally expand "How do I get into the game !!". Follow the steps listed there exactly.

I had a few problems come up during installation, and here's how I fixed them.

On step 11, running the Earth & Beyond configuration, it would open and then close immediately, even when running as administrator. If this happens to you, go to the "EBCONFIG" folder, right click on "E&BConfig.exe", select "troubleshoot compatibility", and it should suggest you use "Windows XP mode" for this file, so choose that.

When you run your configuration, select "Windowed Mode" and choose a resolution smaller than your full monitor resolution so you can easily switch between the game and your code when developing. It's also required that you run the Performance Test whenever you change your configuration.

On step 14, clicking the play button on the launcher, when I initially did this I got an error that said "server failed to respond to login attempt" and then the launcher would close. To fix this, in the launcher under the debug section, I changed the "Local IP" selection to the second item in the list.

Hopefully you're able to get the game installed successfully now.

Once you have it running, inside the game under "Options", then "Control", select the "Default FPS" keybindings if you want to follow along with me exactly. These keybindings allow us to use WASD control for movement.

At this point, it would be a good idea to play the game normally for a little bit to get familiarized with how the game works. Since it is an old game, expect to find some bugs, and be aware that the questing system doesn't always explain itself very well when you're going through the missions.

Hopefully you're excited to start building your first video game bot. We'll get started with the code in the next tutorial.

Your First PyAutoGUI Game Bot
Let's create our first simple video game bot, a timing bot! We'll be learning the basics of PyAutoGUI mouse and keyboard input controls. Links GitHub …
Automate Your Bot Script Creation
In this video, I show you how to use pynput to capture mouse and keyboard inputs in the game, and then use those recordings to …
Basic Image Recognition
PyAutoGUI's image matching features allow us to get information from the screen. In this video, I show you how to use these simple image recognition …
Ben Johnson My name is Ben and I help people learn how to code by gaming. I believe in the power of project-based learning to foster a deep understanding and joy in the craft of software development. On this site I share programming tutorials, coding-game reviews, and project ideas for you to explore.