Guest User

Untitled

a guest
Jun 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P Runescape
  3. Index: com/speljohan/rsbot/gui/BotGUI.java
  4. ===================================================================
  5. --- com/speljohan/rsbot/gui/BotGUI.java (revision 282)
  6. +++ com/speljohan/rsbot/gui/BotGUI.java (working copy)
  7. @@ -9,9 +9,12 @@
  8. import java.awt.Component;
  9. import java.awt.Dimension;
  10. import java.awt.EventQueue;
  11. +import java.awt.Graphics2D;
  12. import java.awt.Image;
  13. import java.awt.MenuItem;
  14. import java.awt.PopupMenu;
  15. +import java.awt.Rectangle;
  16. +import java.awt.Robot;
  17. import java.awt.SystemTray;
  18. import java.awt.Toolkit;
  19. import java.awt.TrayIcon;
  20. @@ -21,6 +24,7 @@
  21. import java.awt.event.ComponentListener;
  22. import java.awt.event.WindowAdapter;
  23. import java.awt.event.WindowEvent;
  24. +import java.awt.image.BufferedImage;
  25. import java.io.BufferedReader;
  26. import java.io.BufferedWriter;
  27. import java.io.File;
  28. @@ -32,6 +36,7 @@
  29. import java.lang.reflect.Method;
  30. import java.net.URL;
  31. import java.util.ArrayList;
  32. +import java.util.Calendar;
  33. import java.util.Collection;
  34. import java.util.EventListener;
  35. import java.util.HashMap;
  36. @@ -42,6 +47,7 @@
  37. import java.util.logging.Level;
  38. import java.util.logging.Logger;
  39.  
  40. +import javax.imageio.ImageIO;
  41. import javax.swing.Box;
  42. import javax.swing.JButton;
  43. import javax.swing.JCheckBoxMenuItem;
  44. @@ -188,6 +194,8 @@
  45. Listener.blocked = !Listener.blocked;
  46. int height = userInputButton.getIcon().getIconHeight();
  47. userInputButton.setIcon(new SimpleIcon(height, height, Listener.blocked ? Color.red : Color.green, null));
  48. + } else if ("Save Screenshot".equals(command)) {
  49. + screenshot();
  50. } else if ("Select Randoms".equals(command)) {
  51. new RandomSelector(this, sh.getRandoms()).setVisible(true);
  52. } else if ("Select AntiBans".equals(command)) {
  53. @@ -407,7 +415,7 @@
  54. String[] titles = new String[] { "File", "Edit", "View", "Help" };
  55. String[][] elements = new String[][] {
  56. { "Run Script", "Stop Script", "-", "Pause/Resume Script", "ToggleF Block User Input",
  57. - "-", "Select Randoms", "Select AntiBans", "-", "Reload Plugins" },
  58. + "-", "Save Screenshot", "-", "Select Randoms", "Select AntiBans", "-", "Reload Plugins" },
  59. { "Accounts", "-", "ToggleF Use Less CPU", "ToggleF Hide Tray Icon"},
  60. debugItems.toArray(new String[debugItems.size()]),
  61. { "Forums", "Troubleshooting", "-", "About" }
  62. @@ -669,7 +677,36 @@
  63. log.info("Closing");
  64. System.exit(0);
  65. }
  66. +
  67. + private void screenshot(){
  68. + try
  69. + {
  70. + Robot robot = new Robot();
  71. + Rectangle rec = this.getBounds();
  72. + //765, 503 size of rsloader
  73. + rec.setSize(765, 503);
  74. + rec.setLocation(rec.x, rec.y+47);
  75. + BufferedImage image = robot.createScreenCapture(rec);
  76. +
  77. + Graphics2D g2d = image.createGraphics();
  78. + g2d.setColor(Color.black);
  79. + g2d.fill(new Rectangle(10, 459, 100, 15));
  80. + g2d.dispose();
  81. +
  82. + Calendar cal = Calendar.getInstance();
  83. + long name = cal.getTimeInMillis();
  84. +
  85. + //Save the screenshot as a png
  86. + File file;
  87. + file = new File(name+".png");
  88. + ImageIO.write(image, "png", file);
  89.  
  90. + }
  91. + catch (Exception e){
  92. + log.warning("Screenshot failed!");
  93. + }
  94. +}
  95. +
  96. private void trayIcon(){
  97. if (SystemTray.isSupported()) {
Add Comment
Please, Sign In to add comment