Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GUIConstantsEx.au3>
- Global $mainWindow, $optionCheckbox[7], $isRunning = False, $monitoringActive = False
- Global Const $monitoringAreaLeft = 500, $monitoringAreaTop = 500, $monitoringAreaRight = 1000, $monitoringAreaBottom = 1000
- Global $coords[2]
- $mainWindow = GUICreate("AutoIt Automation", 300, 300)
- $optionCheckbox[0] = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
- $optionCheckbox[1] = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
- $optionCheckbox[2] = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
- $optionCheckbox[3] = GUICtrlCreateCheckbox("Target Closest", 10, 100, 120, 20)
- $optionCheckbox[4] = GUICtrlCreateCheckbox("Pickup Items", 10, 130, 100, 20)
- $optionCheckbox[5] = GUICtrlCreateCheckbox("Digging", 10, 160, 100, 20)
- $btnStartStop = GUICtrlCreateButton("Start/Stop", 10, 220, 100, 30)
- $btnExit = GUICtrlCreateButton("Exit", 230, 220, 60, 30)
- HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
- GUISetState(@SW_SHOW)
- While 1
- Switch GUIGetMsg()
- Case $GUI_EVENT_CLOSE, $btnExit
- Exit
- Case $btnStartStop
- If Not _IsChecked($optionCheckbox) Then
- MsgBox(48, "Error", "Please select at least one option.")
- Else
- $isRunning = Not $isRunning
- If $isRunning Then
- GUICtrlSetData($btnStartStop, "Stop")
- StartAutomation()
- Else
- MsgBox(64, "Stop", "Stopping automation.")
- ; Add logic to stop automation tasks
- GUICtrlSetData($btnStartStop, "Start")
- EndIf
- EndIf
- EndSwitch
- WEnd
- Func _IsChecked($checkboxArray)
- For $i = 0 To UBound($checkboxArray) - 1
- If GUICtrlRead($checkboxArray[$i]) = $GUI_CHECKED Then Return True
- Next
- Return False
- EndFunc
- Func StartAutomation()
- Local $appWindow, $result, $tolerance = 10 ; Define tolerance here
- $appWindow = WinGetHandle("AsdaGlobal")
- If $appWindow = 0 Then
- MsgBox(16, "Error", "Failed to find the target application window.")
- Return
- EndIf
- ; Start monitoring only if any checkbox is checked and Start/Stop button is active
- If Not $monitoringActive Then
- If _IsChecked($optionCheckbox) Then
- $monitoringActive = True
- StartMonitoring()
- EndIf
- EndIf
- While $isRunning
- ; Add your automation logic here
- If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
- ; Clicking option selected
- $coords = PixelSearch(1110, 642, 360, 110, 0x5A2568, 40)
- If Not @error Then
- MouseClick("left", $coords[0], $coords[1], 2, 1)
- Sleep(700)
- EndIf
- EndIf
- If GUICtrlRead($optionCheckbox[3]) = $GUI_CHECKED Then
- ; Target Closest option selected
- Send("{TAB 5}") ; Presses the Tab key 5 times.
- Sleep(100)
- EndIf
- If GUICtrlRead($optionCheckbox[4]) = $GUI_CHECKED Then
- ; Pickup Items option selected
- For $i = 1 To Random(1, 15) ; Send "2" a random number of times between 1 and 15
- Send("2")
- Sleep(Random(100, 300)) ; Add a random sleep after each keypress
- Next
- EndIf
- If GUICtrlRead($optionCheckbox[5]) = $GUI_CHECKED Then
- ; Digging option selected
- Send("1")
- Sleep(7000) ; Wait 7 seconds
- Send("2")
- Sleep(200)
- Send("1")
- Sleep(200)
- Send("2")
- EndIf
- Sleep(100) ; Add a delay between iterations to prevent excessive CPU usage
- WEnd
- EndFunc
- Func StartMonitoring()
- While $monitoringActive
- ; Check for the appearance of the box with options in the specified area
- If PixelSearchBox($monitoringAreaLeft, $monitoringAreaTop, $monitoringAreaRight, $monitoringAreaBottom) Then
- ; Found the box, double left-click to select the reddish orange option
- MouseClick("left", $coords[0], $coords[1], 2, 0)
- Sleep(100)
- MouseClick("left", $coords[0], $coords[1], 2, 0)
- Sleep(100)
- Send("{ENTER}")
- Sleep(500)
- Send("Sorry I'm busy atm 2 minutes", 35) ; Type the message with a delay of 35ms between each keystroke
- Sleep(100) ; Wait 100ms before pressing enter again
- Send("{ENTER}")
- EndIf
- Sleep(1000)
- WEnd
- EndFunc
- Func PixelSearchBox($left, $top, $right, $bottom)
- ; Adjust the search area to the specified coordinates
- Local $boxCoords = PixelSearch($left, $top, $right, $bottom, 0xFFFFFF, 10)
- If @error Then
- ; Box not found
- Return False
- EndIf
- ; Found the box, store the coordinates
- $coords = $boxCoords
- Return True
- EndFunc
- Func PanicButton()
- ; Add the logic for the panic button action here
- Exit
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement