0

I am running my java application as windows service and using java.awt.Robot class to capture screen, but I getting a black screen.

Code:

Rectangle rect = new Rectangle(1400, 900);
Robot robot = new Robot();
BufferedImage bufferImg = robot.createScreenCapture(rect);
ImageIO.write(bufferImg, JPG_FORMAT, saveLocation);
naveen
  • 72
  • 1
  • 9
  • 1
    Make sure you that when you go to the properties of the service (in `services.msc`), you have selected "connect interactively with the desktop" (or something like that) on the second tab – Ferrybig Nov 14 '17 at 07:29
  • @Ferrybig I am using tanuki wrapper to run my java as service `wrapper.ntservice.interactive=true` and I checked, that allow service to interact with the desktop, still getting a black screen. – naveen Nov 27 '17 at 10:06
  • According to the link in https://stackoverflow.com/questions/18891819/windows-service-screen-capture-returns-black-screen it seems like services are no longer allowed to interact with the user data, and ticking that box makes a virtual session for the service, instead of connecting to the session of the user. You could split up your service into a user program, and a backend service, so it can do its screen capture – Ferrybig Nov 27 '17 at 10:11
  • Thank you @Ferrybig, also referred [Session 0 isolation ] (https://stackoverflow.com/questions/46092870/suppress-windows7-messages-in-session-0) and my question is can take screen capture of all the session like 0,1..etc? – naveen Nov 27 '17 at 10:28
  • Any possibilities to overcome issue other than user program – naveen Nov 28 '17 at 02:37

0 Answers0