Advertisement
ZxkH

Iteration 12.2

Feb 6th, 2024 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 14.31 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. main()
  25.  
  26. ; #include <GUIConstantsEx.au3>
  27.  
  28. Global $mainWindow, $optionCheckbox[8], $isRunning = False, $monitoringActive = False, $autoClickerActive = False
  29. Global $autoClickerDelay = 1000 ; Default delay for autoclicker (milliseconds)
  30. Global Const $monitoringAreaLeft = 520, $monitoringAreaTop = 460, $monitoringAreaRight = 760, $monitoringAreaBottom = 500
  31.  
  32. <link>$mainWindow</link> = GUICreate("AutoIt Automation", 300, 330)
  33.  
  34. <link>$optionCheckbox[0]</link> = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  35. <link>$optionCheckbox[1]</link> = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  36. <link>$optionCheckbox[2]</link> = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  37. <link>$optionCheckbox[3]</link> = GUICtrlCreateCheckbox("Target Closest", 10, 100, 120, 20)
  38. <link>$optionCheckbox[4]</link> = GUICtrlCreateCheckbox("Pickup Items", 10, 130, 100, 20)
  39. <link>$optionCheckbox[5]</link> = GUICtrlCreateCheckbox("Digging", 10, 160, 100, 20)
  40. <link>$optionCheckbox[6]</link> = GUICtrlCreateCheckbox("Monitor", 10, 190, 100, 20)
  41. <link>$optionCheckbox[7]</link> = GUICtrlCreateCheckbox("AutoClicker", 10, 220, 100, 20)
  42.  
  43. <link>$btnStartStop</link> = GUICtrlCreateButton("Start/Stop", 10, 270, 100, 30)
  44. <link>$btnExit</link> = GUICtrlCreateButton("Exit", 230, 270, 60, 30)
  45.  
  46. Global $autoClickerWindow, $inpDelay, $btnAutoClickerStartStop, $btnAutoClickerExit
  47.  
  48. <link>$autoClickerWindow</link> = GUICreate("AutoClicker Settings", 200, 120, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_CAPTION))
  49. GUICtrlCreateLabel("Delay (ms):", 10, 10, 100, 20)
  50. <link>$inpDelay</link> = GUICtrlCreateInput("1000", 110, 10, 60, 20)
  51. <link>$btnAutoClickerStartStop</link> = GUICtrlCreateButton("Start", 10, 50, 80, 30)
  52. <link>$btnAutoClickerExit</link> = GUICtrlCreateButton("Exit", 110, 50, 80, 30)
  53. GUISetState(@SW_HIDE, $autoClickerWindow)
  54. <link>$AutoClickerWindow</link> = 0
  55.  
  56. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  57.  
  58. GUISetState(@SW_SHOW, $mainWindow)
  59.  
  60. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  61.  
  62. GUISetState(@SW_SHOW, $mainWindow)
  63.  
  64. While 1
  65.     $msg = GUIGetMsg()
  66.     Switch $msg
  67.         Case $GUI_EVENT_CLOSE, $btnExit, $btnAutoClickerExit
  68.             Exit
  69.         Case $btnStartStop
  70.             If Not _IsChecked($optionCheckbox) Then
  71.                 MsgBox(48, "Error", "Please select at least one option.")
  72.             Else
  73.                 $isRunning = Not $isRunning
  74.                 If $isRunning Then
  75.                     GUICtrlSetData($btnStartStop, "Stop")
  76.                     StartAutomation()
  77.                 Else
  78.                     MsgBox(64, "Stop", "Stopping automation.")
  79.                     ; Add logic to stop automation tasks
  80.                     GUICtrlSetData($btnStartStop, "Start")
  81.                 EndIf
  82.             EndIf
  83.         Case $optionCheckbox[7] ; Autoclicker checkbox
  84.             If GUICtrlRead($optionCheckbox[7]) = $GUI_CHECKED Then
  85.                 GUISetState(@SW_SHOW, $autoClickerWindow)
  86.             Else
  87.                 GUISetState(@SW_HIDE, $autoClickerWindow)
  88.                 $autoClickerActive = False
  89.             EndIf
  90.         Case $btnAutoClickerStartStop
  91.             If GUICtrlRead($btnAutoClickerStartStop) = "Start" Then
  92.                 GUICtrlSetData($btnAutoClickerStartStop, "Stop")
  93.                 $autoClickerActive = True
  94.                 $autoClickerDelay = GUICtrlRead($inpDelay)
  95.                 StartAutoClicker()
  96.             Else
  97.                 GUICtrlSetData($btnAutoClickerStartStop, "Start")
  98.                 $autoClickerActive = False
  99.             EndIf
  100.     EndSwitch
  101. WEnd
  102.  
  103. Func StartAutomation()
  104.     Local $appWindow, $coords, $result, $tolerance = 10 ; Define tolerance here
  105.  
  106. $appWindow = WinGetHandle("AsdaGlobal")
  107.     If $appWindow = 0 Then
  108.         MsgBox(16, "Error", "Failed to find the target application window.")
  109.         Return
  110.     EndIf
  111.  
  112.     ; Activate the application window
  113.     WinActivate($appWindow)
  114.  
  115.     ; Start monitoring if the monitoring checkbox is checked
  116.     If GUICtrlRead($optionCheckbox[6]) = $GUI_CHECKED Then
  117.         $monitoringActive = True
  118.         StartMonitoring()
  119.     EndIf
  120.  
  121.     While $isRunning
  122.         ; Add your automation logic here
  123.  
  124.         If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  125.             ; Clicking option selected
  126.             $coords = PixelSearch(1110, 642, 360, 110, 0x6A140A, 40)
  127.             If Not @error Then
  128.                 MouseClick("left", $coords[0], $coords[1], 2, 1)
  129.                 Sleep(700)
  130.             EndIf
  131.         EndIf
  132.  
  133.         If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  134.             ; Target Closest option selected
  135.             Send("{TAB 5}") ; Presses the Tab key 5 times.
  136.             Sleep(100)
  137.         EndIf
  138.  
  139.         If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  140.             ; Pickup Items option selected
  141.             For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  142.                 Send("2")
  143.                 Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  144.             Next
  145.         EndIf
  146.  
  147.         If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  148.             ; Digging option selected
  149.             Send("1")
  150.             Sleep(7000) ; Wait 7 seconds
  151.             Send("2")
  152.             Sleep(200)
  153.             Send("1")
  154.             Sleep(200)
  155.             Send("2")
  156.         EndIf
  157.  
  158.         Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  159.     WEnd
  160. EndFunc
  161.  
  162. Func StartMonitoring()
  163.     While $monitoringActive
  164.         ; Check for the appearance of the box with options in the specified area
  165.         If PixelSearchBox($monitoringAreaLeft, $monitoringAreaTop, $monitoringAreaRight, $monitoringAreaBottom) Then
  166.             ; Found the box, double left-click to select the reddish orange option
  167.             MouseClick("left", $coords[0], $coords[1], 2, 0)
  168.             Sleep(100)
  169.             MouseClick("left", $coords[0], $coords[1], 2, 0)
  170.             Sleep(100)
  171.             Send("{ENTER}")
  172.             Sleep(500)
  173.             Send("Sorry I'm busy atm 2 minutes", 35) ; Type the message with a delay of 35ms between each keystroke
  174.             Sleep(100) ; Wait 100ms before pressing enter again
  175.             Send("{ENTER}")
  176.         EndIf
  177.         Sleep(1000)
  178.     WEnd
  179. EndFunc
  180.  
  181. Func PixelSearchBox($left, $top, $right, $bottom)
  182.     ; Adjust the search area to the specified coordinates
  183.     Local $boxCoords = PixelSearch($left, $top, $right, $bottom, 0xFFFFFF, 10)
  184.     If Not @error Then
  185.         ; Found the box, return true
  186.         $coords = $boxCoords
  187.         Return True
  188.     EndIf
  189.     ; Box not found
  190.     Return False
  191. EndFunc
  192.  
  193. Func PanicButton()
  194.     ; Add the logic for the panic button action here
  195.     Exit
  196. EndFunc
  197.  
  198. Func StartAutoClicker()
  199.     While $autoClickerActive
  200.         MouseClick("left") ; Perform a left click
  201.         Sleep($autoClickerDelay) ; Delay between clicks
  202.     WEnd
  203. EndFunc#include <GUIConstantsEx.au3>
  204.  
  205. Global $mainWindow, $optionCheckbox[8], $isRunning = False, $monitoringActive = False, $autoClickerActive = False
  206. Global $autoClickerDelay = 1000 ; Default delay for autoclicker (milliseconds)
  207. Global Const $monitoringAreaLeft = 520, $monitoringAreaTop = 460, $monitoringAreaRight = 760, $monitoringAreaBottom = 500
  208.  
  209. <link>$mainWindow</link> = GUICreate("AutoIt Automation", 300, 330)
  210.  
  211. <link>$optionCheckbox[0]</link> = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  212. <link>$optionCheckbox[1]</link> = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  213. <link>$optionCheckbox[2]</link> = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  214. <link>$optionCheckbox[3]</link> = GUICtrlCreateCheckbox("Target Closest", 10, 100, 120, 20)
  215. <link>$optionCheckbox[4]</link> = GUICtrlCreateCheckbox("Pickup Items", 10, 130, 100, 20)
  216. <link>$optionCheckbox[5]</link> = GUICtrlCreateCheckbox("Digging", 10, 160, 100, 20)
  217. <link>$optionCheckbox[6]</link> = GUICtrlCreateCheckbox("Monitor", 10, 190, 100, 20)
  218. <link>$optionCheckbox[7]</link> = GUICtrlCreateCheckbox("AutoClicker", 10, 220, 100, 20)
  219.  
  220. <link>$btnStartStop</link> = GUICtrlCreateButton("Start/Stop", 10, 270, 100, 30)
  221. <link>$btnExit</link> = GUICtrlCreateButton("Exit", 230, 270, 60, 30)
  222.  
  223. Global $autoClickerWindow, $inpDelay, $btnAutoClickerStartStop, $btnAutoClickerExit
  224.  
  225. <link>$autoClickerWindow</link> = GUICreate("AutoClicker Settings", 200, 120, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_CAPTION))
  226. GUICtrlCreateLabel("Delay (ms):", 10, 10, 100, 20)
  227. <link>$inpDelay</link> = GUICtrlCreateInput("1000", 110, 10, 60, 20)
  228. <link>$btnAutoClickerStartStop</link> = GUICtrlCreateButton("Start", 10, 50, 80, 30)
  229. <link>$btnAutoClickerExit</link> = GUICtrlCreateButton("Exit", 110, 50, 80, 30)
  230. GUISetState(@SW_HIDE, $autoClickerWindow)
  231. <link>$AutoClickerWindow</link> = 0
  232.  
  233. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  234.  
  235. GUISetState(@SW_SHOW, $mainWindow)
  236.  
  237. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  238.  
  239. GUISetState(@SW_SHOW, $mainWindow)
  240.  
  241. While 1
  242.     $msg = GUIGetMsg()
  243.     Switch $msg
  244.         Case $GUI_EVENT_CLOSE, $btnExit, $btnAutoClickerExit
  245.             Exit
  246.         Case $btnStartStop
  247.             If Not _IsChecked($optionCheckbox) Then
  248.                 MsgBox(48, "Error", "Please select at least one option.")
  249.             Else
  250.                 $isRunning = Not $isRunning
  251.                 If $isRunning Then
  252.                     GUICtrlSetData($btnStartStop, "Stop")
  253.                     StartAutomation()
  254.                 Else
  255.                     MsgBox(64, "Stop", "Stopping automation.")
  256.                     ; Add logic to stop automation tasks
  257.                     GUICtrlSetData($btnStartStop, "Start")
  258.                 EndIf
  259.             EndIf
  260.         Case $optionCheckbox[7] ; Autoclicker checkbox
  261.             If GUICtrlRead($optionCheckbox[7]) = $GUI_CHECKED Then
  262.                 GUISetState(@SW_SHOW, $autoClickerWindow)
  263.             Else
  264.                 GUISetState(@SW_HIDE, $autoClickerWindow)
  265.                 $autoClickerActive = False
  266.             EndIf
  267.         Case $btnAutoClickerStartStop
  268.             If GUICtrlRead($btnAutoClickerStartStop) = "Start" Then
  269.                 GUICtrlSetData($btnAutoClickerStartStop, "Stop")
  270.                 $autoClickerActive = True
  271.                 $autoClickerDelay = GUICtrlRead($inpDelay)
  272.                 StartAutoClicker()
  273.             Else
  274.                 GUICtrlSetData($btnAutoClickerStartStop, "Start")
  275.                 $autoClickerActive = False
  276.             EndIf
  277.     EndSwitch
  278. WEnd
  279.  
  280. Func StartAutomation()
  281.     Local $appWindow, $coords, $result, $tolerance = 10 ; Define tolerance here
  282.  
  283. $appWindow = WinGetHandle("AsdaGlobal")
  284.     If $appWindow = 0 Then
  285.         MsgBox(16, "Error", "Failed to find the target application window.")
  286.         Return
  287.     EndIf
  288.  
  289.     ; Activate the application window
  290.     WinActivate($appWindow)
  291.  
  292.     ; Start monitoring if the monitoring checkbox is checked
  293.     If GUICtrlRead($optionCheckbox[6]) = $GUI_CHECKED Then
  294.         $monitoringActive = True
  295.         StartMonitoring()
  296.     EndIf
  297.  
  298.     While $isRunning
  299.         ; Add your automation logic here
  300.  
  301.         If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  302.             ; Clicking option selected
  303.             $coords = PixelSearch(1110, 642, 360, 110, 0x6A140A, 40)
  304.             If Not @error Then
  305.                 MouseClick("left", $coords[0], $coords[1], 2, 1)
  306.                 Sleep(700)
  307.             EndIf
  308.         EndIf
  309.  
  310.         If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  311.             ; Target Closest option selected
  312.             Send("{TAB 5}") ; Presses the Tab key 5 times.
  313.             Sleep(100)
  314.         EndIf
  315.  
  316.         If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  317.             ; Pickup Items option selected
  318.             For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  319.                 Send("2")
  320.                 Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  321.             Next
  322.         EndIf
  323.  
  324.         If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  325.             ; Digging option selected
  326.             Send("1")
  327.             Sleep(7000) ; Wait 7 seconds
  328.             Send("2")
  329.             Sleep(200)
  330.             Send("1")
  331.             Sleep(200)
  332.             Send("2")
  333.         EndIf
  334.  
  335.         Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  336.     WEnd
  337. EndFunc
  338.  
  339. Func StartMonitoring()
  340.     While $monitoringActive
  341.         ; Check for the appearance of the box with options in the specified area
  342.         If PixelSearchBox($monitoringAreaLeft, $monitoringAreaTop, $monitoringAreaRight, $monitoringAreaBottom) Then
  343.             ; Found the box, double left-click to select the reddish orange option
  344.             MouseClick("left", $coords[0], $coords[1], 2, 0)
  345.             Sleep(100)
  346.             MouseClick("left", $coords[0], $coords[1], 2, 0)
  347.             Sleep(100)
  348.             Send("{ENTER}")
  349.             Sleep(500)
  350.             Send("Sorry I'm busy atm 2 minutes", 35) ; Type the message with a delay of 35ms between each keystroke
  351.             Sleep(100) ; Wait 100ms before pressing enter again
  352.             Send("{ENTER}")
  353.         EndIf
  354.         Sleep(1000)
  355.     WEnd
  356. EndFunc
  357.  
  358. Func PixelSearchBox($left, $top, $right, $bottom)
  359.     ; Adjust the search area to the specified coordinates
  360.     Local $boxCoords = PixelSearch($left, $top, $right, $bottom, 0xFFFFFF, 10)
  361.     If Not @error Then
  362.         ; Found the box, return true
  363.         $coords = $boxCoords
  364.         Return True
  365.     EndIf
  366.     ; Box not found
  367.     Return False
  368. EndFunc
  369.  
  370. Func PanicButton()
  371.     ; Add the logic for the panic button action here
  372.     Exit
  373. EndFunc
  374.  
  375. Func StartAutoClicker()
  376.     While $autoClickerActive
  377.         MouseClick("left") ; Perform a left click
  378.         Sleep($autoClickerDelay) ; Delay between clicks
  379.     WEnd
  380. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement