ZxkH

Bot Iteration #9

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