Python basic questions: (pyautogui) and errors

Asked 2 years ago, Updated 2 years ago, 59 views

Hello, how are you?

Purpose

If you run it with that code, some windows end, but the windows end irregularly. What's the problem?

I'm a non-major, so I'd appreciate your help.

import pyautogui as GUI

 win = GUI.getWindowsWithTitle("KP4") #Number of open windows: data type list

 for win2 in win :
     win2.activate()
     GUI.hotkey("alt", "f4")
     win = GUI.getWindowsWithTitle("KP4")
    if len(win) == 1 :
        break 
```python

py

2022-09-19 23:33

1 Answers

I haven't used pyautogui, but win = GUI.Assuming that getWindowsWithTitle("KP4") win2.activate() and GUI.hotkey("alt", "f4") function normally,

import pyautogui as GUI

 win = GUI.getWindowsWithTitle("KP4") #Number of open windows: data type list

 for win2 in win[:-1]:
     win2.activate()
     GUI.hotkey("alt", "f4")

I think it would be helpful if you do it like this.


2022-09-19 23:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.