Advertisement
ZxkH

Iteration #9.1

Feb 6th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. #include <GUIConstantsEx.au3>
  2.  
  3. Global $mainWindow, $optionCheckbox[7], $isRunning = False, $monitoringActive = False
  4. Global Const $monitoringAreaLeft = 500, $monitoringAreaTop = 500, $monitoringAreaRight = 1000, $monitoringAreaBottom = 1000
  5. Global $coords[2]
  6.  
  7. $mainWindow = GUICreate("AutoIt Automation", 300, 300)
  8.  
  9. $optionCheckbox[0] = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  10. $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  11. $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  12. $optionCheckbox[3] = GUICtrlCreateCheckbox("Target Closest", 10, 100, 120, 20)
  13. $optionCheckbox[4] = GUICtrlCreateCheckbox("Pickup Items", 10, 130, 100, 20)
  14. $optionCheckbox[5] = GUICtrlCreateCheckbox("Digging", 10, 160, 100, 20)
  15.  
  16. $btnStartStop = GUICtrlCreateButton("Start/Stop", 10, 220, 100, 30)
  17. $btnExit = GUICtrlCreateButton("Exit", 230, 220, 60, 30)
  18.  
  19. HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
  20.  
  21. GUISetState(@SW_SHOW)
  22.  
  23. While 1
  24. Switch GUIGetMsg()
  25. Case $GUI_EVENT_CLOSE, $btnExit
  26. Exit
  27.  
  28. Case $btnStartStop
  29. If Not _IsChecked($optionCheckbox) Then
  30. MsgBox(48, "Error", "Please select at least one option.")
  31. Else
  32. $isRunning = Not $isRunning
  33. If $isRunning Then
  34. GUICtrlSetData($btnStartStop, "Stop")
  35. StartAutomation()
  36. Else
  37. MsgBox(64, "Stop", "Stopping automation.")
  38. ; Add logic to stop automation tasks
  39. GUICtrlSetData($btnStartStop, "Start")
  40. EndIf
  41. EndIf
  42. EndSwitch
  43. WEnd
  44.  
  45. Func _IsChecked($checkboxArray)
  46. For $i = 0 To UBound($checkboxArray) - 1
  47. If GUICtrlRead($checkboxArray[$i]) = $GUI_CHECKED Then Return True
  48. Next
  49. Return False
  50. EndFunc
  51.  
  52. Func StartAutomation()
  53. Local $appWindow, $result, $tolerance = 10 ; Define tolerance here
  54.  
  55. $appWindow = WinGetHandle("AsdaGlobal")
  56. If $appWindow = 0 Then
  57. MsgBox(16, "Error", "Failed to find the target application window.")
  58. Return
  59. EndIf
  60.  
  61. ; Start monitoring only if any checkbox is checked and Start/Stop button is active
  62. If Not $monitoringActive Then
  63. If _IsChecked($optionCheckbox) Then
  64. $monitoringActive = True
  65. StartMonitoring()
  66. EndIf
  67. EndIf
  68.  
  69. While $isRunning
  70. ; Add your automation logic here
  71.  
  72. If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  73. ; Clicking option selected
  74. $coords = PixelSearch(1110, 642, 360, 110, 0x5A2568, 40)
  75. If Not @error Then
  76. MouseClick("left", $coords[0], $coords[1], 2, 1)
  77. Sleep(700)
  78. EndIf
  79. EndIf
  80.  
  81. If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  82. ; Target Closest option selected
  83. Send("{TAB 5}") ; Presses the Tab key 5 times.
  84. Sleep(100)
  85. EndIf
  86.  
  87. If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  88. ; Pickup Items option selected
  89. For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  90. Send("2")
  91. Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  92. Next
  93. EndIf
  94.  
  95. If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  96. ; Digging option selected
  97. Send("1")
  98. Sleep(7000) ; Wait 7 seconds
  99. Send("2")
  100. Sleep(200)
  101. Send("1")
  102. Sleep(200)
  103. Send("2")
  104. EndIf
  105.  
  106. Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  107. WEnd
  108. EndFunc
  109.  
  110. Func StartMonitoring()
  111. While $monitoringActive
  112. ; Check for the appearance of the box with options in the specified area
  113. If PixelSearchBox($monitoringAreaLeft, $monitoringAreaTop, $monitoringAreaRight, $monitoringAreaBottom) Then
  114. ; Found the box, double left-click to select the reddish orange option
  115. MouseClick("left", $coords[0], $coords[1], 2, 0)
  116. Sleep(100)
  117. MouseClick("left", $coords[0], $coords[1], 2, 0)
  118. Sleep(100)
  119. Send("{ENTER}")
  120. Sleep(500)
  121. Send("Sorry I'm busy atm 2 minutes", 35) ; Type the message with a delay of 35ms between each keystroke
  122. Sleep(100) ; Wait 100ms before pressing enter again
  123. Send("{ENTER}")
  124. EndIf
  125. Sleep(1000)
  126. WEnd
  127. EndFunc
  128.  
  129. Func PixelSearchBox($left, $top, $right, $bottom)
  130. ; Adjust the search area to the specified coordinates
  131. Local $boxCoords = PixelSearch($left, $top, $right, $bottom, 0xFFFFFF, 10)
  132. If @error Then
  133. ; Box not found
  134. Return False
  135. EndIf
  136. ; Found the box, store the coordinates
  137. $coords = $boxCoords
  138. Return True
  139. EndFunc
  140.  
  141. Func PanicButton()
  142. ; Add the logic for the panic button action here
  143. Exit
  144. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement