but what if you do not know beforehand where pyautogui should clickyou can use image recognition instead give pyautogui an image of what you want to clickand let it figure out the coordinates for exampleif you have previously taken screenshot to capture the image of submit button in submit pngthe locateonscreen(function will return the coordinates where that image is found to see how locateonscreen(workstry taking screenshot of small area on your screenthen save the image and enter the following into the interactive shellreplacing 'submit pngwith the filename of your screenshotimport pyautogui pyautogui locateonscreen('submit png' box(left= top= width= height= [ left the box object is named tuple that locateonscreen(returns and has the -coordinate of the left edgethe -coordinate of the top edgethe widthand the height for the first place on the screen the image was found if you're trying this on your computer with your own screenshotyour return value will be different from the one shown here if the image cannot be found on the screenlocateonscreen(returns none note that the image on the screen must match the provided image perfectly in order to be recognized if the image is even pixel offlocateonscreen(raises an imagenotfoundexception exception if you've changed your screen resolutionimages from previous screenshots might not match the images on your current screen you can change the scaling in the display settings of your operating systemas shown in figure - figure - the scale display settings in windows (leftand macos (rightif the image can be found in several places on the screenlocateallonscreen(will return generator object generators are beyond the scope of this book