I'm new to this forum and python, any help is greatly appreciated.
I'm trying to add a if statement under FOR LOOP, as my code shows below, at the moment, my mouse moves to 4 spots before it closes the current web tab, and it repeats this for 10 times.
My question is how to add a if statement ie. if the right arrow key is pressed while the mouse is moving, it skips a few line of codes and goes straight to the last four line of codes?
The current tab is closed and it moves onto the next tab, until it finishes it's 10 cycles. This new If statement helps to close the browser tab much quicker with human intervention instead of waiting for the whole 8 seconds.
Thank you.
import pyautogui as pg
import time, pyautogui
import keyboard
from pynput.keyboard import Key, Listener
pg.moveTo(2679, 900)
pg.click()
for i in range (10):
pg.moveTo(2679, 1620, duration=2)
pg.moveTo(2679, 1923, duration=2)
pg.moveTo(1365, 1875, duration=2)
pg.moveTo(1365, 1572, duration=2)
pg.keyDown('ctrl')
pg.keyDown('w')
pg.keyUp('w')
pg.keyUp('ctrl')