Jump to content

Python, Pyautogui, my while true loop doesn't continue

Enderg312

The code works once even though I have it set in a loop, what do I need to change to make it work.

<import pyautogui, time
time.sleep(5)
while True: 
    pyautogui.press("e")
    pyautogui.click()
    if w or a or s or d:
        stop()>

 

Link to comment
Share on other sites

Link to post
Share on other sites

This is the updated code the loop works but the w a s d won't stop the program
<import pyautogui, time
time.sleep(5)
while True:
    letter = "e"
    pyautogui.press(letter)
    pyautogui.click()

    if (input == "w" or input == "a") or (input =="s" or input =="d"):
        break   #this is your stop() function>
Link to comment
Share on other sites

Link to post
Share on other sites

What is input in this context? The variable isn't declared.

 

In any case, small code prettification:

    if input in ["w", "a", "s", "d"]:
        break   #this is your stop() function>

 

 

 

I like cute animal pics.

Mac Studio | Ryzen 7 5800X3D + RTX 3090

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×