Advertisement
ZxkH

remove

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