Forum Discussion

murugans1011's avatar
murugans1011
Regular Contributor
11 years ago
Solved

Toplevel window

how to check whether the window is top-level window using if condition..i have an apps which i will work with multiple window i want to find whether the window is top level window in desktop or not in scripts.is tat possible through scripts?
  • You can use ActiveWindow method




    function isWindowTop(wnd)


    {


      var topWin = Sys.Desktop.ActiveWindow();


      return wnd.id == topWin.id;


    }



    Usage example:


    var wCalc = Sys.Process("CalcPlus").Window("SciCalc");


    Log.Message(isWindowTop(wCalc));



    Prints True if Calculator is top-level, False otherwise




5 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    You can use ActiveWindow method




    function isWindowTop(wnd)


    {


      var topWin = Sys.Desktop.ActiveWindow();


      return wnd.id == topWin.id;


    }



    Usage example:


    var wCalc = Sys.Process("CalcPlus").Window("SciCalc");


    Log.Message(isWindowTop(wCalc));



    Prints True if Calculator is top-level, False otherwise




  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    I think the index property shows you the order of enumeration, but I am not sure if it is actually sorted by z-order. Maybe someone else can answer that.
  • hlalumiere's avatar
    hlalumiere
    Regular Contributor
    Not anymore unfortunately... Microsoft got rid of the .ZOrder property a while back, to be replaced with methods BringToFront() and SendToBack(). You can use those to bring a particular window to front, but you cannot determine which window is currently toplevel.
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Hi Hugo Lalumiere,

    Thanks for ur immediate response. Is anything can be done with "index" property..?the index ll show wen u map the window with object spy....(under properties tab)
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Hi Gena,I m Using Vbscript.i converted ur code into vbscript...it works fine thnk you so much..