Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P Runescape
- Index: com/speljohan/rsbot/gui/BotGUI.java
- ===================================================================
- --- com/speljohan/rsbot/gui/BotGUI.java (revision 282)
- +++ com/speljohan/rsbot/gui/BotGUI.java (working copy)
- @@ -9,9 +9,12 @@
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.EventQueue;
- +import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.MenuItem;
- import java.awt.PopupMenu;
- +import java.awt.Rectangle;
- +import java.awt.Robot;
- import java.awt.SystemTray;
- import java.awt.Toolkit;
- import java.awt.TrayIcon;
- @@ -21,6 +24,7 @@
- import java.awt.event.ComponentListener;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- +import java.awt.image.BufferedImage;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- @@ -32,6 +36,7 @@
- import java.lang.reflect.Method;
- import java.net.URL;
- import java.util.ArrayList;
- +import java.util.Calendar;
- import java.util.Collection;
- import java.util.EventListener;
- import java.util.HashMap;
- @@ -42,6 +47,7 @@
- import java.util.logging.Level;
- import java.util.logging.Logger;
- +import javax.imageio.ImageIO;
- import javax.swing.Box;
- import javax.swing.JButton;
- import javax.swing.JCheckBoxMenuItem;
- @@ -188,6 +194,8 @@
- Listener.blocked = !Listener.blocked;
- int height = userInputButton.getIcon().getIconHeight();
- userInputButton.setIcon(new SimpleIcon(height, height, Listener.blocked ? Color.red : Color.green, null));
- + } else if ("Save Screenshot".equals(command)) {
- + screenshot();
- } else if ("Select Randoms".equals(command)) {
- new RandomSelector(this, sh.getRandoms()).setVisible(true);
- } else if ("Select AntiBans".equals(command)) {
- @@ -407,7 +415,7 @@
- String[] titles = new String[] { "File", "Edit", "View", "Help" };
- String[][] elements = new String[][] {
- { "Run Script", "Stop Script", "-", "Pause/Resume Script", "ToggleF Block User Input",
- - "-", "Select Randoms", "Select AntiBans", "-", "Reload Plugins" },
- + "-", "Save Screenshot", "-", "Select Randoms", "Select AntiBans", "-", "Reload Plugins" },
- { "Accounts", "-", "ToggleF Use Less CPU", "ToggleF Hide Tray Icon"},
- debugItems.toArray(new String[debugItems.size()]),
- { "Forums", "Troubleshooting", "-", "About" }
- @@ -669,7 +677,36 @@
- log.info("Closing");
- System.exit(0);
- }
- +
- + private void screenshot(){
- + try
- + {
- + Robot robot = new Robot();
- + Rectangle rec = this.getBounds();
- + //765, 503 size of rsloader
- + rec.setSize(765, 503);
- + rec.setLocation(rec.x, rec.y+47);
- + BufferedImage image = robot.createScreenCapture(rec);
- +
- + Graphics2D g2d = image.createGraphics();
- + g2d.setColor(Color.black);
- + g2d.fill(new Rectangle(10, 459, 100, 15));
- + g2d.dispose();
- +
- + Calendar cal = Calendar.getInstance();
- + long name = cal.getTimeInMillis();
- +
- + //Save the screenshot as a png
- + File file;
- + file = new File(name+".png");
- + ImageIO.write(image, "png", file);
- + }
- + catch (Exception e){
- + log.warning("Screenshot failed!");
- + }
- +}
- +
- private void trayIcon(){
- if (SystemTray.isSupported()) {
Add Comment
Please, Sign In to add comment