KurumiAria

MineCraft Server QMacro2014 auto reboot

Apr 15th, 2016
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //此程式碼適用於"按鍵精靈2014",需要新增伺服器開啟與電腦關閉捷徑
  2. timedelay = 105
  3. Dim TimeNow
  4. Do
  5.     Delay 1000
  6.     Call Time1
  7.     If TimeNow = "23:50"                //確定時間到23:50關閉server
  8.         //提醒
  9.     Call Cmd
  10.     Call Serveroff
  11.         //關閉server
  12.     Call Cmd
  13.     SayString "/stop"                   //輸入/stop 後關閉server
  14.     Delay 1000
  15.     KeyPress "Enter", 1
  16.     Delay 30000
  17.     RunApp "C:\Windows\System32\shutdown.exe /r /t 0"
  18.     EndScript                           //結束腳本
  19.     End If
  20. loop
  21.     //副程式
  22. Sub Cmd
  23.     hwnd = Plugin.Window.find(3,"C:\WINDOWS\system32\cmd.exe")
  24.     zhwnd = Plugin.Window.findex(hwnd, 0, "ConsoleWindowClass", 0)
  25.     TracePrint zhwnd
  26.     Call Plugin.Window.Active(zHwnd)    //點開cmd視窗
  27. End Sub
  28. Sub Time1 ()
  29.     h=Hour(time)
  30.     m=Minute(time)
  31.     s=Second(time)
  32.     TimeNow = h &":" & m
  33. End Sub
  34. Sub Serveroff
  35.     SayString "/say 伺服器自動重開機模式"
  36.     Delay 100
  37.     KeyPress "Enter", 1
  38.     SayString "/say 預計10分鐘內 自動開啟"
  39.     Delay 100
  40.     KeyPress "Enter", 1
  41.     timedelay = 105
  42.         for 10
  43.             SayString "/say 伺服器 "
  44.             KeyPress timedelay, 1
  45.             SayString " 秒後關閉"
  46.             KeyPress "Enter", 1
  47.             timedelay = timedelay - 1
  48.             SayString "/say 伺服器關閉 "
  49.             KeyPress "Enter", 1
  50.             Delay 1000
  51.         Next
  52.     SayString "/say 伺服器關閉 "
  53.     KeyPress "Enter", 1
  54. End Sub
Advertisement
Add Comment
Please, Sign In to add comment