Advertisement
ZxkH

Iteration #8.1

Feb 4th, 2024
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 9.75 KB | None | 0 0
  1. #include <GUIConstantsEx.au3>
  2.  
  3. Global $mainWindow, $optionCheckbox[7], $isRunning = False
  4.  
  5. $mainWindow = GUICreate("AutoIt Automation", 300, 300)
  6.  
  7.  
  8. $optionCheckbox[0] = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  9. $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  10. $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  11. $optionCheckbox[3] = GUICtrlCreateCheckbox("Camera Turning", 10, 100, 120, 20)
  12. $optionCheckbox[4] = GUICtrlCreateCheckbox("Target Closest", 10, 130, 100, 20)
  13. $optionCheckbox[5] = GUICtrlCreateCheckbox("Pickup Items", 10, 160, 100, 20)
  14. ;;$optionCheckbox[6] = GUICtrlCreateCheckbox("HP Bar", 10, 280, 100, 20)
  15. ;;$optionCheckbox[7] = GUICtrlCreateCheckbox("HP Count", 10, 310, 100, 20)
  16.  
  17. $btnStart = GUICtrlCreateButton("Start", 10, 220, 100, 30)
  18. $btnStop = GUICtrlCreateButton("Stop", 120, 220, 100, 30)
  19. $btnExit = GUICtrlCreateButton("Exit", 230, 220, 60, 30)
  20.  
  21. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  22.  
  23. ; Adjusted pixel search logic
  24. $color = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x5A2568, 40)
  25. If IsArray($color) Then
  26.     MouseClick("left 4", $color[0], $color[1])
  27.     Sleep(100) ; Add a delay after the click
  28. EndIf
  29. GUISetState(@SW_SHOW)
  30.  
  31. While 1
  32.     Switch GUIGetMsg()
  33.         Case $GUI_EVENT_CLOSE, $btnExit
  34.             Exit
  35.         Case $btnStart
  36.             If Not _IsChecked($optionCheckbox) Then
  37.                 MsgBox(48, "Error", "Please select at least one option.")
  38.             Else
  39.                 $isRunning = True
  40.                 StartAutomation()
  41.             EndIf
  42.         Case $btnStop
  43.             $isRunning = False
  44.             MsgBox(64, "Stop", "Stopping automation.")
  45.             ; Add logic to stop automation tasks
  46.     EndSwitch
  47. WEnd
  48.  
  49. Func _IsChecked($checkboxArray)
  50.     For $i = 0 To UBound($checkboxArray) - 1
  51.         If GUICtrlRead($checkboxArray[$i]) = $GUI_CHECKED Then Return True
  52.     Next
  53.     Return False
  54. EndFunc
  55.  
  56. Func StartAutomation()
  57.     Local $appWindow, $coords, $result
  58.     Local $times = 3
  59.     Local $tolerance = 10
  60.  
  61.     $appWindow = WinGetHandle("AsdaGlobal")
  62.     If $appWindow = 0 Then
  63.         MsgBox(16, "Error", "Failed to find the target application window.")
  64.         Return
  65.     EndIf
  66.  
  67.     While $isRunning
  68.         If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  69.             ; Clicking option selected
  70.             $coords = PixelSearch(1110, 642, 360, 110, 0x5A2568, 40)
  71.             If Not @error Then
  72.                 MouseClick("left", $coords[0], $coords[1], 2, 1)
  73.                 Sleep(700)
  74.             Else
  75.                 ; Turn camera 45 degrees
  76.                 MouseMove(590, 420)
  77.                 MouseDown("right")
  78.                 MouseMove(690, 420)
  79.                 MouseUp("right")
  80.             EndIf
  81.         EndIf
  82.  
  83.         ; Adjusted pixel search logic
  84.         $color = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xB3111E, 40)
  85.         If IsArray($color) Then
  86.             MouseClick("left 2", $color[0], $color[1])
  87.             Sleep(100) ; Add a delay after the click
  88.         EndIf
  89.  
  90.         If GUICtrlRead($optionCheckbox[1]) = $GUI_CHECKED Then
  91.             ; Skills option selected
  92.             Send("1")
  93.             Sleep(100)
  94.             Send("3")
  95.             Sleep(100)
  96.             Send("1")
  97.             Sleep(100)
  98.             Send("3")
  99.             Sleep(100)
  100.         EndIf
  101.  
  102.         If GUICtrlRead($optionCheckbox[2]) = $GUI_CHECKED Then
  103.             ; Auto Heal option selected
  104.             $result = PixelSearch(200, 60, 270, 70, "3500", $tolerance) ; Replace with actual coordinates and number
  105.  
  106.             If Not @error Then
  107.                 ; Found the target number within the specified area
  108.                 Send("{F1}") ; Activate F1 key for auto heal
  109.                 Sleep(1000)
  110.             EndIf
  111.         EndIf
  112.  
  113.         If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  114.             ; Camera Turning option selected
  115.             MouseMove(590, 420) ; Move to the first set of coordinates
  116.             Sleep(50) ; Wait for the mouse to move
  117.             MouseMove(690, 420) ; Move to the second set of coordinates
  118.             Sleep(50) ; Wait for the mouse to move
  119.         EndIf
  120.  
  121.         If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  122.             ; Target Closest option selected
  123.             Send("{TAB 5}") ; Presses the Tab key 5 times.
  124.             Sleep(100)
  125.         EndIf
  126.  
  127.         If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  128.             ; Pickup Items option selected
  129.             PickupStuff($times) ; Ensure $times is defined or passed as an argument
  130.             For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  131.                 Send("2")
  132.                 Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  133.             Next
  134.         EndIf
  135.  
  136.         Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  137.     WEnd
  138. EndFunc#include <GUIConstantsEx.au3>
  139.  
  140. Global $mainWindow, $optionCheckbox[7], $isRunning = False
  141.  
  142. $mainWindow = GUICreate("AutoIt Automation", 300, 300)
  143.  
  144.  
  145. $optionCheckbox[0] = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  146. $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  147. $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  148. $optionCheckbox[3] = GUICtrlCreateCheckbox("Camera Turning", 10, 100, 120, 20)
  149. $optionCheckbox[4] = GUICtrlCreateCheckbox("Target Closest", 10, 130, 100, 20)
  150. $optionCheckbox[5] = GUICtrlCreateCheckbox("Pickup Items", 10, 160, 100, 20)
  151. ;;$optionCheckbox[6] = GUICtrlCreateCheckbox("HP Bar", 10, 280, 100, 20)
  152. ;;$optionCheckbox[7] = GUICtrlCreateCheckbox("HP Count", 10, 310, 100, 20)
  153.  
  154. $btnStart = GUICtrlCreateButton("Start", 10, 220, 100, 30)
  155. $btnStop = GUICtrlCreateButton("Stop", 120, 220, 100, 30)
  156. $btnExit = GUICtrlCreateButton("Exit", 230, 220, 60, 30)
  157.  
  158. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  159.  
  160. ; Adjusted pixel search logic
  161. $color = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x5A2568, 40)
  162. If IsArray($color) Then
  163.     MouseClick("left 4", $color[0], $color[1])
  164.     Sleep(100) ; Add a delay after the click
  165. EndIf
  166. GUISetState(@SW_SHOW)
  167.  
  168. While 1
  169.     Switch GUIGetMsg()
  170.         Case $GUI_EVENT_CLOSE, $btnExit
  171.             Exit
  172.         Case $btnStart
  173.             If Not _IsChecked($optionCheckbox) Then
  174.                 MsgBox(48, "Error", "Please select at least one option.")
  175.             Else
  176.                 $isRunning = True
  177.                 StartAutomation()
  178.             EndIf
  179.         Case $btnStop
  180.             $isRunning = False
  181.             MsgBox(64, "Stop", "Stopping automation.")
  182.             ; Add logic to stop automation tasks
  183.     EndSwitch
  184. WEnd
  185.  
  186. Func _IsChecked($checkboxArray)
  187.     For $i = 0 To UBound($checkboxArray) - 1
  188.         If GUICtrlRead($checkboxArray[$i]) = $GUI_CHECKED Then Return True
  189.     Next
  190.     Return False
  191. EndFunc
  192.  
  193. Func StartAutomation()
  194.     Local $appWindow, $coords, $result
  195.  
  196.     $appWindow = WinGetHandle("AsdaGlobal")
  197.     If $appWindow = 0 Then
  198.         MsgBox(16, "Error", "Failed to find the target application window.")
  199.         Return
  200.     EndIf
  201.  
  202.     While $isRunning
  203.         If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  204.             ; Clicking option selected
  205.             $coords = PixelSearch(1110, 642, 360, 110, 0x5A2568, 40)
  206.             If Not @error Then
  207.                 MouseClick("left", $coords[0], $coords[1], 2, 1)
  208.                 Sleep(700)
  209.             Else
  210.                 ; Turn camera 45 degrees
  211.                 MouseMove(590, 420)
  212.                 MouseDown("right")
  213.                 MouseMove(690, 420)
  214.                 MouseUp("right")
  215.             EndIf
  216.         EndIf
  217.  
  218.         ; Adjusted pixel search logic
  219.         $color = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xB3111E, 40)
  220.         If IsArray($color) Then
  221.             MouseClick("left 2", $color[0], $color[1])
  222.             Sleep(100) ; Add a delay after the click
  223.         EndIf
  224.  
  225.         If GUICtrlRead($optionCheckbox[1]) = $GUI_CHECKED Then
  226.             ; Skills option selected
  227.             Send("1")
  228.             Sleep(100)
  229.             Send("3")
  230.             Sleep(100)
  231.             Send("1")
  232.             Sleep(100)
  233.             Send("3")
  234.             Sleep(100)
  235.         EndIf
  236.  
  237.         If GUICtrlRead($optionCheckbox[2]) = $GUI_CHECKED Then
  238.             ; Auto Heal option selected
  239.             $result = PixelSearch(200, 60, 270, 70, "3500", $tolerance) ; Replace with actual coordinates and number
  240.  
  241.             If Not @error Then
  242.                 ; Found the target number within the specified area
  243.                 Send("{F1}") ; Activate F1 key for auto heal
  244.                 Sleep(1000)
  245.             EndIf
  246.         EndIf
  247.  
  248.         If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  249.             ; Camera Turning option selected
  250.             MouseMove(590, 420) ; Move to the first set of coordinates
  251.             Sleep(50) ; Wait for the mouse to move
  252.             MouseMove(690, 420) ; Move to the second set of coordinates
  253.             Sleep(50) ; Wait for the mouse to move
  254.         EndIf
  255.  
  256.         If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  257.             ; Target Closest option selected
  258.             Send("{TAB 5}") ; Presses the Tab key 5 times.
  259.             Sleep(100)
  260.         EndIf
  261.  
  262.         If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  263.             ; Pickup Items option selected
  264.             PickupStuff($times) ; Ensure $times is defined or passed as an argument
  265.             For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  266.                 Send("2")
  267.                 Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  268.             Next
  269.         EndIf
  270.  
  271.         Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  272.     WEnd
  273. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement