Guest User

AutoBR v0.2

a guest
Feb 23rd, 2015
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.17 KB | None | 0 0
  1. #include <GUIConstants.au3>
  2. #include <Misc.au3>
  3.  
  4. HotKeySet("{F1}", "BR_Hotkey")
  5. HotKeySet("{F2}", "BR_Start")
  6.  
  7. Global $hotkey = False
  8.  
  9. GUICreate("AutoBR v0.2", 200, 150)
  10.  
  11. Local $button_learn = GUICtrlCreateButton("Learn", 10, 10, 180, 30)
  12. Local $button_start = GUICtrlCreateButton("Start (F2)", 10, 50, 180, 30)
  13. Local $button_help = GUICtrlCreateButton("?", 160, 110, 30, 30)
  14.  
  15. GUISetState()
  16.  
  17. While True
  18.     Local $msg = GUIGetMsg()
  19.     Switch ($msg)
  20.         Case $button_learn
  21.             BR_Learn()
  22.         Case $button_start
  23.             BR_Start()
  24.         Case $button_help
  25.             ShellExecute("http://www.reddit.com/r/h1z1/comments/2wtp5u/script_battle_royale_autoconnector/")
  26.         Case $GUI_EVENT_CLOSE
  27.             Exit
  28.     EndSwitch
  29. WEnd
  30.  
  31. Func BR_Hotkey()
  32.     $hotkey = True
  33. EndFunc
  34.  
  35. Func BR_Learn()
  36.     While True
  37.         Sleep(1)
  38.         ToolTip("Make sure the 'Play Battle Royale' button is greyed out." & @CRLF & "Move your mouse over the button and press F1.")
  39.         If ($hotkey) Then
  40.             Local $pos = MouseGetPos()
  41.             MouseMove(0, 0, 0)
  42.             Local $checksum = PixelChecksum($pos[0] - 25, $pos[1] - 5, $pos[0] + 25, $pos[1] + 5)
  43.             IniWrite("config.ini", "config", "br_a_x", $pos[0])
  44.             IniWrite("config.ini", "config", "br_a_y", $pos[1])
  45.             IniWrite("config.ini", "config", "br_a_c", $checksum)
  46.             $hotkey = False
  47.             ExitLoop
  48.         EndIf
  49.     WEnd
  50.     While True
  51.         Sleep(1)
  52.         ToolTip("Do not move your mouse now." & @CRLF & "Waiting for button to change it's color.")
  53.         Local $newcheck = PixelChecksum($pos[0] - 25, $pos[1] - 5, $pos[0] + 25, $pos[1] + 5)
  54.         If ($checksum <> $newcheck) Then
  55.             Click($pos[0], $pos[1])
  56.             ExitLoop
  57.         EndIf
  58.     WEnd
  59.     While True
  60.         Sleep(1)
  61.         ToolTip("Now point at your characters name and press F1.")
  62.         If ($hotkey) Then
  63.             Local $pos = MouseGetPos()
  64.             IniWrite("config.ini", "config", "br_b_x", $pos[0])
  65.             IniWrite("config.ini", "config", "br_b_y", $pos[1])
  66.             $hotkey = False
  67.             ExitLoop
  68.         EndIf
  69.     WEnd
  70.     While True
  71.         Sleep(1)
  72.         ToolTip("Now point at the 'Play' button and press F1.")
  73.         If ($hotkey) Then
  74.             Local $pos = MouseGetPos()
  75.             IniWrite("config.ini", "config", "br_c_x", $pos[0])
  76.             IniWrite("config.ini", "config", "br_c_y", $pos[1])
  77.             $hotkey = False
  78.             ExitLoop
  79.         EndIf
  80.     WEnd
  81.     MsgBox(0, "Done!", "Go back to H1Z1 main menu and start the program by pressing F2.")
  82. EndFunc
  83.  
  84. Func BR_Start()
  85.     If (FileExists("config.ini")) Then
  86.         Local $x = IniRead("config.ini", "config", "br_a_x", "")
  87.         Local $y = IniRead("config.ini", "config", "br_a_y", "")
  88.         Local $checksum = IniRead("config.ini", "config", "br_a_c", "")
  89.         MouseMove(0, 0, 0)
  90.         While True
  91.             If (PixelChecksum($x - 25, $y - 5, $x + 25, $y + 5) <> $checksum) Then
  92.                 ExitLoop
  93.             EndIf
  94.         WEnd
  95.         Sleep(100)
  96.         Click(IniRead("config.ini", "config", "br_a_x", ""), IniRead("config.ini", "config", "br_a_y", ""))
  97.         Click(IniRead("config.ini", "config", "br_b_x", ""), IniRead("config.ini", "config", "br_b_y", ""))
  98.         Click(IniRead("config.ini", "config", "br_c_x", ""), IniRead("config.ini", "config", "br_c_y", ""))
  99.     Else
  100.         MsgBox(0, "Error", "Config not found. Please start with 'Learn'.")
  101.     EndIf
  102. EndFunc
  103.  
  104. Func Click($x, $y)
  105.     For $i = 0 To 3
  106.         MouseMove($x, $y, 3)
  107.         Sleep(5)
  108.         MouseClick("left")
  109.         Sleep(5)
  110.     Next
  111.     Sleep(10)
  112. EndFunc
Add Comment
Please, Sign In to add comment