前言
因为我这是单独给一个人发消息,所以直接生成快捷键到点定时发送就行了:
代码
public class SendMsg {
private static boolean b = true;
private static int num = -1;
public static void main(String[] args) {
try {
while(true){
/*
获取当前时间,判断是不是7点
*/
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
String now = formatter.format(new Date());
System.out.println(now);
if ("07:00".equals(now) && b){
Robot robot = new Robot();
//按下win键
robot.keyPress(KeyEvent.VK_WINDOWS);
robot.keyRelease(KeyEvent.VK_WINDOWS