Jack Posted July 11, 2013 Posted July 11, 2013 //BY USING THIS CODE YOU AGREE THAT NONE OF THE CODE WILL BE USED IN A MALICIOUS WAY. import java.awt.AWTException; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class ScreenCap { public ScreenCap() { } public void screenShot(String fileName, String destination) throws IOException, AWTException { try { Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); BufferedImage capture = new Robot().createScreenCapture(screenRect); File outputfile = new File(destination+fileName+".png"); ImageIO.write(capture, "png", outputfile); } catch (IOException | AWTException e) { e.printStackTrace(); } } } try { sc.screenShot("MyScreenShot", "C:\\Users\\<INSERT USERNAME HERE>\\OSBot\\"); } catch (IOException | AWTException e) { e.printStackTrace(); } 2
Ericthecmh Posted July 12, 2013 Posted July 12, 2013 (edited) Awesome thanks!! I was actually wondering how to do this earlier in the day :P. I'll test it and then integrate it into my remote access function for my essence mining script. Although... your second try-catch clause is a bit redundant... :P Edited July 12, 2013 by ericthecmh
Jack Posted July 12, 2013 Author Posted July 12, 2013 Awesome thanks!! I was actually wondering how to do this earlier in the day . I'll test it and then integrate it into my remote access function for my essence mining script. Although... your second try-catch clause is a bit redundant... The second one is how you access the screen shot in your main class. If you don't surround it with try/catch, it will crash your whole program.
ScorpioZ Posted July 12, 2013 Posted July 12, 2013 So if this was implemented to our client it would save a screeshot of the RS screen? as suggested here. Sweet. Nice snippet
Ericthecmh Posted July 12, 2013 Posted July 12, 2013 Awesome thanks!! I was actually wondering how to do this earlier in the day . I'll test it and then integrate it into my remote access function for my essence mining script. Although... your second try-catch clause is a bit redundant... The second one is how you access the screen shot in your main class. If you don't surround it with try/catch, it will crash your whole program. The only way the exception can be thrown is if one of the calls inside the screenShot method throws an exception, but it will be caught by the handler inside that method. Can you give me a scenario in which an exception fails to be caught by the handler inside screenShot method but will be caught by the outer one? I can't seem to think of one lol... maybe I'm just missing something :P. But yeah it's a really nice piece of code. Thanks for sharing Eric
Cyro Posted July 12, 2013 Posted July 12, 2013 nice i made one few days ago anyway thanks i would suggest you add something to change the file's name each time it saves, i usually just add the current time and date and time when file was saved e.g. "sceenshot2013-07-13 12 37 26 AM" this is how i do it SimpleDateFormat format = new SimpleDateFormat(yyyy-MM-dd HH mm ss a); Calender calender = Calender.getInstance(); File outputfile = new File(destination+fileName+format.format(calender.getTime())+".png"); this will help a lot of people
Doout Posted July 13, 2013 Posted July 13, 2013 try this BufferedImage capture = client.getColorPicker().getBufferedImage() no point in taking the whole screen and the client might not even be up. 1
Cloudnine Posted July 25, 2013 Posted July 25, 2013 use this to make a randoms data collector. snapshots and collects ids for the npcs/objects/etc.
Kenneh Posted August 3, 2013 Posted August 3, 2013 use this to make a randoms data collector. snapshots and collects ids for the npcs/objects/etc. Your sig bothers me. public class Haters { public void handle(String name) { switch(name) { case "Kati": log("Gg."); System.exit(0); break; case "XavierM": log("Your scripts are overpriced."); break; case "Led Zeppelin": log("Post whore."); break; default: log("This script isn't for you."); break; } } public void log(String text) { System.out.println(text); } public static void main(String... args) { Haters haters = new Haters(); haters.handle(client.getBot().getUsername()); } }