I can't stress enough on how much I love your content. I recently got done learning python and being a gamer I wished there were channels / ways to practice code via gaming. Stumbling across your channel has made me SO much more eager to practice and that says a lot because i'm really lazy when it comes to practice. You're gonna have millions of subs in no time and i'm glad I got to find your channel before that happens!
You are the best, thanks a lot. You don't have the most professional videos but you are the only one who makes these types of videos for everyone's understanding. Thank you
THANK YOU ! OMG i've been struggling for the last 3 hours trying to figure out why when i was getting into Star wars the old republic, the clicks wouldnt work! simply cause I didn't run CMD as administrator ! Thank you so much +1 sub
nice video! you could set pyautogui.PAUSE variable instead of using a sleep between commands .. but this is a minor optimization :) this variable sets up a pause (in seconds) after each PyAutoGUI call.
Thanks! Good point about pyautogui.PAUSE, it's a good feature to be aware of. I did think about using that, but I felt doing the sleeps manually gives us more flexibility.
I don't know of any books that cover this specifically. Your best bet is to find a book that discusses automation more generally. I recommend this one for Python: amzn.to/3fJsbyV Thanks for watching!
Hi! I like how beginner-friendly these videos are. Thank you for that! I have some questions on my mind. A) Do you have a video/tutorial on how to make the UI of VSC look more-or-less like yours? The basic setup, if you will: installation & folders (if they matter), theme, settings & all that jazz - maybe even a brief introduction? - Also your terminal looks neat & tidy - can this be easily replicated? It's not a big deal, but unlike yours (at 9:05 ), mine keeps printing the folder's path every time after the script stops, which looks similar to this: C:\Users\User MacUsername\Documents\Programming Lessons\VS Code\bot_lessons>▌ B) Is there a more immediate way to stop the script? Would be useful in case when the script's wait times are too long (while in the middle of "sleep(200)", it won't initiate the failsafe) or for when the mouse cursor won't move for any reason. - Related to that: is there a way to end any (activated) input while stopping the script (i.e. release every key & mouse button, etc, that will otherwise persist after the failsafe has done its magic)?
Hi I really liked the way you teach it's make it's easy to understand. But was wondering is it only for me that my windows terminal or powershell never displays starting whenever I run script it's just show me blank screen and all outputs is shown when script ends .
A few other viewers had this problem, too. You need to add the flush parameter to your print() statements. Change your countdown timer code to look like this: github.com/learncodebygaming/enb_bot/blob/master/timing_bot/main.py#L32
Thanks for the amazing tutorial! I have a small issue with vs code. It does not recognise the FAILSAFE command or any other pyautogui commands. I have pyautogui installed correctly as well as pip. I am very new to Python so please excuse any mistakes I may be making.
Thank you so much for the Tutorial - run through. Quick question as a Python beginner: Does python not read code from top to bottom, left to right? I can see that your code is working but I was always under the impression that to call functions, loops, etc into Main that need to be above def main() - does this not matter?
Code is read from top to bottom, but when we write a function we are only defining it, not executing it. The code inside of the function only gets executed once you call it. And functions need to be defined before they are called. So you can try this out: if you call main() above where we define it with def main(): it will actually cause an error that looks something like NameError: name 'main' is not defined. Hope that helps.
@@LearnCodeByGaming Thank you very much for your reply much appreciated! can I ask a quick other question: do you know how to listen to 'outputs' from the game itself? IE instead of waiting for your game to 'load' your action (sleep between commands) - can you program it so it only reads off the queues of the game?
@@marc10uae I haven't done that before, but if the game doesn't have an official API for interacting with it then you'd have to read the game's memory.
Is there anyway for the botting to be done where it doesn't interrupt you using a computer? Because having it take over control of your input means you can't do anything while there bot run. Anyway to like hook it into the game so it runs on its own without disrupting your using the computer? Thanks! And great tutorial!
How can I control mouse in "full screen" mode. I mean If I kept moving the mouse right, the screen will rotate and keep going, using the actual mouse. However, using python, when I move the mouse using any package out there, it doesn't rotate. when I enable the pan mode in game, the mouse actually works and move with python, so the game responds to it. Can you help me with a package that can deal with the full screen-infinite rotation mode?, or just the keywords, cause I am kinda stuck in this for a while. Thanks as always.
That sounds like a tricky problem. I don't really have any great ideas. Have you tried making your script move the mouse just a few pixels away from the edge, not quite all the way?
@@LearnCodeByGaming yeah I tried that. I found a way around it by enabling pan and move to rotate the screen, then by drag function it works. I know it's a cheat, but it worked for me 😅
hey nice guide!, i'd like to ask you for help, i'm trying to make a farm bot for a Fps online game but it looks like it just recognize raw input, so i started to search for some information, but i seems nothing works for me, i'm using win10 and python 3.8, any suggest of yours that i could try?
Yeah check out my video on PyDirectInput. It doesn't work for every game, but it works in a lot of cases where PyAutoGUI doesn't: ruclips.net/video/LFDGgFRqVIs/видео.html
This might be a less important question. I've st upvisual studio code, and everything is working. But my terminal prints are only shown after the fact. If I run the code, I'll see the main.py being run, but only after the script is run through completely, all the prints will appear. So I can't see the countdown untill it is already over. Know anything about this?
If you're on Python version 3.3+, you can add the flush parameter to your print statements to get them to output immediately, like: print("Something", flush=True) On earlier version of Python you need to do this instead to flush: import sys sys.stdout.flush() Those would be the first things to try, because it sounds like your terminal output is getting caught in the buffer.
Thanks for the Video. I have tried this on a different mmo, but it didn't work. I know what the problem is. Because what i did on coding side, i didnt get any problem trouble shooting and another program such as txt file gave pleasurable responses. So the MMO, I have tried to use this bot, has a gaming guard application to block users using mouseclicker programs. Do I have a way to bypass this? I only need key pressing and visually picking my enemies during the bot usage. Thank you
Hi Bro, i got stucked at the keydown stuff. here Is my prob. The Key i is actually sended to game (i play in window mode btw) but nothing happened. The way i know the KeyPress cmd was sended Is ..if i do open a chat in game..It actually writes the i Key. It seems like only the script works in chat mode. Could be due to a special game protection or do i miss something? Btw i run sublime editor as admin, and i do start script by bash Shell ( run as admin ) and ofc i do select game window on time
If you're playing a game other than Earth & Beyond, you might check out my video on PyDirectInput. That's a library I made because certain games don't work correctly with PyAutoGUI. It doesn't work for 100% of games, but a lot of people have reported success with it. It sounds like you're doing everything else right.
I tried to do a program for Minecraft but it won't recognise the keyboard inputs in Java. I tried it on an other game (kerbal space program) and then it worked. Do you have a idea what the problem could be with Minecraft? By the way I was not trying to cheat or something I was just trying to automatically build a house.
Sometimes games that are built with DirectX will only respond to DirectX inputs. I wrote PyDirectInput to solve that (checkout my video on it), but I don't know of an equivalent project in Java. Essentially you need to call the right Windows API.
You can use pyautogui.pixelMatchesColor(x, y, (r, b, g)) to check for a RBG color at a given X/Y position. At the end of the 4th video in this series I talk a little bit about that function. But the best way to move to a certain color would be 1. Take a screenshot like: im = pyautogui.screenshot(), 2. Use nested for-loops to loop over every X and Y coordinate on the screen, 3. Check the color at each position using: im.getpixel((x, y)), 4. If your color is found then pyautogui.moveTo(x, y) and break out of the loops. Depending on your exact use case, you can make different optimizations to this like only checking every 5th pixel, or searching in a spiral from the center of the screen.
May I ask the mouse events generated by pyautogui detectable? Are those events differ from the events generated by an ordinary mouse? I'm playing a browser game that detecting auto click bots, so I want to make my script undetectable. Thanks.
Hi, I did the countown timer just like you did, but instead of adding 1 dot every second, my code just waits for 10 seconds and then prints "Starting..........Go" all together, what am I doing wrong? Also I noticed that the .py icon for you is yellow, I dont know why but mine is different (blue), can it have anything to do with that?
I've wondered the same thing myself. You could definitely do it with other techniques that don't require the screen to be rendered, but with GUI automation we need to be able to see all those pixels. If you're running multiple VMs on your desktop you'll eventually hit a performance bottleneck depending on how good your hardware is. If you do it on a server, I'm not sure how you would get the screen rendered for each VM (despite not being output to a physical screen), but I'm sure there must be a way. I'll add this topic to my list of video ideas.
@@LearnCodeByGaming Seems like we have the same thought process. For my idea it would require the screen to be rendered due to the mouse inputs at specific areas etc. But can't think of a way where I could do this with more than like 4 vms running on my machine at the same time.
@@LearnCodeByGaming Hi, finally got around to playing around with PyAutoGUI. However within some games like Rainbow Six Siege, even when my terminal and script it self is being ran as an admin it still doesn't click within the game. I've played around with the duration of clicks, put the game into windowed, border less and tried full screen aswell.
@@Bros10 Most likely those games only recognize DirectInput functions. PyAutoGUI does Win32 inputs. This issue has come up for a few people, so I plan on doing another video about it. If you want to have a go at it before then, there's an article explaining the issue here: bit.ly/2DOZKOw I've also found some good source code start with here: bit.ly/33M0DSz
@@LearnCodeByGaming Ahh that's interesting, that's what I assumed however when I'm in an actual game and not in the menu system. Even though I just want the script for the menu system is recognises the inputs when in an actual game. I'll take a read of the article and look at the source code. Cheers for the response
Does this bot still work even if you're doing something? What I mean is that I want to run this bot while I'm doing something on the same PC. May it be that the bot is still working even if the game is minimized or if it is not minimized, I can still move or use the mouse/keyboard on some other things (like doing homework, surfing the net, coding, etc).
No you can't. These are simulated key presses and mouse events, meaning its mimicking user input. Moving your mouse and pressing keys would disrupt it. You'd probably have to run the game and script in a container or develop a memory hack if you wanted to do something like that.
I'm trying to make a gui for botting a game. But I want to have a window that has events such as Right Left Spacebar etc. And if you select on type in for how long.
Hey Johnathan. For this, you will need the pyautogui.hotkey() method, for example, if you want to press the 'd' key, use pyautogui.hotkey('d') in the documentation there are keys that can be used. This is the link:- pyautogui.readthedocs.io/en/latest/keyboard.html
hi nice nice video. I would like to ask why my script cannot find image in my online game, but works when not in game window. if i changed the pic.jpg into some portion of my screen the script can see it. but when i changed the pic.jpg into something i snipped from the game window, the script cannot see it? What is the problem? i hope you can help me. thanks here are my simple script import pyautogui, time time.sleep(2) print(pyautogui.locateOnScreen("pic.jpg")) I am not a programmer, i am just beginning into coding it really fun.
Hi Ronaldo. I would first try running your game in windowed mode, instead of full screen mode, if you're not already. The second thing I would do is try using pyautogui.screenshot("saved_screenshot_name.png") to save a screenshot image of exactly what PyAutoGUI is seeing. If the screenshot looks fine, then there must be a problem with the pic.jpg you're using. Either make a new cropped image to search for (maybe try saving it as a png instead of jpg?), or try using the optional confidence parameter to ignore minor differences, like this: pyautogui.locateOnScreen('pic.png', confidence=0.9). But if the game screen just appears all black in the screenshot, then your only choice is to find another Python library that hopefully works with the game you're playing. Good luck!
@@LearnCodeByGaming hi, thank you for the reply. i tried the confidence command but gaved me this error TypeError: _locateAll_python() got an unexpected keyword argument 'confidence' here are my edited script import pyautogui, time time.sleep(1) print(pyautogui.locateOnScreen('testings.png', confidence=0.9)) thank you..
@@ronaldoapelyido5323 It looks like you have to install OpenCV (pypi.org/project/opencv-python/) for the confidence parameter to work: pip install opencv-python
Hi bro it is me again trying very hard to learn. What i did this time is. Print screen of my game window. Snipped the part of that screenshot that i want to search in game and success, my script can find it in the screenshoted photo but the problem, when i am searching in the actual game window which looks the same as the screenshot, the script cannot find it😭.
@@ronaldoapelyido5323 Glad to see you're sticking with it 👍. Are you sure that what you're searching for isn't changing subtly inside the game? Are you keeping the screenshot snippet small (you might need to go smaller)? Have you tried the grayscale and/or confidence parameters?
Is is possible to do the same thing but using 'virtual' mouse movements, i.e: I want to be able to watch a full screen youtube video in the backround while the bot i'm making run in the backround, haven't found much information on that - other than using autoit.. i'd prefer to use python.
You can run the game and script in its own container. That way simulated OS clicks become isolated to that instance. Note that GPU accelerated windows containers is very hardware intensive, even for decade old titles and especially when you're running another program adjacently.
Sorry total noob here, can someone point me to a tutorial to get the python virtual environment to be EXACTLY like what he has here? The terminal in my VS code doesn't recognize pip.
Hi Toast, welcome to Python! Here's the tutorial I referenced when setting up Python and VSCode on Windows: ruclips.net/video/-nh9rCzPJ20/видео.html I'm using Git Bash as my terminal in VSCode. Here are some more notes I have about this: To setup a virtual environment: Open terminal with ctrl+` Should be in your current project folder. > virtualenv current_project_name or > virtualenv venv This will create a subfolder to hold the virtenv and it will have the same name as the subfolder. You should then select this as the python interpreter in the lower left of vscode. You can kill the terminal and open a new one at the virtenv will be automatically loaded. Or activate the virtenv in terminal manually with: > source current_project_name\Scripts\activate To deactivate just: > deactivate
@@LearnCodeByGaming Wow you are so awesome! Thank you for your help and videos. I'm playing around with it at work right now. Luckily there's nothing for me to do at the office today woot woot! You are the man.
import pyautogui import time pyautogui.keyDown('e') time.sleep(3) pyautogui.keyUp('e') pyautogui.keyDown('e') pressed e only one time how can I hold down the key?
Is this the most underrated video on RUclips? Yes, yes it is.
Glad you like it!
Parts 3 and 4 of this series will be coming over the next week!
hey bro do you have Discord? I would really like to talk to you in private
I can't stress enough on how much I love your content. I recently got done learning python and being a gamer I wished there were channels / ways to practice code via gaming. Stumbling across your channel has made me SO much more eager to practice and that says a lot because i'm really lazy when it comes to practice. You're gonna have millions of subs in no time and i'm glad I got to find your channel before that happens!
Thanks Mark, means a lot! Have fun!
You are the best, thanks a lot. You don't have the most professional videos but you are the only one who makes these types of videos for everyone's understanding. Thank you
i just started this tutorial and it looks awesome. It's exactly what i need. Thanks from Turkey
Awesome, good luck!
man, you're the most smart man that i ever knew on youtube
this guy is literally so underrated. keep up the grind, you’ll get the views and subscribers you deserve hopefully soon.
THANK YOU ! OMG i've been struggling for the last 3 hours trying to figure out why when i was getting into Star wars the old republic, the clicks wouldnt work! simply cause I didn't run CMD as administrator ! Thank you so much +1 sub
Glad you figured it out!
That is indeed one nice introduction to Botting/programming
You are awesome, thanks for teaching us , I used a different mmorpg, and so far is doing great!
Awesome!
Which one did you play? And how did it turn out with your bot?
my favorite module pyautogooey
lol
nice video! you could set pyautogui.PAUSE variable instead of using a sleep between commands .. but this is a minor optimization :) this variable sets up a pause (in seconds) after each PyAutoGUI call.
Thanks! Good point about pyautogui.PAUSE, it's a good feature to be aware of. I did think about using that, but I felt doing the sleeps manually gives us more flexibility.
Great job on this guide! Very informative.
Thanks!
Thanks a ton mate, a really well done video.
Glad you liked it!
Thank you sir, I'm binging all of your content
Your videos are great and fun to watch. Keep it up...
I have a lot of respect for you mate
thanks for this guide, do you know any book that could help me understand more about making bots for games?
Thanks, loved the content so far!!!
I don't know of any books that cover this specifically. Your best bet is to find a book that discusses automation more generally. I recommend this one for Python: amzn.to/3fJsbyV
Thanks for watching!
@@LearnCodeByGaming Thank you, that will be a great help! you are the best!
Hi! I like how beginner-friendly these videos are. Thank you for that!
I have some questions on my mind.
A) Do you have a video/tutorial on how to make the UI of VSC look more-or-less like yours? The basic setup, if you will: installation & folders (if they matter), theme, settings & all that jazz - maybe even a brief introduction?
- Also your terminal looks neat & tidy - can this be easily replicated? It's not a big deal, but unlike yours (at 9:05 ), mine keeps printing the folder's path every time after the script stops, which looks similar to this:
C:\Users\User MacUsername\Documents\Programming Lessons\VS Code\bot_lessons>▌
B) Is there a more immediate way to stop the script? Would be useful in case when the script's wait times are too long (while in the middle of "sleep(200)", it won't initiate the failsafe) or for when the mouse cursor won't move for any reason.
- Related to that: is there a way to end any (activated) input while stopping the script (i.e. release every key & mouse button, etc, that will otherwise persist after the failsafe has done its magic)?
7:19 tip: You can write
in the string to create a new line
It's intentional. He has made it to write every dot on the same line.
Hi I really liked the way you teach it's make it's easy to understand. But was wondering is it only for me that my windows terminal or powershell never displays starting whenever I run script it's just show me blank screen and all outputs is shown when script ends .
A few other viewers had this problem, too. You need to add the flush parameter to your print() statements. Change your countdown timer code to look like this: github.com/learncodebygaming/enb_bot/blob/master/timing_bot/main.py#L32
@@LearnCodeByGaming ChatGPT was able to solve this small problem for me. Your content is valuable even years later. Hope you are doing well.
YOU ARE GENIUS!
Cool video, thanks! But how to execute the script when the game window is in focus? Is there some hotkey?
Thanks for the amazing tutorial! I have a small issue with vs code. It does not recognise the FAILSAFE command or any other pyautogui commands. I have pyautogui installed correctly as well as pip. I am very new to Python so please excuse any mistakes I may be making.
Thank you so much! I learn a lot from your videos.
Can you do pixel colour detection, randomized timer, randomized click pixel?
This was really useful! Thanks!
Thank you so much for the Tutorial - run through. Quick question as a Python beginner: Does python not read code from top to bottom, left to right? I can see that your code is working but I was always under the impression that to call functions, loops, etc into Main that need to be above def main() - does this not matter?
Code is read from top to bottom, but when we write a function we are only defining it, not executing it. The code inside of the function only gets executed once you call it. And functions need to be defined before they are called. So you can try this out: if you call main() above where we define it with def main(): it will actually cause an error that looks something like NameError: name 'main' is not defined. Hope that helps.
@@LearnCodeByGaming Thank you very much for your reply much appreciated!
can I ask a quick other question: do you know how to listen to 'outputs' from the game itself? IE instead of waiting for your game to 'load' your action (sleep between commands) - can you program it so it only reads off the queues of the game?
@@marc10uae I haven't done that before, but if the game doesn't have an official API for interacting with it then you'd have to read the game's memory.
Good stuff sir, and thank you!
This is a great tutorial
you are awesome! could you make such video on how to level up pokemon using open cv in grass with walking in the same square?
Is there anyway for the botting to be done where it doesn't interrupt you using a computer? Because having it take over control of your input means you can't do anything while there bot run. Anyway to like hook it into the game so it runs on its own without disrupting your using the computer? Thanks!
And great tutorial!
Yea i wanna know ir to if there is way
Here is a subscription for you. Take it.
How can I control mouse in "full screen" mode. I mean If I kept moving the mouse right, the screen will rotate and keep going, using the actual mouse. However, using python, when I move the mouse using any package out there, it doesn't rotate. when I enable the pan mode in game, the mouse actually works and move with python, so the game responds to it.
Can you help me with a package that can deal with the full screen-infinite rotation mode?, or just the keywords, cause I am kinda stuck in this for a while.
Thanks as always.
That sounds like a tricky problem. I don't really have any great ideas. Have you tried making your script move the mouse just a few pixels away from the edge, not quite all the way?
@@LearnCodeByGaming yeah I tried that. I found a way around it by enabling pan and move to rotate the screen, then by drag function it works. I know it's a cheat, but it worked for me 😅
hey nice guide!, i'd like to ask you for help, i'm trying to make a farm bot for a Fps online game but it looks like it just recognize raw input, so i started to search for some information, but i seems nothing works for me, i'm using win10 and python 3.8, any suggest of yours that i could try?
Yeah check out my video on PyDirectInput. It doesn't work for every game, but it works in a lot of cases where PyAutoGUI doesn't: ruclips.net/video/LFDGgFRqVIs/видео.html
This might be a less important question.
I've st upvisual studio code, and everything is working.
But my terminal prints are only shown after the fact.
If I run the code, I'll see the main.py being run, but only after the script is run through completely, all the prints will appear.
So I can't see the countdown untill it is already over.
Know anything about this?
If you're on Python version 3.3+, you can add the flush parameter to your print statements to get them to output immediately, like:
print("Something", flush=True)
On earlier version of Python you need to do this instead to flush:
import sys
sys.stdout.flush()
Those would be the first things to try, because it sounds like your terminal output is getting caught in the buffer.
Very Nice
the
tutorial is awesome but when you say GUI as in PyAutoGUI Is it guwy or is it gee yu eye like GUI
Please go deeper in installing pyautogui 🙏🙏🙏
Thanks for the Video. I have tried this on a different mmo, but it didn't work. I know what the problem is. Because what i did on coding side, i didnt get any problem trouble shooting and another program such as txt file gave pleasurable responses. So the MMO, I have tried to use this bot, has a gaming guard application to block users using mouseclicker programs. Do I have a way to bypass this? I only need key pressing and visually picking my enemies during the bot usage. Thank you
Nice video.
Hi Bro, i got stucked at the keydown stuff. here Is my prob. The Key i is actually sended to game (i play in window mode btw) but nothing happened. The way i know the KeyPress cmd was sended Is ..if i do open a chat in game..It actually writes the i Key.
It seems like only the script works in chat mode. Could be due to a special game protection or do i miss something? Btw i run sublime editor as admin, and i do start script by bash Shell ( run as admin ) and ofc i do select game window on time
If you're playing a game other than Earth & Beyond, you might check out my video on PyDirectInput. That's a library I made because certain games don't work correctly with PyAutoGUI. It doesn't work for 100% of games, but a lot of people have reported success with it. It sounds like you're doing everything else right.
Here's the link: ruclips.net/video/LFDGgFRqVIs/видео.html
@@LearnCodeByGaming yea tnx m8. Right before u replied i found out that and tested It out..It works. Tnx for library thing too. Usefull.
I tried to do a program for Minecraft but it won't recognise the keyboard inputs in Java. I tried it on an other game (kerbal space program) and then it worked. Do you have a idea what the problem could be with Minecraft?
By the way I was not trying to cheat or something I was just trying to automatically build a house.
Sometimes games that are built with DirectX will only respond to DirectX inputs. I wrote PyDirectInput to solve that (checkout my video on it), but I don't know of an equivalent project in Java. Essentially you need to call the right Windows API.
Learn Code By Gaming ok I will try that, thanks
@@LearnCodeByGaming Works great now, many thanks.
@@timoplumper2662 Awesome, thanks for letting us know.
Ondra Chvátal Use PyDirectInput then it should work just fine.
Could you use this to make 10 simultaneous bots with something like bluestacks
great video thanks!
can u make more tutorials to play browser games
cool! how do I move my mouse to a certain color in a game?
You can use pyautogui.pixelMatchesColor(x, y, (r, b, g)) to check for a RBG color at a given X/Y position. At the end of the 4th video in this series I talk a little bit about that function. But the best way to move to a certain color would be 1. Take a screenshot like: im = pyautogui.screenshot(), 2. Use nested for-loops to loop over every X and Y coordinate on the screen, 3. Check the color at each position using: im.getpixel((x, y)), 4. If your color is found then pyautogui.moveTo(x, y) and break out of the loops. Depending on your exact use case, you can make different optimizations to this like only checking every 5th pixel, or searching in a spiral from the center of the screen.
May I ask the mouse events generated by pyautogui detectable? Are those events differ from the events generated by an ordinary mouse? I'm playing a browser game that detecting auto click bots, so I want to make my script undetectable. Thanks.
Please can you make video on loards mobile game bot...
Hi, I did the countown timer just like you did, but instead of adding 1 dot every second, my code just waits for 10 seconds and then prints "Starting..........Go" all together, what am I doing wrong? Also I noticed that the .py icon for you is yellow, I dont know why but mine is different (blue), can it have anything to do with that?
Would it be possible to have multiple VMs, which all have a said game installed and also have a script to automate the game in each VM?
I've wondered the same thing myself. You could definitely do it with other techniques that don't require the screen to be rendered, but with GUI automation we need to be able to see all those pixels. If you're running multiple VMs on your desktop you'll eventually hit a performance bottleneck depending on how good your hardware is. If you do it on a server, I'm not sure how you would get the screen rendered for each VM (despite not being output to a physical screen), but I'm sure there must be a way. I'll add this topic to my list of video ideas.
@@LearnCodeByGaming Seems like we have the same thought process. For my idea it would require the screen to be rendered due to the mouse inputs at specific areas etc. But can't think of a way where I could do this with more than like 4 vms running on my machine at the same time.
@@LearnCodeByGaming Hi, finally got around to playing around with PyAutoGUI. However within some games like Rainbow Six Siege, even when my terminal and script it self is being ran as an admin it still doesn't click within the game. I've played around with the duration of clicks, put the game into windowed, border less and tried full screen aswell.
@@Bros10 Most likely those games only recognize DirectInput functions. PyAutoGUI does Win32 inputs. This issue has come up for a few people, so I plan on doing another video about it. If you want to have a go at it before then, there's an article explaining the issue here: bit.ly/2DOZKOw I've also found some good source code start with here: bit.ly/33M0DSz
@@LearnCodeByGaming Ahh that's interesting, that's what I assumed however when I'm in an actual game and not in the menu system. Even though I just want the script for the menu system is recognises the inputs when in an actual game. I'll take a read of the article and look at the source code. Cheers for the response
Can you try to make a bot for Metin2 Private Servers? I tried already but i always fail with those.
is there a setting for why i get the i is an unused variable error?
Yes, in VSCode go to the settings and search for "editor.showUnused". You can uncheck this to disable that warning.
@@LearnCodeByGaming Thank you very much mate, I just liked and subbed. Going on a binge through your material. =]
😍😍😍😍😍😍😍😍😍😍😍
Still waiting for your new videos 😉👍😍😍
Does this bot still work even if you're doing something? What I mean is that I want to run this bot while I'm doing something on the same PC. May it be that the bot is still working even if the game is minimized or if it is not minimized, I can still move or use the mouse/keyboard on some other things (like doing homework, surfing the net, coding, etc).
No you can't. These are simulated key presses and mouse events, meaning its mimicking user input. Moving your mouse and pressing keys would disrupt it. You'd probably have to run the game and script in a container or develop a memory hack if you wanted to do something like that.
What is the name of the theme you are using?
Take my sub
I'm trying to make a gui for botting a game. But I want to have a window that has events such as Right Left Spacebar etc. And if you select on type in for how long.
Hey Johnathan. For this, you will need the pyautogui.hotkey() method, for example, if you want to press the 'd' key, use pyautogui.hotkey('d') in the documentation there are keys that can be used. This is the link:- pyautogui.readthedocs.io/en/latest/keyboard.html
*Jonathan
hi nice nice video.
I would like to ask why my script cannot find image in my online game, but works when not in game window.
if i changed the pic.jpg into some portion of my screen the script can see it. but when i changed the pic.jpg into something i snipped from the game window, the script cannot see it? What is the problem? i hope you can help me. thanks
here are my simple script
import pyautogui, time
time.sleep(2)
print(pyautogui.locateOnScreen("pic.jpg"))
I am not a programmer, i am just beginning into coding it really fun.
Hi Ronaldo. I would first try running your game in windowed mode, instead of full screen mode, if you're not already.
The second thing I would do is try using pyautogui.screenshot("saved_screenshot_name.png") to save a screenshot image of exactly what PyAutoGUI is seeing. If the screenshot looks fine, then there must be a problem with the pic.jpg you're using. Either make a new cropped image to search for (maybe try saving it as a png instead of jpg?), or try using the optional confidence parameter to ignore minor differences, like this: pyautogui.locateOnScreen('pic.png', confidence=0.9). But if the game screen just appears all black in the screenshot, then your only choice is to find another Python library that hopefully works with the game you're playing. Good luck!
@@LearnCodeByGaming hi, thank you for the reply. i tried the confidence command but gaved me this error
TypeError: _locateAll_python() got an unexpected keyword argument 'confidence'
here are my edited script
import pyautogui, time
time.sleep(1)
print(pyautogui.locateOnScreen('testings.png', confidence=0.9))
thank you..
@@ronaldoapelyido5323 It looks like you have to install OpenCV (pypi.org/project/opencv-python/) for the confidence parameter to work: pip install opencv-python
Hi bro it is me again trying very hard to learn. What i did this time is. Print screen of my game window. Snipped the part of that screenshot that i want to search in game and success, my script can find it in the screenshoted photo but the problem, when i am searching in the actual game window which looks the same as the screenshot, the script cannot find it😭.
@@ronaldoapelyido5323 Glad to see you're sticking with it 👍. Are you sure that what you're searching for isn't changing subtly inside the game? Are you keeping the screenshot snippet small (you might need to go smaller)? Have you tried the grayscale and/or confidence parameters?
Hello, I created a simple clicker using PyAutoGui for a MMORPG, the code is working fine, but it's not clicking inside the game. any Ideas? =/
Is is possible to do the same thing but using 'virtual' mouse movements, i.e: I want to be able to watch a full screen youtube video in the backround while the bot i'm making run in the backround, haven't found much information on that - other than using autoit.. i'd prefer to use python.
You can run the game and script in its own container. That way simulated OS clicks become isolated to that instance. Note that GPU accelerated windows containers is very hardware intensive, even for decade old titles and especially when you're running another program adjacently.
Hello, so here is the thing, the pyautogui.press does not work for me, there is not any error but it is nor recognised by the game... Any sollutions?
please help me I don't know how to run this on administrator mode with python IDLE
In the Windows start menu, right click on IDLE, go to More, go to Run as administrator, should do the trick.
It doesn`t print "Starting" or anything else from def main on my computer. Tried with Pychram and VScode. In pycharm code just ends with exit code 0.
It keeps on giving me - warning,unused-variable:Unused variable 'i'. How do I get around this?
It's a warning that you can safely ignore, but you can also get rid of it on most IDE's by using '_' here instead of a variable name like 'i'.
Sorry total noob here, can someone point me to a tutorial to get the python virtual environment to be EXACTLY like what he has here? The terminal in my VS code doesn't recognize pip.
Hi Toast, welcome to Python! Here's the tutorial I referenced when setting up Python and VSCode on Windows: ruclips.net/video/-nh9rCzPJ20/видео.html
I'm using Git Bash as my terminal in VSCode. Here are some more notes I have about this:
To setup a virtual environment:
Open terminal with ctrl+`
Should be in your current project folder.
> virtualenv current_project_name
or
> virtualenv venv
This will create a subfolder to hold the virtenv and it will have the same name as the subfolder.
You should then select this as the python interpreter in the lower left of vscode.
You can kill the terminal and open a new one at the virtenv will be automatically loaded.
Or activate the virtenv in terminal manually with:
> source current_project_name\Scripts\activate
To deactivate just:
> deactivate
@@LearnCodeByGaming Wow you are so awesome! Thank you for your help and videos. I'm playing around with it at work right now. Luckily there's nothing for me to do at the office today woot woot! You are the man.
HI GAME IS FREE TO TEST?
import pyautogui
import time
pyautogui.keyDown('e')
time.sleep(3)
pyautogui.keyUp('e')
pyautogui.keyDown('e') pressed e only one time how can I hold down the key?
holdKey ('e', time)
wait but when I type pip install pyautogui it just says "pip is not recognised as a command"
How do you move your mouse in a game where you can't see your mouse, and instead you just have a crosshair
its the same thing but it might be harder because in 3d games you can move 360 aka past screen boundaries
when i tried to run the code it says that ___name___ is not defined
how can i add images? i wan to do a gem farming on ROK. can i ve your discord?
9:25 I am doing this in a similar game called 'Pokemmo' but it doesn't work. Please help me. :(
Are you the one who have a channel called null byte🤩🙏😃
Sad, my click dont work.
33:14