Results 1 to 5 of 5
- 04-18-2012, 08:29 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
every 10 min Capture a Screenshot in Java program
Hi All,
Im using the below program Capture a Screenshot in java program and connect to the database and store the Capture a Screenshot image in database.
but Iwant every 10 min randomly taken Capture a Screenshot in Java program and connect to database store the Capture a Screenshot image.
can we provide the related example code. please help.....
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.sql.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.sql.Timestamp;
public class JavaScreenCaptureUtil {
public static void writeImage(BufferedImage img, String fileLocation,
String extension) {
try {
BufferedImage bi = img;
File outputfile = new File(fileLocation);
ImageIO.write(bi, extension, outputfile);
} catch (IOException e) {
e.printStackTrace();
}
}
public static String createTimeStampStr() throws Exception {
Calendar mycalendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd_hhmmss");
String timeStamp = formatter.format(mycalendar.getTime());
return timeStamp;
}
public static void main(String args[]) throws Exception {
Robot robot = new Robot();
BufferedImage bi = robot.createScreenCapture(new Rectangle(1000, 700));
String fileNameToSaveTo = "C:/image_" + createTimeStampStr()+ ".PNG";
writeImage(bi, fileNameToSaveTo, "PNG");
Connection connection = null;
PreparedStatement psmnt = null;
FileInputStream fis;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance ();
String connectionURL = "jdbc:mysql://localhost:3306/discoff";
connection = DriverManager.getConnection(connectionURL, "root", "");
File image1 = new File(fileNameToSaveTo);
psmnt = connection.prepareStatement("insert into saveimage(id,image,datetime) values(?,?,?)");
psmnt.setInt(1, 1);
fis = new FileInputStream(image1);
psmnt.setBinaryStream(2, (InputStream) fis, (int) (image1.length()));
psmnt.setTimestamp(3,new Timestamp(System.currentTimeMillis()));
int s = psmnt.executeUpdate();
if (s > 0) {
System.out.println("Uploaded successfully !");
} else {
System.out.println("unsucessfull to upload image.");
}
}
catch (Exception ex) {
System.out.println("Found some error : " + ex);
} finally {
connection.close();
psmnt.close();
}
}
}
- 04-18-2012, 09:03 AM #2
Re: every 10 min Capture a Screenshot in Java program
Why do they call it rush hour when nothing moves? - Robin Williams
- 04-18-2012, 09:28 AM #3
Re: every 10 min Capture a Screenshot in Java program
Copying code from the net rarely helps, unless you take the time to learn enough Java to understand what the code actually does.
It's also unethical to post someone else's code on a public forum without attributing it to its original author.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-18-2012, 11:47 AM #4
Re: every 10 min Capture a Screenshot in Java program
And, it's extremely unethical to abandon a forum thread and start another with the same question.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-18-2012, 11:49 AM #5
Re: every 10 min Capture a Screenshot in Java program
Cross posted on the floral subcontinent site that we don't like to name because of their really, really bad content.
http ://www.[removed].net/answers/viewqa/Java-Beginners/25264-how-can-write-the-program-for-every-10-min-randomly-taken-Capture-a-Screenshot-in-Java-program-and-connect-to-database-store-the-Capture-a-Screenshot-image-.html
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Taking a screenshot and redisplaying it
By aprop in forum New To JavaReplies: 3Last Post: 03-03-2012, 09:24 PM -
Taking screenshot using java robot class not woring when pc is locked.
By sagngh8 in forum New To JavaReplies: 2Last Post: 05-22-2011, 08:56 AM -
cant use Command Prompt to run Java App (with screenshot)
By LongTTH in forum New To JavaReplies: 3Last Post: 05-03-2011, 03:24 AM -
Capturing a screenshot of a another pc?
By chyrl in forum Advanced JavaReplies: 9Last Post: 06-08-2010, 05:07 PM -
Get screenshot(picture) of own pc
By shekhar2010 in forum New To JavaReplies: 5Last Post: 01-24-2010, 03:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks