Interesting Observation using Try to close window.

Asked by Carl

This is more of an observation than a question. While learning Siluli I am tryng many things. Today I put in some tearodown code that works to close out a cmd launch window. It works fine, but when I run it and the cmd window is already closed - it will highlight the last window that was active. It will not close that window, just highlight it. Interesting... I would think tha the highlight would not activate since the region could not be defined.

I am running Win7 Enterprise SP1.

def someDef()
        try:
            wTCRC = App("My Rich Client Launcher").focus() #This is a cmd window that was used
                                                                                  # to launch the rich client.
            rTCRC = Region(App.focusedWindow())
            rTCRC.highlight(2) #If launcher is already closed the last active window is highlighted.
            App.close(wTCRC)
        except:
            pass

someDef

Question information

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

App.focusedWindow()
is generally the frontmost window of all open windows of all running apps (and might not even be visible), so this is as it should be.

Revision history for this message
Carl (n223mm) said :
#2

So, I am using apples and oranges? Thanks for the clarification, that is good to know.

 I suppose I should define my region as

      rTCRC = wTCRC
instead of
      rTCRC = Region(App.focusedWindow())

then the "try:" should catch the error and continue on, right?

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

not really the solution:
wTCRC is an App object, that does not understand highlight.

I do not understand the complexity:

this is all you need:
App("My Rich Client Launcher").close()

would close the app if it is still open, otherwise simply nothing will happen.
No exceptions are thrown at all.

The App class currently has no features, to check what is really happening.

Revision history for this message
Carl (n223mm) said :
#4

The added complexity of highlighting is to show management visually what is happening. During this prototype phase it is better if they can see the flow of events as we talk through the demo. If we get the go ahead to start using this to develop automated testing then I can remove the complexit and speed up the process. :)

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

ok