Advertisement
ZxkH

Test bot Iteration #7

Feb 4th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | Source Code | 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, 100, 100, 20)
  9. $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 130, 100, 20)
  10. $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 160, 100, 20)
  11. $optionCheckbox[3] = GUICtrlCreateCheckbox("Camera Turning", 10, 190, 120, 20)
  12. $optionCheckbox[4] = GUICtrlCreateCheckbox("Target Closest", 10, 220, 100, 20)
  13. $optionCheckbox[5] = GUICtrlCreateCheckbox("Pickup Items", 10, 250, 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.  
  59. $appWindow = WinGetHandle("AsdaGlobal")
  60. If $appWindow = 0 Then
  61. MsgBox(16, "Error", "Failed to find the target application window.")
  62. Return
  63. EndIf
  64.  
  65. While $isRunning
  66. =If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  67. ; Clicking option selected
  68. $coords = PixelSearch(1110, 642, 360, 110, 0x5A2568, 40)
  69. If Not @error Then
  70. MouseClick("left", $coords[0], $coords[1], 2, 1)
  71. Sleep(700)
  72. Else
  73. ; Turn camera 45 degrees
  74. MouseMove(590, 420)
  75. MouseDown("right")
  76. MouseMove(690, 420)
  77. MouseUp("right")
  78. EndIf
  79.  
  80. ; Adjusted pixel search logic
  81. $color = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xB3111E, 40)
  82. If IsArray($color) Then
  83. MouseClick("left 2", $color[0], $color[1])
  84. Sleep(100) ; Add a delay after the click
  85. EndIf
  86. If GUICtrlRead($optionCheckbox[1]) = $GUI_CHECKED Then
  87. ; Skills option selected
  88. Send("1")
  89. Sleep(100)
  90. Send("3")
  91. Sleep(100)
  92. Send("1")
  93. Sleep(100)
  94. Send("3")
  95. Sleep(100)
  96. EndIf
  97.  
  98. If GUICtrlRead($optionCheckbox[2]) = $GUI_CHECKED Then
  99. ; Auto Heal option selected
  100. $result = PixelSearch($200, $60, $270, $70, "3500", $tolerance) ; Replace with actual coordinates and number
  101.  
  102. If Not @error Then
  103. ; Found the target number within the specified area
  104. Send("{F1}") ; Activate F1 key for auto heal
  105. Sleep(1000)
  106. EndIf
  107. EndIf
  108.  
  109. If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  110. ; Camera Turning option selected
  111. MouseMove(590, 420) ; Move to the first set of coordinates
  112. Sleep(50) ; Wait for the mouse to move
  113. MouseMove(690, 420) ; Move to the second set of coordinates
  114. Sleep(50) ; Wait for the mouse to move
  115. EndIf
  116.  
  117. If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  118. ; Target Closest option selected
  119. Send("{TAB 5}") ; Presses the Tab key 5 times.
  120. Sleep(100)
  121. EndIf
  122. Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  123. WEnd
  124.  
  125. If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  126. PickupStuff($times)
  127. For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  128. Send("2")
  129. Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  130. Next
  131. EndIf
  132.  
  133. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement