Advertisement
ZxkH

Bot Iteration #8.2

Feb 6th, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 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. $optionCheckbox[0] = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  8. $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  9. $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  10. $optionCheckbox[3] = GUICtrlCreateCheckbox("Camera Turning", 10, 100, 120, 20)
  11. $optionCheckbox[4] = GUICtrlCreateCheckbox("Target Closest", 10, 130, 100, 20)
  12. $optionCheckbox[5] = GUICtrlCreateCheckbox("Pickup Items", 10, 160, 100, 20)
  13.  
  14. $btnStartStop = GUICtrlCreateButton("Start/Stop", 10, 220, 100, 30)
  15. $btnExit = GUICtrlCreateButton("Exit", 230, 220, 60, 30)
  16.  
  17. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  18.  
  19. GUISetState(@SW_SHOW)
  20.  
  21. While 1
  22. Switch GUIGetMsg()
  23. Case $GUI_EVENT_CLOSE, $btnExit
  24. Exit
  25.  
  26. Case $btnStartStop
  27. $isRunning = Not $isRunning
  28. If $isRunning Then
  29. If Not _IsChecked($optionCheckbox) Then
  30. MsgBox(48, "Error", "Please select at least one option.")
  31. $isRunning = False
  32. Else
  33. GUICtrlSetData($btnStartStop, "Stop")
  34. While $isRunning
  35. ; Add your automation logic here
  36. If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  37. ; Clicking option selected
  38. $coords = PixelSearch(1110, 642, 360, 110, 0x5A2568, 40)
  39. If Not @error Then
  40. MouseClick("left", $coords[0], $coords[1], 2, 1)
  41. Sleep(700)
  42. Else
  43. ; Turn camera 45 degrees
  44. MouseMove(590, 420)
  45. MouseDown("right")
  46. MouseMove(690, 420)
  47. MouseUp("right")
  48. EndIf
  49. EndIf
  50.  
  51. ; Adjusted pixel search logic
  52. $color = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xB3111E, 40)
  53. If IsArray($color) Then
  54. MouseClick("left 2", $color[0], $color[1])
  55. Sleep(100) ; Add a delay after the click
  56. EndIf
  57.  
  58. If GUICtrlRead($optionCheckbox[1]) = $GUI_CHECKED Then
  59. ; Skills option selected
  60. Send("1")
  61. Sleep(100)
  62. Send("3")
  63. Sleep(100)
  64. Send("1")
  65. Sleep(100)
  66. Send("3")
  67. Sleep(100)
  68. EndIf
  69.  
  70. If GUICtrlRead($optionCheckbox[2]) = $GUI_CHECKED Then
  71. ; Auto Heal option selected
  72. $result = PixelSearch(200, 60, 270, 70, "3500", $tolerance) ; Replace with actual coordinates and number
  73.  
  74. If Not @error Then
  75. ; Found the target number within the specified area
  76. Send("{F1}") ; Activate F1 key for auto heal
  77. Sleep(1000)
  78. EndIf
  79. EndIf
  80.  
  81. If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  82. ; Camera Turning option selected
  83. MouseMove(590, 420) ; Move to the first set of coordinates
  84. Sleep(50) ; Wait for the mouse to move
  85. MouseMove(690, 420) ; Move to the second set of coordinates
  86. Sleep(50) ; Wait for the mouse to move
  87. EndIf
  88.  
  89. If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  90. ; Target Closest option selected
  91. Send("{TAB 5}") ; Presses the Tab key 5 times.
  92. Sleep(100)
  93. EndIf
  94.  
  95. If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  96. ; Pickup Items option selected
  97. PickupStuff($times) ; Ensure $times is defined or passed as an argument
  98. For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  99. Send("2")
  100. Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  101. Next
  102. EndIf
  103.  
  104. Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  105. WEnd
  106. EndIf
  107. Else
  108. MsgBox(64, "Stop", "Stopping automation.")
  109. ; Add logic to stop automation tasks
  110. GUICtrlSetData($btnStartStop, "Start")
  111. EndIf
  112. EndSwitch
  113. WEnd
  114.  
  115. Func _IsChecked($checkboxArray)
  116. For $i = 0 To UBound($checkboxArray) - 1
  117. If GUICtrlRead($checkboxArray[$i]) = $GUI_CHECKED Then Return True
  118. Next
  119. Return False
  120. EndFunc
  121.  
  122. Func StartAutomation()
  123. Local $appWindow, $coords, $result
  124.  
  125. $appWindow = WinGetHandle("AsdaGlobal")
  126. If $appWindow = 0 Then
  127. MsgBox(16, "Error", "Failed to find the target application window.")
  128. Return
  129. EndIf
  130. ; Add your automation logic here
  131. EndFunc
  132.  
  133. Func PanicButton()
  134. ; Add the logic for the panic button action here
  135. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement