Sep-24-2020, 03:51 PM
Unless you create some sort of multi-threaded app (which is not easy), there's no way to stop a function from the outside. The outside program is just waiting for the function to return.
Some options:
That marketloop() function is doing a lot of repetitive things. A loop would be good for it. If you had the data in a nice map, you could loop over them, and then check for the keypress (and exit) if you see it.
Some options:
That marketloop() function is doing a lot of repetitive things. A loop would be good for it. If you had the data in a nice map, you could loop over them, and then check for the keypress (and exit) if you see it.
files = { "offers": "offers.PNG" "search": "search.PNG" "settings": "settings.PNG" } def marketloop(): for region, filename in files.each(): data = pg.locateCenterOnScreen(filename, region=(0,0,1919,1079), grayscale=False, confidence=0.80) time.sleep(0.5) pg.click(data.x, data.y) time.sleep(0.5) if check_keypress() == pressed: #however you do this... return # Exits the function immediately.