Advertisement
ZxkH

Test bot Iteration #12.2.1

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