A Win32 Framework application may open a modal window (ControlType Window, ClassName #32770). At least in the example I am facing, it has the same ProcessId as the main application.
Therefore, closing a popup that has been Control windowed is not possible using Close Current Window - Close Current Window just kills the whole process via SIGTERM (in this case, including the main application, because they share ProcessId). The popup has to be closed by other means (e.g. by sending an ESC keystroke).
However, that means self.window still points to the now closed popup. It is a WindowsElement object, whose item has a ProcessId of 0.
When you try to call Close current window later, you are therefore sending a SIGTERM to PID 0 (which is the idle process), which throws an OSError: [WinError 87] The parameter is incorrect.
The solution, obviously, is to re-take control of the main application after the popup has been closed. However, I wonder whether this deserves more documentation somewhere, or adding error messages to catch the case of attempting to close PID 0.
A Win32 Framework application may open a modal window (ControlType
Window
, ClassName#32770
). At least in the example I am facing, it has the same ProcessId as the main application.Therefore, closing a popup that has been
Control window
ed is not possible usingClose Current Window
-Close Current Window
just kills the whole process via SIGTERM (in this case, including the main application, because they share ProcessId). The popup has to be closed by other means (e.g. by sending anESC
keystroke).However, that means
self.window
still points to the now closed popup. It is aWindowsElement
object, whoseitem
has a ProcessId of0
.When you try to call
Close current window
later, you are therefore sending a SIGTERM to PID 0 (which is the idle process), which throws anOSError: [WinError 87] The parameter is incorrect
.The solution, obviously, is to re-take control of the main application after the popup has been closed. However, I wonder whether this deserves more documentation somewhere, or adding error messages to catch the case of attempting to close PID 0.
https://github.com/robocorp/rpaframework/blob/3853cf79bad37c1f881e950a88f3f304c5d4a58e/packages/windows/src/RPA/Windows/keywords/window.py#L328-L345