Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
14 years ago

window object

What is the difference betwen the ActiveWindow "Use the property to get the current top-level window (the window the user is currently working with)"



And the FocussedWindow



Use the property to get the current top-level window (the window the user is currently working with) as



Can the user be working with a window that does not have focus?



I am gettign intermittent errors on a line of script



Sys.Desktop.ActiveWindow().Picture(,,,,False).SaveToFile sFilePath + VarToStr(Sys.Desktop.ActiveWindow.ObjectIdentifier) + ".png" ' TODO -oStephanie :Intermittent unexpected window error



I am getting unexpected window error. How can the active window be unexpected?
  • Lane,


    ActiveWindow is a top-level window. FocusedWindow is a control that has the focus.

    I suppose, you are working with a dialog that has a text box in it, and this text box has the focus.

    FocusedWindow will return the test object that corresponds to the text box, while ActiveWindow returns the test object that corresponds to the dialog.


    As for the unexpected window error, the situation seems to be a bit strange. I think that before capturing a window's image, the Picture method attempts to activate the window, and in your case, it fails to do this. This can happen if another window of your application blocks the activation, for instance, there is a modal dialog over the window you are working with. I agree with you that this is strange, because in this case, I would expect this modal dialog to be an active window.


    The ActiveWindow method uses a certain Windows API function to determine the active window. So, the method returns the data that this API function returns to it. Long ago, I saw this strange behavior (when the active window was not a modal window, but another window of the application).


    Sorry, I don't know any immediate solution to this problem. I'd suggest that you post the full name of the active window to the test log before calling the Picture method:




    ...

    s = Sys.Desktop.ActiveWindow().FullName

    Log.Message s



    Sys.Desktop.ActiveWindow().Picture(,,,,False).SaveToFile sFilePath + VarToStr(Sys.Desktop.ActiveWindow.ObjectIdentifier) + ".png"


    This will help you understand the image of the window you are going to capture. Perhaps, after that, you will have to change the test to eliminate the problem (for example, you can change the test to hide the blocking window).