first working version

This commit is contained in:
joachim
2013-07-01 07:16:52 +02:00
commit c44e184480
3 changed files with 163 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
package de.lusiardi.mousemover;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Main {
private static boolean running = false;
private static Thread t = null;
public static void main(String[] args) throws AWTException,
InterruptedException {
JFrame main = new JFrame("ScreenSaverDisabler");
final JButton startStop = new JButton("Start");
startStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (running) {
running = false;
startStop.setText("Start");
} else {
running = true;
startStop.setText("Stop");
Runnable r = new Runnable() {
public void run() {
Robot r = null;
try {
r = new Robot();
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (running == true) {
r.keyPress(KeyEvent.VK_CONTROL);
r.keyRelease(KeyEvent.VK_CONTROL);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
t = new Thread(r);
t.start();
}
}
});
main.add(startStop);
main.pack();
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
main.setVisible(true);
}
}

BIN
src/main/resources/mm.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB