How to get a reference to a child window of an app?

Asked by Mike Williamson

I am writing a script to launch an App and then search within it. The search window appears when I click the appropriate button and I would like to get the Region for just that window.

I tried using myapp.window(1) thinking that this would give me a region for just the search window that had been opened. Saving a capture of the region reveals that it gives me the entire App window. My script was working only because the search window falls within the bounds of the App window.

How can I get the region of just the child window of this app?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Mike Williamson
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

What system?

How is myapp defined?

You might try the following:

for i in range(100):
    r = myapp.window(i)
    if not r: break
    print "window", i
    r.highlight(2)

this will highlight all reachable windows on after the other and report the region aspects with the window number.

Revision history for this message
Mike Williamson (sleepycat) said :
#2

myapp is the return value of App('C:\some\path\to\an\exe')

So I tried what you gave me and it turns out that window(0) is what I needed.
My assumptions about how that was working were way off.
Does this mean that if the app's child window opens a child window of its own, does that then become window(0)?
Basically like a fifo stack?

Revision history for this message
RaiMan (raimund-hocke) said :
#3

As far as I understand, what they have done on windows in this area, then you get the windows, that are registered with the respective process (whose process id is internally stored when saying x = App('C:\some\path\to\an\exe')), in the current z-order, means frontmost is 0 and so on.
So this has nothing to do with fifo - it is just dynamic with respect to the focus given with keyboard and/or mouse actions.

But one has to be careful with that: some of the windows you get might not be visible at all at that moment.

You might check this with the above test, by making your main app window frontmost (if possible - the dialog window might be modal (blocking clicks on other windows of same app until closed)).

Revision history for this message
Mike Williamson (sleepycat) said :
#4

Interesting.
Thanks RaiMan.