In my script I have:
def maximize_photoshop_window():
photoshop_window = pyautogui.getWindowsWithTitle("Adobe Photoshop")[0]
photoshop_window.maximize()
time.sleep(1) # Give a little time for the window to maximize
def activate_photoshop_window():
# Activate the Photoshop window titled "Untitled-1"
pyautogui.getWindowsWithTitle("Untitled-1")[0].activate()
time.sleep(1) # Give a little time for the window to activate`
# It stops with an error at this point (in Pycharm)
if __name__ == "__main__":
maximize_photoshop_window()
The error is:
Traceback (most recent call last): File "C:\1_python\Photoshop draw
circle in untitled-1 with spacebar.py", line 54, in <module>
maximize_photoshop_window() File "C:\1_python\Photoshop draw circle in untitled-1 with spacebar.py", line 9, in
maximize_photoshop_window
photoshop_window = pyautogui.getWindowsWithTitle("Adobe Photoshop")[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
Process finished with exit code 1
Wonder what is happening here?
getWindowsWithTitle
returns a list of all the windows with the given title. According to the error message, in this case, it returned an empty list, which probably means that "Adobe Photoshop" isn't the exact title of the window.