Advertisement
ZxkH

Iteration #11

Feb 6th, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. #include <GUIConstantsEx.au3>
  2.  
  3. Global $mainWindow, $optionCheckbox[7], $isRunning = False, $monitoringActive = False
  4. Global Const $monitoringAreaLeft = 520, $monitoringAreaTop = 460, $monitoringAreaRight = 760, $monitoringAreaBottom = 500
  5.  
  6. $mainWindow = GUICreate("AutoIt Automation", 300, 300)
  7.  
  8. $optionCheckbox[0] = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
  9. $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
  10. $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
  11. $optionCheckbox[3] = GUICtrlCreateCheckbox("Target Closest", 10, 100, 120, 20)
  12. $optionCheckbox[4] = GUICtrlCreateCheckbox("Pickup Items", 10, 130, 100, 20)
  13. $optionCheckbox[5] = GUICtrlCreateCheckbox("Digging", 10, 160, 100, 20)
  14. $optionCheckbox[6] = GUICtrlCreateCheckbox("Monitor", 10, 190, 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, $coords, $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. ; Activate the application window
  62. WinActivate($appWindow)
  63.  
  64. ; Start monitoring if the monitoring checkbox is checked
  65. If GUICtrlRead($optionCheckbox[6]) = $GUI_CHECKED Then
  66. $monitoringActive = True
  67. StartMonitoring()
  68. EndIf
  69.  
  70. While $isRunning
  71. ; Add your automation logic here
  72.  
  73. If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
  74. ; Clicking option selected
  75. $coords = PixelSearch(1110, 642, 360, 110, 0x6A140A, 40)
  76. If Not @error Then
  77. MouseClick("left", $coords[0], $coords[1], 2, 1)
  78. Sleep(700)
  79. EndIf
  80. EndIf
  81.  
  82. If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
  83. ; Target Closest option selected
  84. Send("{TAB 5}") ; Presses the Tab key 5 times.
  85. Sleep(100)
  86. EndIf
  87.  
  88. If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
  89. ; Pickup Items option selected
  90. For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
  91. Send("2")
  92. Sleep(Random(100, 300)) ; Add a random sleep after each keypress
  93. Next
  94. EndIf
  95.  
  96. If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
  97. ; Digging option selected
  98. Send("1")
  99. Sleep(7000) ; Wait 7 seconds
  100. Send("2")
  101. Sleep(200)
  102. Send("1")
  103. Sleep(200)
  104. Send("2")
  105. EndIf
  106.  
  107. Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
  108. WEnd
  109. EndFunc
  110.  
  111. Func StartMonitoring()
  112. While $monitoringActive
  113. ; Check for the appearance of the box with options in the specified area
  114. If PixelSearchBox($monitoringAreaLeft, $monitoringAreaTop, $monitoringAreaRight, $monitoringAreaBottom) Then
  115. ; Found the box, double left-click to select the reddish orange option
  116. MouseClick("left", $coords[0], $coords[1], 2, 0)
  117. Sleep(100)
  118. MouseClick("left", $coords[0], $coords[1], 2, 0)
  119. Sleep(100)
  120. Send("{ENTER}")
  121. Sleep(500)
  122. Send("Sorry I'm busy atm 2 minutes", 35) ; Type the message with a delay of 35ms between each keystroke
  123. Sleep(100) ; Wait 100ms before pressing enter again
  124. Send("{ENTER}")
  125. EndIf
  126. Sleep(1000)
  127. WEnd
  128. EndFunc
  129.  
  130. Func PixelSearchBox($left, $top, $right, $bottom)
  131. ; Adjust the search area to the specified coordinates
  132. Local $boxCoords = PixelSearch($left, $top, $right, $bottom, 0x6A140A, 10)
  133. If Not @error Then
  134. ; Found the box, return true
  135. $coords = $boxCoords
  136. Return True
  137. EndIf
  138. ; Box not found
  139. Return False
  140. EndFunc
  141.  
  142. Func PanicButton()
  143. ; Add the logic for the panic button action here
  144. Exit
  145. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement