0

I have application that have 5 windows (1 window, 4x pane) that have parent Desktop and they share the same process_id.

When I try something like this:

for line in pywinauto.findwindows.find_windows(process=proc_id):
    print line  ### this will print all 5 handles of windows
    app = Application().connect(handle=line)   ### this will connect to specific handle
    app.top_window().set_focus()    ### this will set focus ONLY to one window and bring it to forward
    time.sleep(5)

This FOR loop should bring forward one window every 5 seconds (1 control_type="Window" element and 4time control_type="Pane" elements) But this will only bring to forward one window and nothing else, and it will get 5x focus on it. No windows change is done.

thanks

0

1 Answer 1

0

Because top_window() always chooses the first top window. What other could you expect from this method? Anyway we have plans to redesign or to remove it.

The right method for your purpose is app.windows():

for w in app.windows():
    print(w.window_text())
    w.set_focus()

Note: the app.windows() returns the list of wrappers, so only listing .children() or .descendants() is possible without advanced implicit waits and more detailed search specifications.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.