Advertisement
RyzaJr

[AHK] SWBF2 Restart

Dec 30th, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; This AHK script will automatically restart a Star Wars Battlfront 2 game using the Chat Reader and Admin Commander.exe.
  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. IP := "127.0.0.1"
  13. PORT := "4658"
  14. PASS := "YOURPASS"
  15. PROCESS := "ahk_exe Chat Reader and Admin Commander.exe"
  16. PROCESS_DIR := "C:\Misc\Programs\Chat Reader and Admin Commander"
  17. MESSAGE := "/say ATTENTION: The game will now restart."
  18. ADMIN_COMMAND := "/restart"
  19.  
  20. IfWinNotExist %PROCESS%
  21. {
  22.     Start()
  23.     Sleep 5000
  24.     Command()
  25. }
  26. else
  27. {
  28.     Command()
  29. }
  30. exit
  31.    
  32. Start()
  33. {
  34.     global
  35.     Run, Chat Reader and Admin Commander.exe, %PROCESS_DIR%
  36.     Sleep 5000
  37.     ControlSend, Edit2, %IP%, %PROCESS%
  38.     ControlSend, Edit3, %PORT%, %PROCESS%
  39.     ControlSend, Edit4, %PASS%, %PROCESS%
  40.     Sleep 2000
  41.     ControlClick, Button1, %PROCESS%
  42.     return
  43. }
  44.    
  45. Command()
  46. {
  47.     global
  48.     Clipboard := MESSAGE
  49.     Sleep 100
  50.     ControlSend, Edit6, ^v, %PROCESS%
  51.     ControlClick, Button3, %PROCESS%
  52.     Sleep 5000
  53.     ControlSend, Edit6, %ADMIN_COMMAND%, %PROCESS%
  54.     ControlClick, Button3, %PROCESS%
  55.     return
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement