Close all application windows until the main application window

uiautomation

#1

I am using a desktop application and during the process I will click some buttons which will further open more windows. These windows are stacked one on top of the other.Whenever there is an exception I want to close all windows until i reach the main application window .

i have tried get active window and closing the window .But i didn’t find a way to determine if I have reached the main window. Please give your suggestions and thoughts on how to achieve this


#2

Hi,
may be this one is a bad solution :stuck_out_tongue: anyway…
The below solution work only if your sub windows are in sequence order
ex main window->subwnd1->subwnd2->subwnd3-… after exception use your logic to close window in reverse order or Alt+F4 accordingly .keep on closing the windows until you find some unique uiElement/image on “main window” using image exist or element exist which returns to Boolean value .Use that in condition to stop executing(closing windows) further.


#3

Since you said it is WIndows Application there should be isMDIChild attribute for each window including Parent (False).

If your task is to close all the Windows, do the following

  1. Get Active Windoow
  2. Pass the Output to GetAttribute Element and pass “isMDIChild”
  3. if true click cancel or Alt+F4 till you get false (loop 1-3 )
  4. if false you are at Main Window.

CloseWindows.xaml (9.9 KB)


#4

I normally just use the “Attach Window” then store it into a window variable. Do that for every window that is opened, then use “Close Window” with that variable. Just don’t close the main window variable, and you are only left with that window remaining.


#5

I like your idea.For attach window I guess you have to store every window selector and has to be done at development stage?

My idea was to implement on any open windows application irrespective of selectors.


#6

Right. When developing you would just need to make sure the selector is correct in the Attach Window to accommodate dynamic selectors.


#7

Yeah, I would go with your idea if the windows were not opened during the UiPath process you are running. Maybe that would be a useful way to get rid of all windows from a previous failed process run.


#8

I have a citrix application which im converting to desktop version, I can implement your idea to detect pop ups. Thanks.