Advertisement
RyzaJr

[AHK] SWBF2 Reboot

Dec 30th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; This AHK script will automatically reboot a Star Wars Battlfront 2 server running in GameRanger.
  2.  
  3. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  4. #Warn  ; Enable warnings to assist with detecting common errors.
  5. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  6. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  7. #singleinstance force   ;Forces the script to be replaced by the new one if u try to re run a new instance
  8.  
  9. ;#NoTrayIcon
  10. SetTitleMatchMode, 2
  11.  
  12. MANAGER := "ahk_class SWBF2SERVERMANAGER"
  13. GAMERANGER := "ahk_exe GameRanger.exe"
  14. MESSAGE := "ATTENTION: The server will now reboot."
  15.  
  16. IfWinExist %MANAGER%
  17. {
  18.     Reboot()
  19. }
  20. else
  21. {
  22.     KillReboot()
  23. }
  24. exit
  25.  
  26. Reboot()
  27. {
  28.     global
  29.     ControlClick, Button40, %MANAGER%
  30.     Sleep 5000
  31.     ControlClick, Button1, Question
  32.     Sleep 5000
  33.     ControlClick, Button48, %MANAGER%
  34.     Sleep 5000
  35.     Message()
  36.     Sleep 2000
  37.     ControlClick, Button1, %GAMERANGER%
  38.     Sleep 5000
  39.     ControlClick, Button40, %MANAGER%
  40.     return
  41. }
  42.  
  43. KillReboot()
  44. {
  45.     global
  46.     Run, %comspec% /c taskkill /f /im BattlefrontII.exe, , hide
  47.     Sleep 5000
  48.     Message()
  49.     Sleep 2000
  50.     ControlClick, Button1, %GAMERANGER%
  51.     Sleep 5000
  52.     ControlClick, Button40, %MANAGER%
  53.     return
  54. }
  55.  
  56. Message()
  57. {
  58.     global
  59.     ControlClick, RichEdit20W2, %GAMERANGER%
  60.     Clipboard := MESSAGE
  61.     Sleep 100
  62.     ControlSend, RichEdit20W2, ^v, %GAMERANGER%
  63.     Sleep 2000
  64.     ControlSend, RichEdit20W2, {Enter}, %GAMERANGER%
  65.     return
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement