I am new to python and I am trying to write a script that exits out of a loop when a certain window closes. I am having problems getting the code to work properly it won’t even enter the loop. I think this is because I am not properly getting the window name. I was wondering if there are any good tutorials on the Win32Gui extension that would help me to understand how it works.
Edit
Here is what I have, it is doing what it is suppose to do, but I am sure there is an easier way of doing it.
def answerCalls(local, network):
t = 0
count = 0
while t == 0:
time.sleep(1)
if win32gui.GetWindowText(win32gui.GetForegroundWindow()) == "Incoming Call":
time.sleep(10)
getApplicationPos("Incoming Call")
clickOnElement(******.IncomingCall_AnswerButton())
time.sleep(10)
if win32gui.GetWindowText(win32gui.GetForegroundWindow()) == "Video Call":
count += 1
writeFile("Answering Calls", count, local)
uploadToServer(local, network)
The following example (Python 3) gets a list of the titles of all the windows: