I am a new python 3.9 user who's trying to step up my coding. I'm writing a program that uses a while loop and will call functions to press keys based on user input. My code basically looks like:
from pynput.keyboard import Key, Controller
from graphics import *
import time
def wack():
M = Controller()
for i in range(3):
M.press('a')
time.sleep(1) # This guy right here is the issue
M.release('a')
def main():
click = Win.checkMouse()
while not click(click, exit_box):
click = Win.checkMouse()
if *input* == *correct string*:
wack()
I have a graphics window with an exit button and when exit is clicked, it terminates the program and closes the window. The issue is that the time.sleep(1) doesn't pause the inputs or that point in the code, it pauses the entire program suspending the while loop which is not what I want it to do.
Searching about the time function hasn't provided any clear solutions since time.sleep() seems to be the most popular pausing function in python.