import java.util.*; import java.util.zip.*; import java.util.List; import java.util.regex.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; import javax.swing.table.*; import java.io.*; import java.net.*; import java.lang.reflect.*; import java.lang.ref.*; import java.lang.management.*; import java.security.*; import java.security.spec.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.imageio.*; import java.math.*; import javax.swing.event.AncestorListener; import javax.swing.event.AncestorEvent; import javax.swing.Timer; public class main { public static void main(String[] args) throws Exception { blinkScreenArea(new Rectangle(0, 0, 300, 200)); } // TODO: hide on mouse over static BlinkScreenArea blinkScreenArea(Rectangle r) { return new BlinkScreenArea(r).go(); } static class BlinkScreenArea { int count, max = 12; int delay = 150; BufferedImage img, img2; JWindow window; JLabel lbl; Rectangle area; BlinkScreenArea(Rectangle r) { try { // clip to screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize (); r = new Rectangle(screenSize).intersection(r); area = r; Robot robot = new Robot(); img = robot.createScreenCapture(r); img2 = changeBrightness(img, 2f); img = changeBrightness(img, 0.5f); } catch (Throwable __e) { throw __e instanceof RuntimeException ? (RuntimeException) __e : new RuntimeException(__e); }} BlinkScreenArea go() { SwingUtilities.invokeLater(new Runnable() { public void run() { try { // make JWindow window = new JWindow(); window.setBounds(area); lbl = new JLabel(new ImageIcon(img2)); window.add(lbl); window.setAlwaysOnTop(true); window.setVisible(true); installTimer(lbl, delay, new Runnable() { public void run() { try { step(); } catch (Exception __e) { throw __e instanceof RuntimeException ? (RuntimeException) __e : new RuntimeException(__e); }}}); } catch (Exception _e) { throw _e instanceof RuntimeException ? (RuntimeException) _e : new RuntimeException(_e); } } }); return this; } void step() { ++count; if (count > max) print("huh?"); else if (count == max) window.dispose(); // should stop timer too else lbl.setIcon(new ImageIcon((count & 1) == 0 ? img : img2)); } } static volatile StringBuffer local_log = new StringBuffer(); // not redirected static volatile StringBuffer print_log = local_log; // might be redirected, e.g. to main bot // in bytes - will cut to half that static volatile int print_log_max = 1024*1024; static volatile int local_log_max = 100*1024; static void print() { print(""); } // slightly overblown signature to return original object... static A print(A o) { String s = String.valueOf(o) + "\n"; StringBuffer loc = local_log; StringBuffer buf = print_log; int loc_max = print_log_max; if (buf != loc && buf != null) { print_append(buf, s, print_log_max); loc_max = local_log_max; } if (loc != null) print_append(loc, s, loc_max); System.out.print(s); return o; } static void print(long l) { print(String.valueOf(l)); } static void print(char c) { print(String.valueOf(c)); } static void print_append(StringBuffer buf, String s, int max) { synchronized(buf) { buf.append(s); max /= 2; if (buf.length() > max) try { int newLength = max/2; int ofs = buf.length()-newLength; String newString = buf.substring(ofs); buf.setLength(0); buf.append("[...] ").append(newString); } catch (Exception e) { buf.setLength(0); } } } static BufferedImage changeBrightness(BufferedImage src, float val) { return new RescaleOp(val, 0, null).filter(src, null); } // first delay = delay static void installTimer(JComponent component, Runnable r, int delay) { installTimer(component, r, delay, delay); } // first delay = delay static void installTimer(JFrame frame, int delay, Runnable r) { installTimer(frame.getRootPane(), r, delay, delay); } // first delay = delay static void installTimer(JComponent component, int delay, Runnable r) { installTimer(component, r, delay, delay); } static void installTimer(final JComponent component, final Runnable r, final int delay, final int firstDelay) { installTimer(component, r, delay, firstDelay, true); } static void installTimer(final JComponent component, final Runnable r, final int delay, final int firstDelay, final boolean repeats) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { final Timer timer = new Timer(delay, new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent _evt) { r.run(); }}); timer.setInitialDelay(firstDelay); timer.setRepeats(repeats); if (component.isShowing()) timer.start(); component.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { timer.start(); } public void ancestorRemoved(AncestorEvent event) { timer.stop(); } public void ancestorMoved(AncestorEvent event) { } }); } catch (Exception _e) { throw _e instanceof RuntimeException ? (RuntimeException) _e : new RuntimeException(_e); } } }); } }