Advertisement
ZxkH

Bot Iteration #12

Feb 6th, 2024
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 6.66 KB | Source Code | 0 0
  1. #include <GUIConstantsEx.au3>
  2.  
  3. Global $mainWindow, $optionCheckbox[8], $isRunning = False, $monitoringActive = False, $autoClickerActive = False
  4. Global $autoClickerDelay = 1000 ; Default delay for autoclicker (milliseconds)
  5. Global Const $monitoringAreaLeft = 520, $monitoringAreaTop = 460, $monitoringAreaRight = 760, $monitoringAreaBottom = 500
  6.  
  7. $mainWindow = GUICreate("AutoIt Automation", 300, 330)
  8.  
  9. $optionCheckbox[0] = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  10. $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  11. $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  12. $optionCheckbox[3] = GUICtrlCreateCheckbox("Target Closest", 10, 100, 120, 20)
  13. $optionCheckbox[4] = GUICtrlCreateCheckbox("Pickup Items", 10, 130, 100, 20)
  14. $optionCheckbox[5] = GUICtrlCreateCheckbox("Digging", 10, 160, 100, 20)
  15. $optionCheckbox[6] = GUICtrlCreateCheckbox("Monitor", 10, 190, 100, 20)
  16. $optionCheckbox[7] = GUICtrlCreateCheckbox("AutoClicker", 10, 220, 100, 20)
  17.  
  18. $btnStartStop = GUICtrlCreateButton("Start/Stop", 10, 270, 100, 30)
  19. $btnExit = GUICtrlCreateButton("Exit", 230, 270, 60, 30)
  20.  
  21. ; GUI for autoclicker settings
  22. $autoClickerWindow = GUICreate("AutoClicker Settings", 200, 120, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_CAPTION))
  23. GUICtrlCreateLabel("Delay (ms):", 10, 10, 100, 20)
  24. $inpDelay = GUICtrlCreateInput("1000", 110, 10, 60, 20)
  25. $btnAutoClickerStartStop = GUICtrlCreateButton("Start", 10, 50, 80, 30)
  26. $btnAutoClickerExit = GUICtrlCreateButton("Exit", 110, 50, 80, 30)
  27. GUISetState(@SW_HIDE, $autoClickerWindow)
  28.  
  29. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  30.  
  31. GUISetState(@SW_SHOW, $mainWindow)
  32.  
  33. While 1
  34.     $msg = GUIGetMsg()
  35.     Switch $msg
  36.         Case $GUI_EVENT_CLOSE, $btnExit, $btnAutoClickerExit
  37.             Exit
  38.         Case $btnStartStop
  39.             If Not _IsChecked($optionCheckbox) Then
  40.                 MsgBox(48, "Error", "Please select at least one option.")
  41.             Else
  42.                 $isRunning = Not $isRunning
  43.                 If $isRunning Then
  44.                     GUICtrlSetData($btnStartStop, "Stop")
  45.                     StartAutomation()
  46.                 Else
  47.                     MsgBox(64, "Stop", "Stopping automation.")
  48.                     ; Add logic to stop automation tasks
  49.                     GUICtrlSetData($btnStartStop, "Start")
  50.                 EndIf
  51.             EndIf
  52.         Case $optionCheckbox[7] ; Autoclicker checkbox
  53.             If GUICtrlRead($optionCheckbox[7]) = $GUI_CHECKED Then
  54.                 GUISetState(@SW_SHOW, $autoClickerWindow)
  55.             Else
  56.                 GUISetState(@SW_HIDE, $autoClickerWindow)
  57.                 $autoClickerActive = False
  58.             EndIf
  59.         Case $btnAutoClickerStartStop
  60.             If GUICtrlRead($btnAutoClickerStartStop) = "Start" Then
  61.                 GUICtrlSetData($btnAutoClickerStartStop, "Stop")
  62.                 $autoClickerActive = True
  63.                 $autoClickerDelay = GUICtrlRead($inpDelay)
  64.                 StartAutoClicker()
  65.             Else
  66.                 GUICtrlSetData($btnAutoClickerStartStop, "Start")
  67.                 $autoClickerActive = False
  68.             EndIf
  69.     EndSwitch
  70. WEnd
  71.  
  72. Func _IsChecked($checkboxArray)
  73.     For $i = 0 To UBound($checkboxArray) - 1
  74.         If GUICtrlRead($checkboxArray[$i]) = $GUI_CHECKED Then Return True
  75.     Next
  76.     Return False
  77. EndFunc
  78.  
  79. Func StartAutomation()
  80.     Local $appWindow, $coords, $result, $tolerance = 10 ; Define tolerance here
  81.  
  82. $appWindow = WinGetHandle("AsdaGlobal")
  83.     If $appWindow = 0 Then
  84.         MsgBox(16, "Error", "Failed to find the target application window.")
  85.         Return
  86.     EndIf
  87.  
  88.     ; Activate the application window
  89.     WinActivate($appWindow)
  90.  
  91.     ; Start monitoring if the monitoring checkbox is checked
  92.     If GUICtrlRead($optionCheckbox[6]) = $GUI_CHECKED Then
  93.         $monitoringActive = True
  94.         StartMonitoring()
  95.     EndIf
  96.  
  97.     While $isRunning
  98.         ; Add your automation logic here
  99.        
  100.         If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  101.             ; Clicking option selected
  102.             $coords = PixelSearch(1110, 642, 360, 110, 0x6A140A, 40)
  103.             If Not @error Then
  104.                 MouseClick("left", $coords[0], $coords[1], 2, 1)
  105.                 Sleep(700)
  106.             EndIf
  107.         EndIf
  108.  
  109.         If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  110.             ; Target Closest option selected
  111.             Send("{TAB 5}") ; Presses the Tab key 5 times.
  112.             Sleep(100)
  113.         EndIf
  114.  
  115.         If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  116.             ; Pickup Items option selected
  117.             For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  118.                 Send("2")
  119.                 Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  120.             Next
  121.         EndIf
  122.  
  123.         If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  124.             ; Digging option selected
  125.             Send("1")
  126.             Sleep(7000) ; Wait 7 seconds
  127.             Send("2")
  128.             Sleep(200)
  129.             Send("1")
  130.             Sleep(200)
  131.             Send("2")
  132.         EndIf
  133.  
  134.         Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  135.     WEnd
  136. EndFunc
  137.  
  138. Func StartMonitoring()
  139.     While $monitoringActive
  140.         ; Check for the appearance of the box with options in the specified area
  141.         If PixelSearchBox($monitoringAreaLeft, $monitoringAreaTop, $monitoringAreaRight, $monitoringAreaBottom) Then
  142.             ; Found the box, double left-click to select the reddish orange option
  143.             MouseClick("left", $coords[0], $coords[1], 2, 0)
  144.             Sleep(100)
  145.             MouseClick("left", $coords[0], $coords[1], 2, 0)
  146.             Sleep(100)
  147.             Send("{ENTER}")
  148.             Sleep(500)
  149.             Send("Sorry I'm busy atm 2 minutes", 35) ; Type the message with a delay of 35ms between each keystroke
  150.             Sleep(100) ; Wait 100ms before pressing enter again
  151.             Send("{ENTER}")
  152.         EndIf
  153.         Sleep(1000)
  154.     WEnd
  155. EndFunc
  156.  
  157. Func PixelSearchBox($left, $top, $right, $bottom)
  158.     ; Adjust the search area to the specified coordinates
  159.     Local $boxCoords = PixelSearch($left, $top, $right, $bottom, 0xFFFFFF, 10)
  160.     If Not @error Then
  161.         ; Found the box, return true
  162.         $coords = $boxCoords
  163.         Return True
  164.     EndIf
  165.     ; Box not found
  166.     Return False
  167. EndFunc
  168.  
  169. Func PanicButton()
  170.     ; Add the logic for the panic button action here
  171.     Exit
  172. EndFunc
  173.  
  174. Func StartAutoClicker()
  175.     While $autoClickerActive
  176.         MouseClick("left") ; Perform a left click
  177.         Sleep($autoClickerDelay) ; Delay between clicks
  178.     WEnd
  179. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement