pydirectinput icon indicating copy to clipboard operation
pydirectinput copied to clipboard

Write function slow, interval not working

Open learncodebygaming opened this issue 4 years ago • 6 comments

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 avatar Mar 13 '20 01:03 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"

learncodebygaming avatar Mar 13 '20 02:03 learncodebygaming

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 avatar May 29 '20 02:05 AndrewJWashington

Any tips on speeding it up?

AndrewJWashington avatar May 29 '20 02:05 AndrewJWashington

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

AndrewJWashington avatar May 29 '20 22:05 AndrewJWashington

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.

learncodebygaming avatar May 29 '20 23:05 learncodebygaming

Glad to help!

AndrewJWashington avatar May 30 '20 00:05 AndrewJWashington