Advertisement
ZxkH

Iteration #14

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