Advertisement
ZxkH

Iteration #10

Feb 6th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. #include <GUIConstantsEx.au3>
  2.  
  3. Global $mainWindow, $optionCheckbox[8], $isRunning = False, $monitoringActive = False
  4. Global Const $monitoringAreaLeft = 520, $monitoringAreaTop = 460, $monitoringAreaRight = 760, $monitoringAreaBottom = 500
  5.  
  6. $mainWindow = GUICreate("AutoIt Automation", 300, 330)
  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("Monitoring", 10, 190, 100, 20)
  15.  
  16. $btnStartStop = GUICtrlCreateButton("Start/Stop", 10, 250, 100, 30)
  17. $btnExit = GUICtrlCreateButton("Exit", 230, 250, 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
  26. PanicButton()
  27.  
  28. Case $btnStartStop
  29. If $isRunning Then
  30. $isRunning = False
  31. GUICtrlSetData($btnStartStop, "Start")
  32. Else
  33. If Not _IsChecked($optionCheckbox) Then
  34. MsgBox(48, "Error", "Please select at least one option.")
  35. Else
  36. $isRunning = True
  37. GUICtrlSetData($btnStartStop, "Stop")
  38. StartAutomation()
  39. EndIf
  40. EndIf
  41.  
  42. Case $btnExit
  43. PanicButton()
  44. EndSwitch
  45. WEnd
  46.  
  47. Func _IsChecked($checkboxArray)
  48. For $i = 0 To UBound($checkboxArray) - 1
  49. If GUICtrlRead($checkboxArray[$i]) = $GUI_CHECKED Then Return True
  50. Next
  51. Return False
  52. EndFunc
  53.  
  54. Func StartAutomation()
  55. Local $appWindow, $coords, $result, $tolerance = 10 ; Define tolerance here
  56.  
  57. $appWindow = WinGetHandle("AsdaGlobal")
  58. If $appWindow = 0 Then
  59. MsgBox(16, "Error", "Failed to find the target application window.")
  60. Return
  61. EndIf
  62.  
  63. ; Start monitoring if the monitoring checkbox is checked
  64. If GUICtrlRead($optionCheckbox[6]) = $GUI_CHECKED Then
  65. $monitoringActive = True
  66. StartMonitoring()
  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, 0x6A140A, 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 Not @error Then
  133. ; Found the box, return true
  134. $coords = $boxCoords
  135. Return True
  136. EndIf
  137. ; Box not found
  138. Return False
  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