Take screenshot not working in VM for 2 months


This is an issue related to screenshot. Earlier, in all our production bots, “Take screenshot” activity was working fine. But, for 2-3 months, it has stopped working. Tried to figure out but no help. Also, it works if i log into VM and minimises the screen but stops working as soon as I close the VM session from my side. Below is the error it throws:

Take screenshot: System.ComponentModel.Win32Exception (0x80004005): The handle is invalid
at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
at System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
at UiPath.Vision.UiImage.FromScreenRegion(Rectangle region)
at UiPath.Core.Image…ctor(Region screenRegion)

Any help would be highly appreciated.

Kind Regards,
Jyoti Bora


Check below post for your reference

Hope this helps you