Advertisement
ZxkH

Test

Feb 7th, 2024 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <StaticConstants.au3>
  5. #include <WindowsConstants.au3>
  6.  
  7. Opt("GUIOnEventMode", 1)
  8.  
  9. Global $mainWindow, $autoClickerWindow, $optionCheckbox[8], $btnStartStop, $btnExit, $inpDelay, $btnAutoClickerStartStop, $btnAutoClickerExit
  10. Global $isRunning = False, $autoClickerActive = False, $autoClickerDelay = 1000
  11.  
  12. $mainWindow = GUICreate("AutoIt Automation", 300, 330)
  13. GUISetOnEvent($GUI_EVENT_CLOSE, "CloseScript")
  14.  
  15. $optionCheckbox[0] = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  16. $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  17. $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  18. $optionCheckbox[3] = GUICtrlCreateCheckbox("Target Closest", 10, 100, 120, 20)
  19. $optionCheckbox[4] = GUICtrlCreateCheckbox("Pickup Items", 10, 130, 100, 20)
  20. $optionCheckbox[5] = GUICtrlCreateCheckbox("Digging", 10, 160, 100, 20)
  21. $optionCheckbox[6] = GUICtrlCreateCheckbox("Monitor", 10, 190, 100, 20)
  22. $optionCheckbox[7] = GUICtrlCreateCheckbox("AutoClicker", 10, 220, 100, 20)
  23.  
  24. $btnStartStop = GUICtrlCreateButton("Start/Stop", 10, 270, 100, 30)
  25. $btnExit = GUICtrlCreateButton("Exit", 230, 270, 60, 30)
  26.  
  27. GUISetState(@SW_SHOW, $mainWindow)
  28.  
  29. While 1
  30. $msg = GUIGetMsg()
  31. Switch $msg
  32. Case $GUI_EVENT_CLOSE, $btnExit
  33. CloseScript()
  34. Case $btnStartStop
  35. ToggleAutomation()
  36. Case $optionCheckbox[7] ; Autoclicker checkbox
  37. ToggleAutoClickerGUI()
  38. EndSwitch
  39. WEnd
  40.  
  41. Func CloseScript()
  42. Exit
  43. EndFunc
  44.  
  45. Func ToggleAutomation()
  46. If Not _IsChecked($optionCheckbox) Then
  47. MsgBox(48, "Error", "Please select at least one option.")
  48. Else
  49. $isRunning = Not $isRunning
  50. If $isRunning Then
  51. GUICtrlSetData($btnStartStop, "Stop")
  52. StartAutomation()
  53. Else
  54. MsgBox(64, "Stop", "Stopping automation.")
  55. ; Add logic to stop automation tasks
  56. GUICtrlSetData($btnStartStop, "Start")
  57. EndIf
  58. EndIf
  59. EndFunc
  60.  
  61. Func StartAutomation()
  62. Local $appWindow, $coords, $result, $tolerance = 10 ; Define tolerance here
  63.  
  64. While $isRunning
  65. If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  66. ; Clicking option selected
  67. $coords = PixelSearch(1110, 642, 360, 110, 0x6A140A, 40)
  68. If Not @error Then
  69. MouseClick("left", $coords[0], $coords[1], 2, 1)
  70. Sleep(700)
  71. EndIf
  72. EndIf
  73.  
  74. If GUICtrlRead($optionCheckbox[1]) = $GUI_CHECKED Then
  75. ; Skills option selected
  76. ; Add skills logic here
  77. EndIf
  78.  
  79. If GUICtrlRead($optionCheckbox[2]) = $GUI_CHECKED Then
  80. ; Auto Heal option selected
  81. ; Add auto heal logic here
  82. EndIf
  83.  
  84. If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  85. ; Target Closest option selected
  86. ; Add target closest logic here
  87. EndIf
  88.  
  89. If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  90. ; Pickup Items option selected
  91. ; Add pickup items logic here
  92. EndIf
  93.  
  94. If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  95. ; Digging option selected
  96. ; Add digging logic here
  97. EndIf
  98.  
  99. If GUICtrlRead($optionCheckbox[6]) = $GUI_CHECKED Then
  100. ; Monitor option selected
  101. ; Add monitor logic here
  102. EndIf
  103.  
  104. Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  105. WEnd
  106. EndFunc
  107.  
  108. Func _IsChecked($checkboxArray)
  109. For $i = 0 To UBound($checkboxArray) - 1
  110. If GUICtrlRead($checkboxArray[$i]) = $GUI_CHECKED Then Return True
  111. Next
  112. Return False
  113. EndFunc
  114.  
  115. Func ToggleAutoClickerGUI()
  116. If GUICtrlRead($optionCheckbox[7]) = $GUI_CHECKED Then
  117. $autoClickerWindow = GUICreate("AutoClicker Settings", 200, 120, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_CAPTION))
  118. GUISetOnEvent($GUI_EVENT_CLOSE, "CloseAutoClickerGUI")
  119.  
  120. GUICtrlCreateLabel("Delay (ms):", 10, 10, 100, 20)
  121. $inpDelay = GUICtrlCreateInput("1000", 110, 10, 60, 20)
  122.  
  123. $btnAutoClickerStartStop = GUICtrlCreateButton("Start", 10, 50, 80, 30)
  124. GUICtrlSetOnEvent($btnAutoClickerStartStop, "ToggleAutoClicker")
  125.  
  126. $btnAutoClickerExit = GUICtrlCreateButton("Exit", 110, 50, 80, 30)
  127. GUICtrlSetOnEvent($btnAutoClickerExit, "CloseAutoClickerGUI")
  128.  
  129. GUISetState(@SW_SHOW, $autoClickerWindow)
  130. Else
  131. GUIDelete($autoClickerWindow)
  132. EndIf
  133. EndFunc
  134.  
  135. Func ToggleAutoClicker()
  136. $autoClickerActive = Not $autoClickerActive
  137. If $autoClickerActive Then
  138. GUICtrlSetData($btnAutoClickerStartStop, "Stop")
  139. $autoClickerDelay = GUICtrlRead($inpDelay)
  140. StartAutoClicker()
  141. Else
  142. GUICtrlSetData($btnAutoClickerStartStop, "Start")
  143. EndIf
  144. EndFunc
  145.  
  146. Func StartAutoClicker()
  147. While $autoClickerActive
  148. MouseClick("left") ; Perform a left click
  149. Sleep($autoClickerDelay) ; Delay between clicks
  150. WEnd
  151. EndFunc
  152.  
  153. Func CloseAutoClickerGUI()
  154. GUIDelete($autoClickerWindow)
  155. GUICtrlSetState($optionCheckbox[7], $GUI_UNCHECKED)
  156. $autoClickerActive = False
  157. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement