PyAutoGUI not working? Use DirectInput

  Рет қаралды 69,894

Learn Code By Gaming

Learn Code By Gaming

Күн бұрын

Пікірлер: 447
@itsBenjamon
@itsBenjamon 4 жыл бұрын
Dude literally nowhere else explained why pyautogui doesn't work sometimes. You are my hero. Literally I'm so glad I finally found this.
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Glad to help!
@luigiesposito2481
@luigiesposito2481 2 жыл бұрын
@@LearnCodeByGaming hello friend please Luigi I'm Italian I don't understand English would you give me a hand? to install the program?
@maybelindow3906
@maybelindow3906 2 жыл бұрын
@@luigiesposito2481 hi did you use Google translate to type that ( out of curiosity 👀 )
@ninjedi6710
@ninjedi6710 Жыл бұрын
@@LearnCodeByGaming what would be a recommended approach to record mouse movements in FPS games? im having a problem where the script thinks that the mouse is always at the center of the screen.
@yoursps
@yoursps Жыл бұрын
@@ninjedi6710 Faced with a similar problem. The cursor coordinates are determined centered (x=960, y=540), but the application reads them as (0, 0). This would not be a problem, but move(0, 0) transmits some wrong signal and activates the camera movement. Due to an error with zero translation in coordinates, the camera can only move diagonally. If you have a similar problem and you have found a solution, I would be grateful if you let me know.
@emiryassin877
@emiryassin877 4 жыл бұрын
I got bored of playing games “the normal way” and I wanted to automate the boring stuff . Suddenly stumbled upon one of your videos one day , now i’m learning python (day 6)
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Awesome, have fun!
@deadpopcorn8523
@deadpopcorn8523 2 жыл бұрын
​@@LearnCodeByGaming pydirectinput kind of skips the duration function, please can you fix it????? my god it took forever to find what was wrong
@benjaminwilliams5116
@benjaminwilliams5116 4 жыл бұрын
You are the greatest human ever.
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
lol, thanks!
@TheAmazingXizde
@TheAmazingXizde 4 жыл бұрын
DANG DUDE IT WORKS, TY SO MUCH!
@mrweb9087
@mrweb9087 3 жыл бұрын
In Windows 8.1 pyautogui.keyDown('alt') pyautogui.keypress('tab') Time.sleep(1) pyautogui.keyUp('alt') This is not working for switching the windows Please help me to solve this problem I also try hotkey Please tell me the solution if anyone knows 🙏🙏
@lorenzo1479
@lorenzo1479 3 жыл бұрын
@@mrweb9087 try pyautogui.hotkey(‘alt’, ‘tab’) function, it works, I use it since hotkey isn’t implemented in pydirectinput
@mrweb9087
@mrweb9087 3 жыл бұрын
@@lorenzo1479 thanks✨
@jeremytwomey7167
@jeremytwomey7167 4 жыл бұрын
Dude you are awesome! I spent a couple weeks wracking my brain on how to improve my simple bots and this was exactly what I needed! Keep up the good work.
@Med_Sel
@Med_Sel 4 жыл бұрын
ty so much man i had to do press and hold for an amount of time before and now the presses=number of presses works which saved me a lot of lines
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Awesome, glad to help!
@Spee2k12
@Spee2k12 4 жыл бұрын
YES! Thank you! This has made my Factorio repetitive task application/script work perfectly, you sir are a star, I shall be following you from now on!
@cavalfou
@cavalfou Жыл бұрын
automating in an automation game, genius XD ... though it does not work in some steam game still.
@hourz
@hourz 4 жыл бұрын
For anyone that still has problems try the following: 1)- Open CMD as Administrator 2) - Open game up as administrator 3) - Run the py file 4) - focus on the game window, and watch the magic happen. Hope this helped :) (please don't make spamming/scamming chat bots thats not cool man)
@joseaugustodossantossilva1149
@joseaugustodossantossilva1149 4 жыл бұрын
still not working
@krikukiks
@krikukiks 4 жыл бұрын
Worked for me. It also worked when I ran my IDE (PyCharm) as administrator.
@Sergey-xf9gw
@Sergey-xf9gw 4 жыл бұрын
Thank you so much I already wanted to give up on finding libraries. You're the best
@bakugameplays
@bakugameplays 3 жыл бұрын
Ty king
@aamirnafis4139
@aamirnafis4139 3 жыл бұрын
i wanr to spam myself previously not working now a 2nd chance
@doubleHLabs
@doubleHLabs 4 жыл бұрын
This is awesome. I installed it with pip in pyCharm and tested it out. Worked first try. Now to start automating!
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Glad to hear it!
@zxdvbvzdfbzdfgdg
@zxdvbvzdfbzdfgdg 5 ай бұрын
Our saviour! I've been trying to set up a simple macro to automate video games so when I'm not able to play I can run my macro on a raspberry pi. While in my attempt to do this I noticed that mouse interactions would only work if I was moving the mouse around. Thank you so much!
@how2eatanapple975
@how2eatanapple975 4 жыл бұрын
Dude thank you so much! Now I can create my evil robot of destruction in minecraft. The cost will be many lives because of this. You have given me... ULTIMATE POWER!! Seriously thanks I was stuck! Edit: also there is not a hotkey command but I can just use keyDown and keyUp fine
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Haha, glad to help! Yeah it doesn't have any other way to do key combos right now.
@deadpopcorn8523
@deadpopcorn8523 2 жыл бұрын
@@LearnCodeByGaming i play a 3d game called "planet of cubes" i havent tested it on other 3d games but any clicking command from pydirectinput is read as holding, but when i open my inventory its all good. My theory is that is outdated
@Limofeus
@Limofeus 3 жыл бұрын
Thanks a lot! I have a long story with this, so this was incredibly useful for me! I have tried to create simple macros for some video games about a year ago and i have tried a lot of different macro applications, different input libraries for python and NONE of them worked for any game, but what was even stranger to me is that all the inputs worked for in-game chat or any other text boxes. So i thought that all the inputs i was sending DO work, but for so little amount of time that the game could only handle them with text boxes. And this led me to spending hours and hours trying to figure out why the librarys can't hold keys but only press them for so little. And only now i found this incredibly simple, but amazingly useful video. Thank you a lot once again!
@psmith5573
@psmith5573 3 жыл бұрын
I liked 20+ on the comments to express my emotion to this effort. The world is better with the people like you!
@yarx1922
@yarx1922 3 жыл бұрын
New to python, and this tutorial is very easy and very helpful. Thank you very much!
@recepciftci2642
@recepciftci2642 3 жыл бұрын
After all this struggle with not using pyautogui or similar libraries in the game, your solution worked. Thank you so much. You are great man.
@arescharles1674
@arescharles1674 9 ай бұрын
click api is not working, did u use this api?
@universe6578
@universe6578 4 жыл бұрын
whoa thank you so much i was struggle with this for fkn *4 hours*
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Glad to help!
@ZackDaQuack
@ZackDaQuack 3 жыл бұрын
It took me 5 hours
@Wavened
@Wavened 4 жыл бұрын
You prevented me from getting a migraine, thank you so much!
@laniakea8147
@laniakea8147 2 жыл бұрын
Thanks to this movie, I succeeded to automate “Lightning Dodger” that is famous extremely-hard side quest of Final Fantasy X. ありがとう😊
@AyaanKumar-mo7fx
@AyaanKumar-mo7fx Жыл бұрын
Genuinely thank you so much! I had been trying to fix an issue for ages and nowhere else said why pyautogui wasn't working
@raulalejandrofuentesblanco8975
@raulalejandrofuentesblanco8975 2 жыл бұрын
To anyone who is having problems because your code only runs the first time, be sure that you are also doing a keyUp when your doing a keyDown.
@SimonPrefontaineGames
@SimonPrefontaineGames 4 жыл бұрын
You just saved me a lot of headache! Thank you :)
@anmolsaxena3832
@anmolsaxena3832 3 жыл бұрын
Found no other video that solves this problem . Thank u very much
@LearnCodeByGaming
@LearnCodeByGaming 3 жыл бұрын
Glad it works for you
@Gamebito
@Gamebito 3 жыл бұрын
Thanks! Discord wasn't recognizing any custom keybinds I set (in the discord settings) when using pyautogui, but using your pydirectinput works!
@hotz5589
@hotz5589 3 жыл бұрын
Idk if you still read through this but THANKS. I always had problem with keyboard input and this library just WORKS. Thank you so much
@JamBear
@JamBear 4 жыл бұрын
You seem like a genuinely nice guy.
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Thanks, I try to be!
@whxmpy56
@whxmpy56 2 жыл бұрын
BRO I M GOING TO CRY THANK YOU SOOOO MUCH YOU ARE A LIFE SAVER.
@n.m.danimations5854
@n.m.danimations5854 3 жыл бұрын
With pydirect input i keep getting the error no module called pydirectinput?
@Alexandurs
@Alexandurs 4 жыл бұрын
You should have more subscribers sir, your content is top-notch.
@yasam3780
@yasam3780 2 жыл бұрын
How can I perform a click action while a directx game is running? I tried pyautogui, pydirectinput, pywinauto, autoit. None of the above modules were able to click anywhere on the both game or desktop or browser while the directx game is running.
@zuccthe4thttv887
@zuccthe4thttv887 4 жыл бұрын
Thanks man! youve earned your 1000th sub!
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Thanks!!!
@Vse8311
@Vse8311 4 жыл бұрын
Thx for creating pydirectinput. Its working great!
@paulonascimento3461
@paulonascimento3461 3 жыл бұрын
Dude you're the best human in the world, you just save a brazilian life and time.
@decqyd
@decqyd 3 жыл бұрын
do you know how i can get the mouse functions to work with looking around minecraft bedrock? ive tried using both pyautogui and pydirectinput but they dont seem to work
@kavikanaveli8348
@kavikanaveli8348 3 жыл бұрын
have you found a solution?
@suleyk4063
@suleyk4063 4 жыл бұрын
I have a question. Your library seems to work with the game Rainbow Six Siege, but the mouse movement is erratic no matter what values I put for the movement. Do you know why this might be the case? I think it might have to do with the game grabbing the mouse to the screen. I'm not sure how to go about a work-around.
@patta3213
@patta3213 3 жыл бұрын
First of all: Great Work!! But I would like to ask you if there is a way to send keystrokes to an inactive window with a handle or something, so I can use this in background.
@LearnCodeByGaming
@LearnCodeByGaming 3 жыл бұрын
Hi thanks! I'm working on a video about that right now actually. Should be out in about a week.
@kvnei
@kvnei 3 жыл бұрын
I have the same question, really looking forward to your video!
@kvnei
@kvnei 3 жыл бұрын
do you mind to share the basic idea so that I can try it first?
@stead2767
@stead2767 Жыл бұрын
@@LearnCodeByGaming hi teacher~~~where can I find the tutor viedo you makes~~~thank~~very a lot !!!
@joethumbsup5266
@joethumbsup5266 3 жыл бұрын
man, you're awesome! i admire you professionalism!
@tobagheorgheirinel703
@tobagheorgheirinel703 4 жыл бұрын
One of the best video again mate👍👍👍
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Thanks as always!
@SRFxVideos
@SRFxVideos 4 жыл бұрын
BROOO! YOUR LIB IS WORKING! GOOD JOB!!!! THANK YOU! Just launch your scripts with Administrator.
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Glad you got it working!
@jimmysaxblack
@jimmysaxblack 11 ай бұрын
thanks mate i have an issue with pyautogui locate image center work on asus not HP any leads ?
@splinterun9005
@splinterun9005 4 жыл бұрын
I tried this library for fallout:new vegas which is a directx 9 game, as well as running the script from an administrator command prompt, however no mouse movements or keyboard inputs would work. Do you know anything else that would work?
@MushBeck_Goat
@MushBeck_Goat Жыл бұрын
Hello, I tried to create a BOT in python for my game in LDPLAYER 9 (an Android emulator), but pyautogui and pydirect work on my windows but not on my emulator how to solve this probleme?
@ipratik91
@ipratik91 4 жыл бұрын
I am using pyautogui with opencv to make a bot for a game. Problem is want the program to keep taking screenshots till it finds a button that I want pressed and only then move forward. I tried if loop but pyautogui is not returning none or ImageNotFound. It's returning something else only if it doesn't find the image. Can u help?
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
What is locate() returning? And are you using the confidence parameter? If you want to share your code with me on pastebin.com I can diagnose the problem faster.
@greedsloth1516
@greedsloth1516 4 жыл бұрын
Thank you Ben! I am almost sure but i just had to ask are you a developer by career?
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
I am! I've been doing it for 12 years, and since last year I've been working as an independent consultant.
@k15e15
@k15e15 Жыл бұрын
Thank you!! You're a genius!! I'm from Russia. I have been looking for a solution to the problem for a long time and there was no information about it. But I came across your video! I've stumbled upon gold!! thank you very much for making such an addition to the library!!! You're the best! Subscribe and like! You deserve more!
@aamirnafis4139
@aamirnafis4139 3 жыл бұрын
mansood bhai tum bhuut accha kaam kartteh ho
@VabrinBR
@VabrinBR 3 жыл бұрын
I was trying to do it at PUBG Lite just for test and doesn't work, any suggestion?
@kasoa.thourcans124
@kasoa.thourcans124 3 жыл бұрын
You're a genius, my hero, thank you so much, it works perfectly
@rafaelap.6193
@rafaelap.6193 Жыл бұрын
Muito obrigado, passei horas tentando arrumar isso e não achava solução em lugar nenhum, estava nas ultimas tentativas antes de desistir.
@ericsein
@ericsein Жыл бұрын
Bom dia, ainda funciona pra voce? pra mim ainda não funciona... Pode me dizer por favor qual foi a solução?
@Lea-ww9hf
@Lea-ww9hf 2 жыл бұрын
Hello I have a problem, when I press a key, it don't work ingame, but when I try it in a notepad it work. I used pyautogui and pydirectinput. Neither worked
@lyricsms5448
@lyricsms5448 3 жыл бұрын
I love these videos but i wanted to ask you a question you might know a lot about. So I know that some people say that programs or anti cheats can detect a program using code to send keystrokes or button presses. What makes clicking the mouse button yourself over just having a program do it? Like is it true it's really more detectable that way?
@camvel869
@camvel869 Жыл бұрын
A big shout out to you in 2023! Thanks for helping me keep building a solution to use a coin acceptor over arduino. As my arduino can definitely not be flashed to hid so that it sends direct keyboard presses, I linked it to python where I ask it to send a key press that should insert a coin credit in mame. Problem is that the default keyboard library in python is not direct input based. This library helped a lot and then instructing mame.ini to use direct input finally made mame recognize python command. All of this would have been much simpler with arduino Leonardo but I didnt want to give up until I played with coding and thought of solutions with my arduino uno. Thanks.
@carlosquinones7560
@carlosquinones7560 2 жыл бұрын
Hey, so I tried to use both pyautogui and pydirectinput but neither of them are working for Halo 5 Forge on PC. It detects the mouse movement and the pydirectinput.press() method works for keyboard inputs but the leftClick() method doesn't work in the game, it only moves the mouse around but the clicks are not registering in neither module. What should I do?
@sameer1234ification
@sameer1234ification 2 жыл бұрын
I've been using "mouse" python library for a while to move cursor programmatically; and I recently stumbled upon the issue that it does not get recognized by video games such as call of duty ... I noticed in the morning that "mouse" library uses the same mouse events utilized by PyAutoGUI; So I modified my code to use your library instead and i am currently in the testing process .. I hope it works
@ch66linux39
@ch66linux39 Жыл бұрын
Hello, I called your library according to the method in your video and tried it. The click operation can proceed normally, but the move operation still has no effect. Do you know how to solve it? My test game is BLOCKPOST. Looking forward to your reply.
@MushroomHunt0
@MushroomHunt0 2 жыл бұрын
Is there currently a version for linux? I am currently running into the issues that you are describing/showing.
@alintaredurand
@alintaredurand 2 ай бұрын
Hi, I don't know if you're still answering on this channel or not, But I'm having trouble with mouse movements... I had the autogui problem with keyboard inputs and after I switched to directinput everything was better, But for now the mouse still doesn't move so I dunno what's the problem I've been stuck on this for like 4 hours, need some input =S
@maiconjogos
@maiconjogos 5 ай бұрын
Well, I was trying to auto a task on Nemu Player, a Emulator for cellphone, but none pyAutoGUI, pyDirectInput or pyWin32 worked.
@pharaohx7k358
@pharaohx7k358 2 жыл бұрын
Is there any library that will send inputs to controllers? Like moving left stick up..
@estebeste4045
@estebeste4045 4 жыл бұрын
Hi! First of all thank you for the tutorials, they are really helpful. I have a question tho. Can some game have their own cursor position different from the your actual cursor position? I'm asking because I'm making a bot for a game that recenters the cursor everytime I move it in game, and the thing is if I use pydirectinput.move(x,y) it moves it inside the game but at very random positions, not where I intend it to move. Also another interesting thing is after i run the function once, it moves to a random position, but then if I move around in game with the cursor(to change its position) and run the function again, the cursor doesn't move at all, like it thinks it's already there. Only if I give it different coordinates it will move again to a random position. If you got any idea what's going on, please let me know! Thanks!
@crazycalias6380
@crazycalias6380 4 жыл бұрын
este beste are you trying to use it in a first person shooter? I am trying in a first person shooter and I am having the same problem. The cursor doesnt move to where it is supposed to... if you find any solution let me know pls
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Hello! So move(x, y) does relative movement from your current mouse position. You might be looking for moveTo(x, y) to go to an absolute position on your screen. There's also moveRel(x, y) which is just another name for move(x, y). Hope that helps! Sorry it's not the best naming conventions, I'm following the function names set by PyAutoGUI.
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
@@crazycalias6380 Hi! Try using moveTo() instead of move().
@estebeste4045
@estebeste4045 4 жыл бұрын
@@LearnCodeByGaming i was using moveTo, sry I said move by mistake
@suleyk4063
@suleyk4063 4 жыл бұрын
@@LearnCodeByGaming All of the functions dont seem to work properly in an fps environment. I think its because the game calculates the distance between the before-and-after coordinates then moves the camera, and when combined with the fact that you cant see the absolute cursor position, makes it look like weird, random movement. Any thoughts on a work-around?
@hourz
@hourz 4 жыл бұрын
are we able to cntrl + v with pydirectinput?
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Yes, but you can't use the press() shortcut. You need to keyDown('ctrl'), keyDown('v'), keyUp('v'), keyUp('ctrl').
@mark7230
@mark7230 4 жыл бұрын
Hi, I tried your library but it's not working inside the window of my game. What else I can try?
@henrycharriere5256
@henrycharriere5256 2 жыл бұрын
tnks man, do you have some option for linux? pyautogui does not work moveTo method for me
@imrebudai4930
@imrebudai4930 4 жыл бұрын
Hello. I try to make a "clicking bot" for MTA:SA,but it seems like none of the libraries work in this game. Everything goes pefectly,until I run it in game. I use exactly the same pydirectinput command as you,but it doesn't work. Do you have any idea,what could cause the problem?
@mariusz8385
@mariusz8385 4 жыл бұрын
i've tried both pyautogui and pydirectinput to make my click my mouse in football manager 2009 and it doesnt want to work for some reason... i do see mouse being move but the click doesnt want to work
@surayuthpintawong8332
@surayuthpintawong8332 3 жыл бұрын
I try to import your library on Ubuntu and I get the error: module 'ctypes' has no attribute 'windll'. Is there a way to fix this?
@LearnCodeByGaming
@LearnCodeByGaming 3 жыл бұрын
No sorry this library is only designed for Windows.
@surayuthpintawong8332
@surayuthpintawong8332 3 жыл бұрын
@@LearnCodeByGaming Ok, Thanks.
@asdasdasasdasdas9073
@asdasdasasdasdas9073 3 жыл бұрын
hey any solution for games like black desert online ? directinput doesnt seem to work
@MashenkaRust
@MashenkaRust 2 жыл бұрын
what with ebalom
@ThePirateHistory
@ThePirateHistory 3 жыл бұрын
Have game like counter strike nexon studio, there not work your lib) and i try win32 is the same, can i trigger real output from mouse&
@SmalltimR
@SmalltimR 2 жыл бұрын
Hi, would it be possible to move the mouse along a specific path and speed?
@cristiankaz2264
@cristiankaz2264 2 жыл бұрын
Very well explained and done :) I tried to use this for a game called metin2 but it still didn't work tho :( any ideas why? I tried rocket league and it works just fine. Thank you for the content
@haoranjiang6866
@haoranjiang6866 4 жыл бұрын
hi I am creating an automation tool to move the mouse which can adjust the camera position in a game created by `UE engine`. Trying to use `pydirectinput` and `pywinauto` to control the mouse, but if moving the mouse to a coordinate which has a negative number like: ``` pydirectinput.moveTo(-100,540) or pywinauto.mouse.move(coords=(-100,540)) ``` the camera position in the game will not be changed. wt should I do
@raychen8221
@raychen8221 3 жыл бұрын
it seems the failsafe for pyautogui isn't working when I use DirectInput. Could you fix that?
@TheChipmonks
@TheChipmonks 3 жыл бұрын
Thanks for the video man, i just need a little help While using the move method I get a laggy motion, its not smooth as of mouse. Pls help me out
@LearnCodeByGaming
@LearnCodeByGaming 3 жыл бұрын
Thanks! Duration and tween haven't been implemented in the mouse moveTo() in PyDirectInput, so jumping to the given coordinates is the expected behavior right now. You'll need to write your own smoothing or pathing for the mouse movement.
@TheChipmonks
@TheChipmonks 3 жыл бұрын
@@LearnCodeByGaming sorry but I am not that advance 😂, will wait for future updates of your library. Thanks again for DirectInput
@Bob-em6kn
@Bob-em6kn 3 жыл бұрын
The mouse moveTo is not working on roblox. It won't move to the position i set until I physically move my mouse, is there any fix to this?
@phongo9343
@phongo9343 3 жыл бұрын
I used pyautogui and directinput but the game window still won't work with mouse click and press, I'm playing Mir4 Global, they use DirectX and OpenGL When I select DirectX the title window of the game can't be found so I don't use DirectX. Then I switched to using OpenGL and found the game window, but mouse clicks and keyboard presses didn't work. Do you have any idea about this problem please help me...thank you
@gnooox
@gnooox 2 жыл бұрын
wow this is what i looking for upto now. it works perfectly thanks so much. subscribed before text. thanks a lot
@nickplj12
@nickplj12 3 жыл бұрын
How do I get it to press multiple keys at once?
@steve7878
@steve7878 3 жыл бұрын
brother this is good work, thank you for sooo much!
@__hazelnut
@__hazelnut 3 жыл бұрын
You are an absolute legend tysm!
@Mikey-zf1lf
@Mikey-zf1lf 3 жыл бұрын
so this is really late, but how do I use duration in the moverel function?
@AhmedKamel-ol6qv
@AhmedKamel-ol6qv 4 жыл бұрын
Thanks for the great work. Can I input more than key simultaneously?
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Yes you can. The only issue I know of is if you press arrow keys at the same time as an alphanumeric key, it acts like shift is being held down. I plan to correct that at some point, but it's still a bug right now.
@AhmedKamel-ol6qv
@AhmedKamel-ol6qv 4 жыл бұрын
@@LearnCodeByGaming I am confused of how to did this. can you show me?, thanks a lot. when I write it like this, they got pressed in series. pydirectinput.keyDown('k') pydirectinput.keyDown('u') time.sleep(2.00) pydirectinput.keyUp('k') pydirectinput.keyUp('u')
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
@@AhmedKamel-ol6qv I think I misunderstood your original question. PyDirectInput isn't able to send multiple keyDown (or keyUp) inputs at exactly the same time. You can do it if you drop down to using ctypes.windll.user32.SendInput directly.
@AhmedKamel-ol6qv
@AhmedKamel-ol6qv 4 жыл бұрын
​@@LearnCodeByGaming Thanks a lot for your help. I am trying to build my first game Bot using Reinforcement Learning to play Pro Evolution Soccer. I have almost fair background in python, but i am quit familiar with RL as part of my research in Transportation. your videos helped me in my first steps. wish you all the best.
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
@@AhmedKamel-ol6qv Awesome that sounds sweet, wishing you the best too!
@automaticmonkTV
@automaticmonkTV Жыл бұрын
Thanks for making pydirectinput you rock
@ninjatekno1980
@ninjatekno1980 4 жыл бұрын
Hello Ben ! can you help me about my scipt ? I did everything right but my mouse clicks or keyboard events still not works on my windowed screen game. What should i search for on internet i don't know. Here is my code: from pyautogui import * import pyautogui import time import win32api , win32con , win32gui import pydirectinput while keyboard.is_pressed("q") == False: if pyautogui.pixel(994,204)[0] != 88: pydirectinput.keyUp("space") time.sleep(0.5) pydirectinput.keyDown("space")
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Hi! I think you mean to call keyDown first, wait half a second, then call keyUp?
@ninjatekno1980
@ninjatekno1980 4 жыл бұрын
@@LearnCodeByGaming Hi again i fixed my exception i just run as administrator to visual studio code and then your pydirectinput that worked. I really thank you for sharing pydirectinput it is really usefull thank you very much 👍🤩
@cozinhadocidao
@cozinhadocidao 4 жыл бұрын
Hey, my script runs perfect on shell but not on screen. looks like the game dont capture the "w" key or something like that.
@cozinhadocidao
@cozinhadocidao 4 жыл бұрын
He dont pass the command to the game, u know what i mean? even with the pydirectinput
@Majitsu
@Majitsu 2 жыл бұрын
tried this but still doesnt control mouse movements or clicks in the game window
@eb941
@eb941 4 жыл бұрын
Super Helpful! You the man
@Ehxx
@Ehxx 4 жыл бұрын
pyautiogui.keyup gives an attribute error while pyautogui.keydown works fine?
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Interesting, any more details? What's the exact error message and what does the code look like? (Please use pastebin.com to show the code)
@Ehxx
@Ehxx 4 жыл бұрын
@@LearnCodeByGaming Was just a typo importing pyautogui, surprised keydown worked still with the typo.
@xmp9564
@xmp9564 2 жыл бұрын
dude edirectinput not working is there any other python module we can use
@hostgrady
@hostgrady 4 жыл бұрын
I'm going to criticize the pip in this comment just to be distinct from the other thread. I have noticed the "write" function is quite slow in comparison to autogui's version. On top of that the interval function doesnt really function at all. Idk if this is known but it would be cool to communicate via a bot using this version of pyautogui
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
Thanks for letting me know, I'll look into it, and thanks for trying out PyDirectInput!
@hostgrady
@hostgrady 4 жыл бұрын
@@LearnCodeByGaming np, love the support for other games already
@hostgrady
@hostgrady 4 жыл бұрын
@@LearnCodeByGaming just as an addon, from what I can see, the write function works fine without direct input, I have been able to switch seamlessly between your library and pyautogui's type function seamlessly
@TheFlipsy
@TheFlipsy 2 ай бұрын
I know I'm years late, but I'm VERY thankful for PyDirectInput! Is there any way for PyDirectInput to take controllers into account? Only one other library appears to attempt to have controller input be taken into account (vgamepad) but that's also only virtual inputs and so there is no DirectX input for gamepads.
@louiswheelz1993
@louiswheelz1993 4 жыл бұрын
HELP please :( I did the pip install pydirectinput but whenever i try to import it on vscode it says "unable to import pydirectinput"
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
If you're using a virtual environment, make sure you have the right one activated. If you're not, then make sure the Python you're using to run the script is the same Python path that pip is installing into. Getting these Python environment things sorted is definitely my least favorite part of Python 😕
@louiswheelz1993
@louiswheelz1993 4 жыл бұрын
@@LearnCodeByGaming hey :) some updates, when i try to install pydirectinput and run the same program on my laptop, it works just fine! can you tell me about this environement thing ? maybe that is the issue
@LearnCodeByGaming
@LearnCodeByGaming 4 жыл бұрын
@@louiswheelz1993 The exact way to solve your problem is going to vary a lot based on which shell you're using, how you're launching the program, and how Python is installed on your machine. But essentially your goal is to make sure that the Python executable that's running your program is the same one that pip is installing packages into. If you're using GitBash or any other *NIX command line, the commands "which python" and "pip list -v" will show you the relevant paths. You can also manually look in your Python folder for lib/site-packages/ and check there to see if your pip installed packages are there or not. You'll likely need to do some Google searching for "pip package not found" and other terms relevant to your setup to find a fix that works for you.
@louiswheelz1993
@louiswheelz1993 4 жыл бұрын
@@LearnCodeByGaming okay:) i will look into all of that thank you very much! i'm a first year CS student so im more or less 'new' to some of this ! I want to thank you very much for the effort you put into your replies, I really appreciate it a lot! you sir are great and your channel is a hidden gem! you deserve a lot more subs!
@mrweb9087
@mrweb9087 3 жыл бұрын
@@LearnCodeByGaming In Windows 8.1 pyautogui.keyDown('alt') pyautogui.keypress('tab') Time.sleep(1) pyautogui.keyUp('alt') This is not working for switching the windows Please help me to solve this problem I also try hotkey Please tell me the solution if anyone knows 🙏🙏
@zarakikenpachi1238
@zarakikenpachi1238 4 жыл бұрын
can you help me ? when i try to run script on videogame, game crash
@ejoojoo
@ejoojoo 3 жыл бұрын
does this work for unfocused window
@thzeroucken
@thzeroucken 3 жыл бұрын
holy thanks! you the only one who helped me
@normandas9647
@normandas9647 2 жыл бұрын
omg thank you so much man after hours of searching for solutions i found this❤
@cryptofrogich
@cryptofrogich 3 жыл бұрын
ERROR: Could not find a version that satisfies the requirement win32gui (from versions: 221.3, 221.4, 221.5) ERROR: No matching distribution found for win32gui >but downloaded to the root file, that is, it does not start it, what's the problem?
@VaneHD
@VaneHD 3 жыл бұрын
Hi, hope you are doing well, on the popular game called Roblox it does not seem to work pyautogui.moveTo(pyautogui.locateOnScreen("image.png",confidence=0.9)) -- moves mouse to image pydirectinput.click() -- clicks on where mouse (positioned in the in-game button) is but just doesn't work
@ЯнМатвеев-г9я
@ЯнМатвеев-г9я Жыл бұрын
tysm! i tried ALOT of libs and none of them worked, but this one did :) i was trying to do wave auto skip for TDS in Roblox
@AdriRPerez
@AdriRPerez 2 жыл бұрын
i am having an issue where i can only right click once and left click once, after the first time, if i try to right or left click again it does not register, can anyone help?
@nguyenangkhanh1485
@nguyenangkhanh1485 3 жыл бұрын
Thank you so much, this pretty much worked for me but some cases don't. For the Teamfight Tactic game, the keyboard event works like a charm but when I try to /ff (surrender), a new window appears and let me choose to accept quit or not and after that mouse function is fire to click accept button, it's done click, but seem like the game isn't taking that input from mouse, how can I fix it? The CMD and game run as Administrator.
@BCB010-d9o
@BCB010-d9o 4 жыл бұрын
Is time.sleep() is necessary to use keyDown() ? Bcuz when I use keyDown() it only pressed one time How Can I hold down the key :(
@dag_6881
@dag_6881 4 жыл бұрын
Use looping
@mrweb9087
@mrweb9087 3 жыл бұрын
In Windows 8.1 pyautogui.keyDown('alt') pyautogui.keypress('tab') Time.sleep(1) pyautogui.keyUp('alt') This is not working for switching the windows Please help me to solve this problem I also try hotkey Please tell me the solution if anyone knows 🙏🙏
Fast Window Capture - OpenCV Object Detection in Games #4
30:48
Learn Code By Gaming
Рет қаралды 242 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
I tried to make a Valorant AI using computer vision
19:23
River's Educational Channel
Рет қаралды 1,5 МЛН
Direct Input - Python plays Grand Theft Auto 5 p.3
12:34
sentdex
Рет қаралды 157 М.
How to make advanced image recognition bots using python
15:01
Kian Brose
Рет қаралды 1,4 МЛН
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
LEVEL 1 POKEMON TROLL POKEMON SHOWDOWN...
12:16
temp6t
Рет қаралды 1,2 МЛН
Why I Would Use Pynput or Mouse Over PyAutoGUI
5:32
WhyNotProgram
Рет қаралды 1,9 М.
Convert .EXE to Source Code!
8:05
ebola man
Рет қаралды 219 М.
Automating Android Games with Python: Stick Hero
15:22
Engineer Man
Рет қаралды 386 М.