Advertisement
ZxkH

Test bot Iteration #12.1

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