Hi,
Both OnOverlappingWindow and OnUnexpectedWindow events occur only when test code tries to interact with some UI element via the mouse or keyboard like the human user do. Events are not triggered if the test code just gets or sets some properies of the UI element. For example
window.Caption = "My modified caption"
line of code will never trigger these events because there is no interaction with the window here.
OnUnexpectedWindow event is triggered when test code tries to interact with some target UI element and this element (or the point that test code tries to interact with) is blocked with some other window in a way that this target UI element can not be activated or focused. Usually, those blocking windows are system modal or application modal message boxes.
As an example, if test code tries to execute
window.editBox.Keys("Hello world")
line of code which requires the window object to be activated (i.e. put in front of all other windows) and the editBox control to be focused, the OnUnexpectedWindow event will be triggered if the above actions cannot be performed because of system modal or application modal message box displayed.
OnOverlappedWindow event is triggered when test code tries to interact with some target UI element and this element (or the point that test code tries to interact with) is overlapped with some other window or control but this overapping control is not a modal one, but just overlaps the target control.
The baisc difference - in case of modal window, the blocked control cannot get focus until the blocking modal window is closed. In case of overlapping window - the blocked control can get focus without blocking window to be closed.
Hope this makes things to be more clear...