Reputation: 35
Im doing automation for a chat application on windows by module Pywinauto in python. When i create a new chat room, it generated a new window with unfixed name of window. The window name depends on numbers of chat room members. Example : if there are two members, chat room name displayed as name of that two members. But if there are more than 5 members, chat room name will be showns as member x and 4 others.
So the windows name is always changed. I dont know how to connect the new window to perform action
Im using Desktop(backend ='uia') Backend win32 is also too
(SOLVED) I walkaround and found a solution for this. Step1: connect to mainwindow (app = Application(backend ='uia').connect(title = mainwindowapp)
Step2: get top window ( app.top_window() )
Upvotes: 2
Views: 1173
Reputation: 10000
If this new window is in the same process, it's better to use Application(backend="uia").connect(process=pid)
where you can get pid
from main window by method .process_id()
. Then you can get all top level windows of this process:
from pywinauto import Desktop, Application
pid = Desktop(backend="uia").window(title="Main Window Title").process_id()
app = Application(backend="uia").connect(process=pid)
top_windows_before = app.windows()
# do some actions (create new chat)
for w in app.windows():
if w not in top_windows_before:
new_chat = w
Comparison between wrapper objects should work, that's why I suggest boolean operator w not in top_windows_before
.
Upvotes: 2