Ryan I tried this out, as I suspected it wasn't that strange, just annoying.

It will work if you run your CF Server from the command line. 

You can also tick "allow service to interact with desktop" in the Log On tab
of the CF Server service properties (windows services).

It sort of makes sense - if a windows service is running on a server, and
there's no user logged in as such, then there's no desktop. But even if
there is a desktop available, you don't want to allow that sort of access by
default to all services. So there's that little tick :)

Cheers.

PS: Now that it works, that's a pretty neat concept. Nice.

-----Original Message-----
From: Ryan Duckworth [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 24 November 2005 6:48 PM
To: CF-Talk
Subject: java.awt.Robot Integration using createObject

I am getting a very strange result when I try to run some java screen
capture code from coldfusion.  When I simply run the .java file (#2
below)  I get a great .png screen shot stored here:
c:\screenshotFromJava.png

However, when I run the .cfm page (#1 below) using createObject I get
the same size .png file that is completely black.

To test this, compile the .java file below and place the .jar file in
the lib directory, then restart the cf service.

1.  ColdFusion page that calls the JAR
_________________________________________________________
<cfscript>
objMouse = createObject('java','robotScreenShot').init();
objMouse.screenShot("screenshotFromCF.png");
</cfscript>

Screen shot created here: c:\screenshotFromCF.png
_________________________________________________________

2.  .java file

import java.awt.Robot;
import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;

public class robotScreenShot {

public static void main(String[] args)
throws AWTException{
screenShot("screenshotFromJava.png");
}

public static void screenShot(String pngFileName)
throws AWTException{
  try {
      Robot r = new Robot();
      String pngPath = "c:\\" + pngFileName;
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      Rectangle rect = new Rectangle(0, 0, screenSize.width,
screenSize.height);
      BufferedImage img = r.createScreenCapture(rect);
      ImageIO.write(img, "png", new File(pngPath));

  } catch (AWTException e) {
      System.err.println(e);
  } catch (IOException e) {
      System.err.println(e);
  }
}
}

I would really appreciate any help.  Thanks,

Ryan Duckworth
913.486.2611



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225167
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to