learncodebygaming / pydirectinput

Python mouse and keyboard input automation for Windows using Direct Input.
Other
510 stars 89 forks source link

Write function slow, interval not working #1

Open learncodebygaming opened 4 years ago

learncodebygaming commented 4 years ago

Copying this issue report from YouTube by HostGrady: "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 commented 4 years ago

"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"

AndrewJWashington commented 4 years ago

I'm using this for a bot and it takes nearly half a second for this snippet to run:

keys = ['w', 'a', 's', 'd']
if prediction == 0:  # forward
    pydirectinput.keyDown('w')
    [pydirectinput.keyUp(key) for key in keys if key != 'w']
AndrewJWashington commented 4 years ago

Any tips on speeding it up?

AndrewJWashington commented 4 years ago

Figured it out. I didn't see the _pause argument. Setting it to False removes the lag.

learncodebygaming commented 4 years ago

Figured it out. I didn't see the _pause argument. Setting it to False removes the lag.

Thanks Andrew for letting us know how you fixed it. I forgot about that pause argument, too.

AndrewJWashington commented 4 years ago

Glad to help!