pyautogui click(fw left fw top you can now use these attributes to calculate precise coordinates within window if you know that button you want to click is always pixels to the right of and pixels down from the window' top-left cornerand the window' top-left corner is at screen coordinates ( )then calling pyautogui click( (or pyautogui click(fw left fw top if fw contains the window object for the windowwill click the button this wayyou won' have to rely on the slowerless reliable locateonscreen(function to find the button for you other ways of obtaining windows while getactivewindow(is useful for obtaining the window that is active at the time of the function callyou'll need to use some other function to obtain window objects for the other windows on the screen the following four functions return list of window objects if they're unable to find any windowsthey return an empty listreturns list of window objects for every visible window on the screen pyautogui getwindowsat(xyreturns list of window objects for every visible window that includes the point (xypyautogui getwindowswithtitle(titlereturns list of window objects for every visible window that includes the string title in its title bar pyautogui getactivewindow(returns the window object for the window that is currently receiving keyboard focus pyautogui getallwindows(pyautogui also has pyautogui getalltitles(functionwhich returns list of strings of every visible window manipulating windows windows attributes can do more than just tell you the size and position of the window you can also set their values in order to resize or move the window for exampleenter the following into the interactive shellimport pyautogui fw pyautogui getactivewindow( fw width gets the current width of the window fw topleft gets the current position of the window ( fw width resizes the width fw topleft ( moves the window controlling the keyboard and mouse with gui automation