What's the difference between Close Application and Close Window - why does UiPath behave different after one or the other?


I stumbled upon the same problem as described in Dealing with "do you want to save" popup dialog. This thread contains the solution (use Close Window instead of Close Application), but I’d like to know why you have to use Close Window instead of Close Application.
Because it makes little sense to me. My sequence is like:

  1. do stuff
  2. open application notepad
  3. do stuff in notepad
  4. close notepad

-> as I opened notepad by using Open Application, I’d expect to close it with … well, Close Application. This does indeed close the application - as does Close Window - and in both cases the “do you want to save”-window pops up, but the click on the Don’t Save button only works after the Close Window activity.
Can anyone explain why?




I too stumbled on this problem. Ironically in the thread you linked someone else answered after you wrote this post:

This describes the behaviour, but leaves me unsatisfied, because there is no documentation about it. I couldn’t find any other topic on the forum and the doc for this activity doesn’t mention this either https://activities.uipath.com/lang-en/docs/close-application.

Can someone shed some light on this?



I don’t know if this helps but it certainly indicates that the two activities are quite different.

Close Window is a UI Automation activity (UIAutomation > Window) while Close Application is a System Activity (System > Application)

They have different properties which may suggest that you may have scenarios later on in your automation where one will be more suited than the other. (I am only starting off on my RPA journey so I have no idea where on when you would use one over the other, I also wondered about the difference so I thought I would share what I have found.)

Close Application has two exclusive properties namely Target.ClippingRegion and Target.Element while Close Window has one exclusive property called UseWindow.

The Target.Element option uses the UiElement variable returned by another activity and when you use the Target.Element option you cannot use the Selector property. You can also only use UiElement variables.

The UseWindow property only accepts Window variables.

(Now the next question is what is the difference between a Window variable and a UiElement variable? :grinning: but not tonight!)

Sometimes applications uses more than one window, like a website can use a popup for example, so you have the option to only close a child window with Close Window or the whole app using Close Application.