I like watching your videos cuz it feels like what it really feels like to code, instead of some pre-made stuff
@sentdex7 жыл бұрын
Thanks!
@allmightqs16796 жыл бұрын
@@sentdex, when I ran your code, I opened a notepad to see if it works or not and it did, so the code's working alright, but when I open gta5, it doesn't work. Do I need to make any changes in the settings?
@el-jay_6 ай бұрын
7 years later as a Python newbie, I share this sentiment.
@RandomShowerThoughts6 жыл бұрын
literally some of the best videos love the thought processes everything about these videos this is how coding really is rather than memorizing things. This is real problem solving
@youneskhouli7 жыл бұрын
Hey man! I just wanna say that in the next two weeks, I will finish the third year in College studying "Software engineering", and I never had fun programming, the way I do right now after watching your video!!! Good job and thank you :)
@24HourMusic7 жыл бұрын
VK is a Virtual Key and most games are set to ignore them to stop bots (I believe)
@sentdex7 жыл бұрын
Thanks for the info!
@jakesmith89647 жыл бұрын
hey im having trouble at this part, ive imported directkeys into my main file yet when I run it the vehicle still doesnt move what so ever
@ashleygodden12697 жыл бұрын
have you imported the directkeys file into your main file?
@pottingmix37337 жыл бұрын
You can use windows api to send keys to a window handle either with postmessage or sendmessage. def Type(handle, string): for char in range(len(string)): win32api.SendMessage(handle, win32con.WM_CHAR, ord(string[char]), 0) time.sleep(.1) I have used this to make chat bots for certain games. For holding down a key you could use the WM_KEYDOWN flag from windows api.
@savijiN5 жыл бұрын
@@sentdex I know I am replying to a 2 year old comment but I found if I run my python scripts through CMD as Administrator I often have my inputs go through fine with PyAutoGUI
@JulioPerez-ng9pt7 жыл бұрын
1:50 Want pyautogui to do something but it doesn't. I had that problem. Yesterday I was trying to make pyautogui move mouse and click onto a button, it did moved but didn't clicked. Weird thing, Before I run the code, I click on app to be clicked (to focus), solution was to be the IDLE the one to be focused. I am a newbie and don't understand why is that, but that was the solution.
@relaxwithai6 жыл бұрын
being a coder also i feel really bad copy pasting other people's code, expecially if I don't fully understand what's going on.. any advice on how i can get over this
@RandomShowerThoughts6 жыл бұрын
try to figure out what each piece does
@georgebockari2896 жыл бұрын
mildly sarcastic response...utterly genuine however. Just get over it. The task of being a developer is to rich a field to have working knowledge of every problem you will ever run across. Stackoverflow will and should already be a good friend of yours. Once you have a good grasp of the fundamentals of programming you'll be able to grab someone else's code to a problem you can't solve, skim it and get a feel if it seems to solve your issue. Plus the best part of coding is you just run it, if it does what you wanted, then its just a matter of figuring out how.
@vincelouse44094 жыл бұрын
1. Instead of copying and pasting, find code that you'd copy and manually write it out. 2. after the first step look at parts of the code and search online to see what the code you just copied is doing and why it's implemented the way it is.
@westernvibes12674 жыл бұрын
Copy pasting code is bad is a kind of myth. It's usually a coder's ego, don't let that ego consume you, knowing how to google is one of the important thing while coding or working on projects, a human simply can't have anwers to any question neither we can remember syntax of all the libraries and modules it's ok to google, take code, remake it, extend it. If you feel such things are supposed to make you feel bad watch big peoples coding stuffs from scratch, like geohot
@shmuelk30187 ай бұрын
Thanks, it works, I am using this script to stay AFK without getting kicked from the session
@kevinvidzzz53937 жыл бұрын
Would be interesting to see how I could use some of this to program a "PokerBot". Not for evil purposes of course . . . Just to learn how to grab the screen . . . tweak the screen . . . apply some AI . . . Then do some mouse clicks based on the AI . . . Obviously I'm not the first person to have this in the back of their minds. Or a ChessBot . . . or any number of cool "Bots".
@sentdex7 жыл бұрын
My plan is to certainly try to continue the "Python Plays" aspect of this series, and get Python to play a bunch of things. Not sure on poker, but possibly :P
@shahmi987 жыл бұрын
Kevin Vidzzz im hoping for football game such as fifa or pes
@kevinvidzzz53937 жыл бұрын
Cool . . . not quite there yet . . . I just did a craps dice simulation in my latest video . . . I'm just about to upload it . . . I will be getting back to the poker bot stuff soon . . . ;)
@paranoidpenguin90777 жыл бұрын
Give World of Warcraft a shot, it would be interesting to see if you could use something like OpenCV to navigate towards resource nodes or to farm an area for for mobs. Although, considering that Blizzard tries to punish cheaters, I'd be interested to know if they have mechanisms in place to prevent this sort of behaviour.
@England917 жыл бұрын
Paranoid Penguin if you use it as a macro on your keyboard and or mouse then it might be hard for them to detect but that's just me thinking on the spot
@crustog116 жыл бұрын
what is the alternate library for MacOS for key interruption , it seems like "SendInput = ctypes.windll.user32.SendInput" needs to be replaced by alternative library for MacOS
@quadro2017 жыл бұрын
9:25 ... lm gonna be a good boy and not block the way of other cars :D
@JadenAccord7 жыл бұрын
Could you put the links for the stackoverflow and other sites in the description? It would be a lot easier to follow you like that.
@sentdex7 жыл бұрын
all the code is sourced on the project github and pythonprogramming.net. This specfic tutorial on ppnet for example: pythonprogramming.net/direct-input-game-python-plays-gta-v/ The links to the code sourced elsewhere are commented in the code.
@kshitijohri52853 жыл бұрын
I'm having an error saying :-cannot import name 'Presskey' from 'directkeys' both files are in the same directory
@KellenChase7 жыл бұрын
nice. I used PyAutoGui to program myself out of my last job for a while. had to learn the scan codes to get around some things that wouldn't take the standard pyautogui inputs.
@vijayabhaskar-j7 жыл бұрын
Awesome Idea!,The best ML idea with fun,I have seen in youtube!
@sentdex7 жыл бұрын
Thank you, this is easily the most fun I've had with a series so far as well.
@danielguarchaj48366 жыл бұрын
I just loved this, great work!
@gstexpla637 жыл бұрын
Hi! So the funda is that the window you want to send the keys to ('w' in this case) should be in 'focus' at the time the keys are being 'sent' to it. Windows will just send the keys to whatever window happens to be in focus at the time of code execution. Since the window in your code that is in focus is the IDLE window, the keys are not being sent to the GTA window. A shabby workaround I found in my intern was this: 1. Using pyAutoGUI use the mouse to 'click' the window you want to send the keys to 2. now send the actual keys I suppose you can figure out the mouse click part. This worked for me, I suppose the 'Alt+Tab' combo could also be sent through the code for such a task.
@shubhamdebnath7147 жыл бұрын
i've just confirmed, using just pyautogui.DownKey, works only for older games or the ones not using newer DX like COD 4 and crossout. the games that didn't work were witcher 3, COD WW2, in both cases i used the same code and alt-tab
@beckettman427 жыл бұрын
Fun choice of topic. I will have to come back to this when GTA V goes on sale.
@sentdex7 жыл бұрын
You can also use another GTA (maybe, IIRC GTA 3 doesn't work well on windows 7+), but you could also just use San Andreas. Super cheap on Steam. Just for the record, I am not sponsored in any way, just think it's a great came for playing with AI in. If you have another game where you drive a car and can clearly see lanes, that can also work, we're going to be doing self-driving cars for a bit, til I can speed through the city :D. None of the methods used here will be GTA-specific, besides maybe some mods I use to make no traffic, lots of traffic, clear skies...etc :P
@beckettman427 жыл бұрын
Excellent. This will be fun! At this rate Ornstein and Smough are doomed to fall to python.
@veerendra.k7 жыл бұрын
Thanks for the great tutorials. I tried same code in my laptop(Acer, Nvidia) GTA 5, it is not working for me. But it is working in "Batman: Arkham Origins". Still I don't understand what I'm missing. Any help?
@Paavo19917 жыл бұрын
I didn't know that you can write [::-1] after for loop, nice but how it works?
@sentdex7 жыл бұрын
To be honest, I have no idea why ::-1 works like that, I just know it does. Mainly the :: part means go backwards. -1 means go backwards from the -1st index (the last one). Why :: means reversed though .. I just don't know.
@Paavo19917 жыл бұрын
Yup, I know that [::-1] works "reversed" but I've never seen it next to the list() function. Thanks for tutorials :)
@chronicfantastic7 жыл бұрын
I think you've got this wrong? list slicing is [start: stop: increment], where if no value is given for start:stop it defaults to start:end so :: means go from the start to the end (unspecified), and the -1 means in reverse increments
@Zenzodiene7 жыл бұрын
And perhaps you can use it next to the list function since a "slice" returns a list. So it basically says for i in list.
@benburrill7 жыл бұрын
The `list()` just converts the range object to a list because +sentdex is under the (incorrect) impression that Python 3 range objects cannot be sliced. Once it is a list, the [::-1] works just like the [::-1] on any other list: it creates a new, reversed list object. However, because Python 3's range objects are more powerful than many give them credit for, you can just slice the range, returning a new reversed range object: >>> range(4)[::-1] range(3, -1, -1) This would be better because it not only takes up less typing, but also is more efficient in time and memory use because Python 3's range objects do not store each value like a list does, they just calculate them on the fly when you ask for them. In this case it doesn't really matter because there are just 4 values in the range, but this would matter for bigger ranges.
@kanishqvijay28524 жыл бұрын
You can use pydirectinput module, which has same functions like pyautogui. It can work where VK input won't work
@sourabhjangid80134 жыл бұрын
pydirectinput works only for windows is there any similar for ubuntu
@kanishqvijay28524 жыл бұрын
@@sourabhjangid8013 Try using pynput module
@kanishqvijay28524 жыл бұрын
@@sourabhjangid8013 "Maybe" run python in wine in Ubuntu. And use the pydirectinput(im not sure about this method)
@abdelkaderguellati51642 жыл бұрын
I had same problem of sending key presses or controlling mouse for a while. it turned out you need to run the script as administrator and worked .thnx for the videos though
@bharathbabuyp7 жыл бұрын
It's a pleasure to watch your videos. Awesome Harrison!!! Not sure if it has been implemented later on, but you could try to run the keyboard events in a parallel thread, right?. Correct me if its not possible. I haven't tried it though. But still, its an awesome topic man :)
@tonysmn977 жыл бұрын
For those, who are on Linux, you can use this library: github.com/SavinaRoja/PyUserInput (Though it says it works on Windows, Mac, Linux) I've tested it, works prefect and supports all kinds of keys and even a mouse events
@YumekuiNeru7 жыл бұрын
xlib is just endless pain and suffering to work with (but it tends to work)
@YoloMonstaaa6 жыл бұрын
How are y'all playing GTA on Linux?
@mogarbobac14726 жыл бұрын
from KeyPresses import ReleaseKey, PressKey, W, A, S, D ImportError: cannot import name 'ReleaseKey' !!Please Help!! im using Jupiter notebook. all i did was name it KeyPresses instead. what could be causing this issue
@machwave5406 жыл бұрын
Hey @Sentdex can you do videos on Carla? its an opensource autonomous driving simulator.
@BoomTownNL7 жыл бұрын
I can't seem to get mouse clicks working. When I try to assign mouse1 to 0x100 (scancode 256) it does nothing, and 0x101 for mouse2 seems to press esc for some reason. Is there something i'm missing?
@sentdex7 жыл бұрын
I wish you or I knew! I want to get a way to drive smoother bad!
@IyaJenkei6 жыл бұрын
Man I've searched every thread relating to this stuff it feels like and I can't get mouse clicks to work right. when I try the hex codes that are supposed to work it ends up pressing keyboard keys? No chance you ever came up with anything is there? I'm trying to make a civilization 6 bot and the whole game is mouse clicking. I guess if I have to I can look up all the keyboard shortcuts and hopefully there's one for every action
@glorytoarstotzka3306 жыл бұрын
i found a way : you need to download an autoclicker like autoclicker professional , and its key to use it its F1 , so put a huge delay on the clicks then instead in the program of making bot click , make it press F1 , then F2 after 0.5 secs , this should fix problem , if F1 is start key for autoclicker and F2 is the other , and i believe you can use pyautogui for F1 and F2
@m3n4lyf6 жыл бұрын
I like how he is talking about replacing time.sleep() in a loop that is using time.time() for instrumentation.
@someaccount34386 жыл бұрын
Finally... Last year, I was trying to make a bot for a game, and I gave up, having never figured out how to make keystrokes work. I had used many methods, but not this one. Surprisingly, I had also stumbled across the piece of code that you copied from Stackoverflow, but it seemed too confusing, so I just left it. I was so hyped when I finally managed to get the game to catch the key this year, when I was trying to make another bot. Thank you.
@sentdex6 жыл бұрын
Awesome! What game are you doing?
@someaccount34386 жыл бұрын
sentdex I did Warframe. Nothing complicated, I just needed it to post a message every 120 seconds. Turns out, win32com.client's SendKeys can be used for writing in chat, but not for keys in game. All I needed was to press enter so the chat would open. I ended up using this solution here for that, and kept using SendKeys for writing. Turned out great!
@otacon10244 жыл бұрын
@@someaccount3438 Funny you should mention Warframe, I also made one for scrolling through my inventory and running OCR to get a list of all the items I had and their counts. Combined with pulling prices from warframe.market it made it way easier to figure out exactly what I could sell and for how much platinum.
@Katatonya2 жыл бұрын
@@otacon1024 yo how did you get OCR to be consistent with the warframe font? I've always had trouble with that, OCR libraries I tried like tesseract don't work on all fonts no matter how many parameters I tweaked.
@iRetroGamingz4 жыл бұрын
ur a legend even 3 years down the like tysm
@henoktilaye31524 жыл бұрын
Big time fan. Late to the party. pyautogui is working for me on ubuntu.
@tazbird7 жыл бұрын
I ran into a similar issue with pyautogui when I was automating an app that was running through Citrix. it wouldn't take the VKs either, I ended up editing pyautogui adding a dictionary to lookup the scan code and then just tweaking the keyb_event call to take 'the looked up' scan code in the 2nd parameter (it's hard-coded to 0 in Sweigart's code)
@nihaalmodi68847 жыл бұрын
Hello Sentdex, If you start four new thread two for left right and two for up down along with queue, you will be able to use pyautogui for controlling the character/car
@deknas14075 жыл бұрын
11:47 how do u comment out code like that?
@gurkiratsingh3485 жыл бұрын
Alt+3
@ifredpingplay4685 жыл бұрын
hi it was working in other games except for GTA V I tried in GTA V to while ago and it was working .Key is being pressed and Release everything is working except in GTA V, Direct Input required particular DirectX version?
@mihaiandrei-daniel44855 жыл бұрын
: expected LP_INPUT instance instead of LP_Input Any ideas guys?
@siddheshgawali77646 жыл бұрын
how can i code the same for pubg emulator... cus it cant take input from direct keys
@jaeminpark31137 жыл бұрын
Hi, I would appreciate it if anyone could explain what if __name__ == '__main__' does... around 5:35 ..
@wookiecharge11897 жыл бұрын
main means that it is teh whoel code on tehat page the under scores mean its "special"
@khoapham30834 жыл бұрын
Hello, i still can not let python press the key in GTA V even though used keyPress just like you, can you help me ? I am using python 3.7.7 (64bit) and DirectX 10.1 and 11 (both doesn't work)
@pizzafoot19666 жыл бұрын
Hey Sentdex (or anybody else, seriously), you wouldn't happen to know why my _keys_ are working in pyautogui, but my _mouse_ isn't? I am working on mac High Sierra, though, so it's quite a bit different. In Minecraft, the clicks and mouse movement actually work perfectly fine on menus, but in actual gameplay the mouse movements just jitters once you actually move the mouse. Is it just the way that the mouse is used in video games?
@MatterStorm16 жыл бұрын
If you're telling it to move the mouse to a specific position on the screen or a certain amount in a certain direction, that's just a single sudden movement. Real human mouse movement is continuous. In menus and on your desktop it doesn't really matter since everything has an absolute position on the screen and you're just moving your cursor around, but in a first person game where you're controlling a camera, it will look jittery if you tell the mouse to move suddenly. Perhaps you could make it looks slightly smoother by spreading the total movement you want out over several steps of max distance ~20 pixels or something with a for loop and some simple vector math. If you need to you could do time.sleep(0.005) and try out values for that to give it a bit more slowness.
@boredgaming916 жыл бұрын
same code not working on my GTA V i have a wireless keyboard Observations: when i give input W in PressKey it kindof presses LCtrl on text document it prints nothing, the cursor just moves left
@jlewwis19957 жыл бұрын
Why would you *NOT* send scancodes to the game input? I thought all virtual keypress programs used scancodes... apparently I was wrong? What is even the benefit of non scancode VKs?
@sentdex7 жыл бұрын
I wondered the same thing when I learned that modules like pyautogui and sendkeys were just using some 2ndary form of input. I guess it's so a machine could differentiate between the presses if necessary, not sure why that would be necessary...but possible!
@esequielalbornoz52716 жыл бұрын
Hi... i know im a year late but. How can i send mouse movements with direct input? im trying but it alway move to the same position (center of th screen)
@mauipomare32325 ай бұрын
Forget `time.time()`. It's for checking the current time, not for measuring how long something takes. Use `time.perf_counter()` instead. It's designed for precision and high-resolution timing, perfect for when you need to measure the exact duration between events.
@allmightqs16796 жыл бұрын
Sentdex, when I ran your code, I opened a notepad to see if it works or not and it did, so the code's working alright, but when I open gta5, it doesn't work. Am I making a mistake, or do I need to make any changes in the settings?
@SandeepKumarz16719957 жыл бұрын
help..!! I have done exactly the same but the key wont work. when I tried to see what it is doing then I found that it printed the key once after PressKey(W) and this single press dont work in Game. Thanks in advance.
@kingcheng20006 жыл бұрын
Is that working now ?
@allmightqs16796 жыл бұрын
It's not working for me either
@agianzariskyarbhama80973 жыл бұрын
@@allmightqs1679 i have some problem i can't use the direct input, this code don't work in my project @sentdex
@GregorEpet7 жыл бұрын
Just noticed in this episode: How do you run PIL in Python 3.x? I can only find PIL for 2.x online
@srikanthvelpuri29737 жыл бұрын
Hackfleisch Hackender Zerhacker Install pillow module and it contains PIL in python 3.0 ..Hope this helps you.
@jesusalejandrocorneliotruj50134 жыл бұрын
But how do I move the camera with mouse code in games with raw_input
@NoobishAlpha4 жыл бұрын
Does pynput work for inputing data in a game ?
@I3LaCkPeArL5 жыл бұрын
Didn't work for my game. They keystrokes still dont appear ingame, only in other applications. Are there other ways to simulate direct keystrokes?
@user-df4zw7yb4v5 жыл бұрын
run the code as a .pyw file Run it by clicking on the file itself, not within the code editor
@venishpatidar39915 жыл бұрын
Dexter Morgan or run code editor as administrator.
@JurassicJordan6 жыл бұрын
how do i accomplish this in mac os, without a user32 api?
@foxrain47913 жыл бұрын
Thank you! I love this video♥
@GauravSuryawanshi6 жыл бұрын
Hey what are those 0x11 and this nomenclature?
@kolterdyx5 жыл бұрын
where can i find the keys thing to copy and paste?
@AdamSaudagar7 жыл бұрын
please put links of stuff u copy code from (even for testing) in the description
@tgautam034 жыл бұрын
Is there any way to do this for a controller?
@jakehappenpal81654 жыл бұрын
Doesn't work for me. Game doesn't accept that directkeys input
@allmightqs16796 жыл бұрын
The code doesn't throw any errors, but my bike doesn't move either. Can anyone tell me what's going wrong?
@codewithlenny7 жыл бұрын
Hey Sentdex i am doing this on GTA Vice City and the directKeys is not working.My PC can't play GTA V....It's too big .Any suggestions to other games like GTA that will work out for me??
@sentdex7 жыл бұрын
Try pypautogui's "key" functions like keyUp and keyDown ...vice city might not be using direct inputs, that's an older game, so you might actually be fine with the virtual keys stuff. pyautogui.readthedocs.io/en/latest/
@allmightqs16796 жыл бұрын
@@sentdex When I ran your code, I opened a notepad to see if it works or not and it did, so the code's working alright, but when I open gta5, it doesn't work. Do I need to make any changes in the game settings or am I doing something wrong?
@bhagyeshkocharekar88506 жыл бұрын
not working for CS:GO and Rainbow six siege. Any help ?
@mehDfd6 жыл бұрын
run the script then select csgo windows to work
@fuba447 жыл бұрын
Great idea for a video series!
@sentdex7 жыл бұрын
Thanks, it's been a lot of fun working on it!
@thepiratedeveloper88076 жыл бұрын
How would you send mouse clicks?
@slashhack10267 жыл бұрын
I am so happy to meet you.
@pradyumanpareek29725 жыл бұрын
I tried running the code by same procedure and it is not showing any error and it's not running in GTA V. Please Help....
@venishpatidar39915 жыл бұрын
PRADYUMAN PAREEK Run ur IDE as administrator and try to run code again.
@Osama_Amer2 жыл бұрын
damn i went through with the same thought process for PyAutoGUI, gave me a headache.
@ifredpingplay4685 жыл бұрын
GG! but how can I pass 2 keys at a single time like lSHIFT+W for sprint?
@Myrkvi_5 жыл бұрын
You do PressKey for both. e.g. first PressKey(L_SHIFT) and then PressKey(W), and then release both later.
@khoapham30834 жыл бұрын
Okay, i know it a bit late but if you can not run your gta 5 like him, you MUST run GTA V and Python IDLE as administrator
@andrejkaradzic56847 жыл бұрын
Why do you use a text editor instead of some IDE?
@sentdex7 жыл бұрын
IDLE is an IDE :P
@SpirosKaftanis7 жыл бұрын
Do you know how to send half key? or 30% key pressed?
@sentdex7 жыл бұрын
You'd need to emulate a controller, which I am doing with vjoy + x360ce for GTA V now.
@Lee-ie1xg7 жыл бұрын
Help! I cannot seem to get the 'W' key to move my character in GTA. What i observed is when i run the code without clicking on GTA window, it will type 'w' in the shell. However, it does not type 'w' when i tab over to GTA, yet there is no response in the game. Is GTA blocking the signals sent? How can I get it to work. Please let me know. Thank you.
@Lee-ie1xg7 жыл бұрын
Also can anyone let me know what GTA Mod he is using to change the weather, time, location etc. Thank you!
@aniketbhanavase77907 жыл бұрын
I had the same issue...run GTA 5 as administrator and python script too:)
@srikanthvelpuri29737 жыл бұрын
I too had the same issue? Found the fix..Please let me know
@srikanthvelpuri93007 жыл бұрын
Thanks Aniket..It solved my issue
@talrofe55586 жыл бұрын
Thanks. This comment should be pinned
@npcode6 жыл бұрын
Why not Keyboard lib?
@niklaskras54982 жыл бұрын
Awesome to see that even though you are a way better programer than i am you still dont write perfect code and use the "start the programm, get a error, fix the error" type of programming cycle.
@Tibetan-experience6 жыл бұрын
it dose not work for mac OS
@johncusack36467 жыл бұрын
How can you track mouse movement with python?
@sentdex7 жыл бұрын
That's a great question for the google. pyautogui can do it, but I don't know if it works in this environment.
@johncusack36467 жыл бұрын
What about an Xbox controller? I want to make a mayhem bot, he just aims and shoots an RPG at cars and cops
@ravernot88897 жыл бұрын
seriously though- do you teach an actual class?
@sentdex7 жыл бұрын
Nope I don't. I've been able to reach over a million people through pythonprogramming.net and youtube. Something just not possible if I was physically teaching. I also don't like the idea of teaching the same thing over and over. ...finally, I don't have credentials. Universities want you to have a degree, usually phd/masters in what you teach. I have no such thing for anything even remotely close to CS.
@easter.bunny.67 жыл бұрын
8:20 pressing and releasing have different hardware event code so lmao xD
@ishanksharma90517 жыл бұрын
amazing dude please keep this up
@derekverveer60587 жыл бұрын
Edward snowden, Is that you?
@JoaoMartins-qc4oh5 жыл бұрын
I cant use it in my game. Can someone help me?
@ronyyosef5134 жыл бұрын
did u get a answer?
@JoaoMartins-qc4oh4 жыл бұрын
@@ronyyosef513 Nop
@Zippka_4 жыл бұрын
some shit a while ago that I tried in LoL, ended using AutoHotkey. Basically put the exe in python folder and install AHK library via pip and it worked really nice
@varshneydevansh5 жыл бұрын
*AI God Sentdex*
@phluent21815 жыл бұрын
did u make another video
@sentdex5 жыл бұрын
I made *many* more. Here's the full playlist: pythonprogramming.net/game-frames-open-cv-python-plays-gta-v/
@hadjseddikyousfi005 жыл бұрын
Guys using linux distributions how did you use ctypes lib ? @sentdex fans PLZ HELP
@祐祐風風7 жыл бұрын
part-2-and-3-keyboard-input-and-basic-OpenCV.py It need to add extra line: if __name__=="__main__": main() it can be work
@krazzysingh39806 жыл бұрын
the code was for teaching tho..so no license
@yadavdenrose5 жыл бұрын
NameError: name 'get_ipython' is not defined How to solve this error? Do i need jupyter notebook for these codes?
@marcosmarcolas82015 жыл бұрын
cv2.imshow('window, new_screen) ^ SyntaxError: EOL while scanning string literal
@ubwr53225 жыл бұрын
you need to close the string: cv2.imshow('window', new_screen) rather than: cv2.imshow('window, new_screen)
@rednax37887 жыл бұрын
Why don't you have one thread doing the processing, and another thread doing the inputs and shit
@sentdex7 жыл бұрын
Sure, that's possible, if you want to do a pull request and show how you think it should be done: github.com/sentdex/pygta5/
@walpurgoffnacht6 жыл бұрын
Hello sentdex! This might be a year later, but i think i found out why you think you didnt need ReleaseKey i am making a similar bot for a game with arrowkeys, and it turns out arrowkeys only register as one press, so you didnt need to use ReleaseKey
@shinsawai17 жыл бұрын
Does anyone know how to get this to work on a Mac?
@chilliam657 жыл бұрын
I use pyautogui and it works fine
@JurassicJordan6 жыл бұрын
@@chilliam65 not for me, according to the terminal return, i need windll, a windows system file
@TechHackerTamilOfficial4 жыл бұрын
this guys has 4 monitors in front
@Salata_kepu8 ай бұрын
Nice vid, helped!!!
@kanedsodas5 жыл бұрын
did anyone notice that he has a typo in the folder name "ai-gamging"?
@jackpaul93936 жыл бұрын
So much off copy paste work doesn't seems to be tutorial, live code is better than debugging copy paste code
@sentdex6 жыл бұрын
So long as you never import a library in Python, you can make that claim. Otherwise...wot?
@parthikbhandari69035 жыл бұрын
GTA V ain't taking input using this code too. Somebody save me. I'm done with all other frameworks, finding lanes and all (though I used a different method to find lanes, I didn't want to just copy everything from you), now I'm only stuck at giving inputs. I even copied and pasted your code from Github as it is, still, no good! Here's my stack link to the question: stackoverflow.com/questions/56846010/direct-input-command-not-working-while-making-gamebot
@u00xclub5 жыл бұрын
For most of the game nowadays you have to run it as an administrator, since the game doesn't allow things from outside to interfere with the game, that's also why most of the "cheats" are internal(in the game)
@tellvivk7 жыл бұрын
that brain freeze tho 😂
@arvindroshaan7 жыл бұрын
Pyautogui will work for controlling the movements. The code is given below, print('down') press_w_start_time = time.time() while time.time()-press_w_start_time
@sentdex7 жыл бұрын
No, that doesn't work. You need direct input.
@arvindroshaan7 жыл бұрын
No Sir, it works. The logic is to press 'w' continuously for 3 seconds (in this example) using while loop and after that release 'w' using keyup. I have tried it in GTA SA, and it worked as expected. Kindly cross-check. Thank you.
@sentdex7 жыл бұрын
Maybe it works in GTA SA, but doesn't work in GTA V. Again, you need direct input for current-aged games. I did try when I first began this project.
@shubhamdebnath7147 жыл бұрын
i've just confirmed, using just pyautogui.DownKey, typewrite(), works only for older games or the ones not using newer DX like COD 4 and crossout. the games that didn't work were witcher 3, COD WW2, in both cases i used the same code and alt-tab and yeah this comment i posted again
@akilkhan29555 жыл бұрын
Does this require running the script as an admin? Coz at the moment, i'm able to alt+tab into the game but the game's not recognizing the keyboard events or mouse clicks. I'm trying on Gta SA btw.
@hydroblitz33076 жыл бұрын
stackoverflow.com/questions/14489013/simulate-python-keypresses-for-controlling-a-game is the site
@hope-kz6tb2 жыл бұрын
Please teach us how to create a bot for fucking clash of kings game
@hope-kz6tb2 жыл бұрын
I know you will not read my comment but if accidentally you read it so please create video on it and teach me how can provide bots for games and provide services to earn some money
@bennis92837 жыл бұрын
Great!
@JS-ys2uk7 жыл бұрын
"You can probably guess what's about to happen" No I can't because I'm still a noob, but this is fun to watch! :)