r/pythonhelp • • Nov 10 '20

Keyboard.is_pressed() While Loop Condition

I'm writing a bot that plays the game on aimbooster.com. It takes a screenshot of the game and then clicks where it sees the bullseye. This runs in a while loop so that it can keep taking screenshots. To stop the while loop, the user should press the 'q' key on their keyboard. So I have the while loop set as such:

while not keyboard.is_pressed('q'):
    # Loop body

 

This works fine sometimes, but if the game speeds up and there are more mouse clicks, then I have to keep spamming 'q' and hope it goes through. Any ideas on how to avoid this issue? Thanks!

2 Upvotes

0 comments sorted by