If you disconnect and let the bot run then it will else if you lock or minimize the vm while running it would fail as the screen is not active. For that case any UI Activity would fail. You have to disconnect then it can take .
You can use the Take Screenshot activity in the exception block or use the global exception handler to catch unexpected issues. Whenever an exception occurs it will take a screenshot and save it in the given folder.
I had the same issue few days before, if you specify the area of which you want to take the screenshot in the take screenshot activity it won’t work. Just drag and drop the take screenshot activity.
The only thing here is it will capture the whole screen and it will save it as you have specified within the screenshot activity
As you can see from the image above I am capturing a screenshot of my file explorer and have not indicated what area to take so it captures the whole screen. This perfectly works in unattended mode and under a lockscreen. Tested and verified