so i wrote a script that automatically clicks the bananas in bloons td 6 but i want to do it so that my mouse goes back to the position it was in before. Here is the script:
from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
time.sleep(2)
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
while keyboard.is_pressed('q') == False:
pic = pyautogui.screenshot(region=(750,610,700,500))
width, height = pic.size
for x in range(0,width,3):
for y in range (0,height,3):
r,g,b = pic.getpixel((x,y))
if (r, g, b) == (197, 143, 12):
click(x+700,y+500)
time.sleep(0.5)
break
elif (r, g, b) == (157, 117, 23):
click(x+700,y+500)
time.sleep(0.1)
break
im pretty new to python.