Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <MsgBoxConstants.au3>
- #include <WinAPIFiles.au3>
- HotKeySet("{F1}", "Start")
- HotKeySet("{F2}", "Stop")
- Global $hAutoclickerWindow = WinGetHandle("[CLASS:AsdaGlobal]")
- While 1
- Sleep(100)
- WEnd
- Func Start()
- While 1
- If Not WinExists($hAutoclickerWindow) Then
- MsgBox($MB_SYSTEMMODAL, "Error", "AsdaGlobal window not found!")
- Exit
- EndIf
- ; Click somewhere in the AsdaGlobal window
- MouseClick("left", 100, 100, 1, 0)
- Sleep(1000)
- WEnd
- EndFunc ;==>Start
- Func Stop()
- Exit
- EndFunc ;==>Stop
- ;The rest of the code from the pastebin link
- Func _FileWriteLog($sMessage, $sFile)
- Local $hFileOpen = FileOpen($sFile, 1)
- If $hFileOpen = -1 Then
- FileWrite($sFile, $sMessage & @CRLF)
- Else
- FileWriteLine($hFileOpen, $sMessage)
- FileClose($hFileOpen)
- EndIf
- EndFunc
- Func _WaitForImage($sImagePath, $iTimeout = 30000)
- Local $iTimerStart = TimerInit()
- While TimerDiff($iTimerStart) < $iTimeout
- If FileExists($sImagePath) Then Return True
- Sleep(100)
- WEnd
- Return False
- EndFunc
- Func _ClickImage($sImagePath)
- Local $aSearch = _ImageSearch($sImagePath, 0, 0, 0, 0)
- If $aSearch[0] = 0 Then Return False
- MouseMove($aSearch[1], $aSearch[2], 10)
- MouseClick("left", $aSearch[1], $aSearch[2], 1, 0)
- Return True
- EndFunc
- Func _ImageSearch($sImagePath, $iLeft, $iTop, $iRight, $iBottom, $iFuzziness = 0)
- Local $aResult = ControlGetHandle("AsdaGlobal", "", 0)
- If $aResult[0] = 0 Then Return SetError(1, 0, 0)
- Local $aSearch = _ImageSearchArea($sImagePath, $iLeft, $iTop, $iRight, $iBottom, $iFuzziness, $aResult[1])
- Return $aSearch
- EndFunc
- Func _ImageSearchArea($sImagePath, $iLeft, $iTop, $iRight, $iBottom, $iFuzziness, $hWnd = 0)
- Local $aSearch = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $iLeft, "int", $iTop, "int", $iRight, "int", $iBottom, "wstr", $sImagePath, "int", $iFuzziness, "hwnd", $hWnd)
- If @error Then Return SetError(@error, @extended, "")
- Return $aSearch
- EndFunc
- #include <MsgBoxConstants.au3>
- Global $autoClickerWindow
- ; Open the AutoClicker
- $autoClickerWindow = WinGetHandle("[CLASS:AutoClicker]")
- If @error Then
- MsgBox($MB_OK, "Error", "AutoClicker window not found.")
- Exit
- EndIf
- Func Example()
- ; This function clicks the button Start on the AutoClicker window
- ControlClick($autoClickerWindow, "", "[CLASS:Button; TEXT:Start]")
- EndFunc
- Func main()
- ; Example of using the $autoClickerWindow handle:
- ; ControlClick($autoClickerWindow, "", "[CLASS:Button; TEXT:Start]")
- ; Your main code goes here...
- EndFunc
- #include <GUIConstantsEx.au3>
- Global $mainWindow, $optionCheckbox[8], $isRunning = False, $monitoringActive = False, $autoClickerActive = False
- Global $autoClickerDelay = 1000 ; Default delay for autoclicker (milliseconds)
- Global Const $monitoringAreaLeft = 520, $monitoringAreaTop = 460, $monitoringAreaRight = 760, $monitoringAreaBottom = 500
- <link>$mainWindow</link> = GUICreate("AutoIt Automation", 300, 330)
- <link>$optionCheckbox[0]</link> = GUICtrlCreateCheckbox("Clicking", 10, 10, 100, 20)
- <link>$optionCheckbox[1]</link> = GUICtrlCreateCheckbox("Skills", 10, 40, 100, 20)
- <link>$optionCheckbox[2]</link> = GUICtrlCreateCheckbox("Auto Heal", 10, 70, 100, 20)
- <link>$optionCheckbox[3]</link> = GUICtrlCreateCheckbox("Target Closest", 10, 100, 120, 20)
- <link>$optionCheckbox[4]</link> = GUICtrlCreateCheckbox("Pickup Items", 10, 130, 100, 20)
- <link>$optionCheckbox[5]</link> = GUICtrlCreateCheckbox("Digging", 10, 160, 100, 20)
- <link>$optionCheckbox[6]</link> = GUICtrlCreateCheckbox("Monitor", 10, 190, 100, 20)
- <link>$optionCheckbox[7]</link> = GUICtrlCreateCheckbox("AutoClicker", 10, 220, 100, 20)
- <link>$btnStartStop</link> = GUICtrlCreateButton("Start/Stop", 10, 270, 100, 30)
- <link>$btnExit</link> = GUICtrlCreateButton("Exit", 230, 270, 60, 30)
- Global $autoClickerWindow, $inpDelay, $btnAutoClickerStartStop, $btnAutoClickerExit
- <link>$autoClickerWindow</link> = GUICreate("AutoClicker Settings", 200, 120, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_CAPTION))
- GUICtrlCreateLabel("Delay (ms):", 10, 10, 100, 20)
- <link>$inpDelay</link> = GUICtrlCreateInput("1000", 110, 10, 60, 20)
- <link>$btnAutoClickerStartStop</link> = GUICtrlCreateButton("Start", 10, 50, 80, 30)
- <link>$btnAutoClickerExit</link> = GUICtrlCreateButton("Exit", 110, 50, 80, 30)
- GUISetState(@SW_HIDE, $autoClickerWindow)
- <link>$AutoClickerWindow</link> = 0
- HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
- GUISetState(@SW_SHOW, $mainWindow)
- HotKeySet("{End}", "PanicButton") ; Set the "end" key as the panic button
- GUISetState(@SW_SHOW, $mainWindow)
- While 1
- $msg = GUIGetMsg()
- Switch $msg
- Case $GUI_EVENT_CLOSE, $btnExit, $btnAutoClickerExit
- 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
- Case $optionCheckbox[7] ; Autoclicker checkbox
- If GUICtrlRead($optionCheckbox[7]) = $GUI_CHECKED Then
- GUISetState(@SW_SHOW, $autoClickerWindow)
- Else
- GUISetState(@SW_HIDE, $autoClickerWindow)
- $autoClickerActive = False
- EndIf
- Case $btnAutoClickerStartStop
- If GUICtrlRead($btnAutoClickerStartStop) = "Start" Then
- GUICtrlSetData($btnAutoClickerStartStop, "Stop")
- $autoClickerActive = True
- $autoClickerDelay = GUICtrlRead($inpDelay)
- StartAutoClicker()
- Else
- GUICtrlSetData($btnAutoClickerStartStop, "Start")
- $autoClickerActive = False
- EndIf
- EndSwitch
- WEnd
- Func StartAutomation()
- Local $appWindow, $coords, $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
- ; Activate the application window
- WinActivate($appWindow)
- ; Start monitoring if the monitoring checkbox is checked
- If GUICtrlRead($optionCheckbox[6]) = $GUI_CHECKED Then
- $monitoringActive = True
- StartMonitoring()
- EndIf
- While $isRunning
- ; Add your automation logic here
- If GUICtrlRead($optionCheckbox[0]) = $GUI_CHECKED Then
- ; Clicking option selected
- $coords = PixelSearch(1110, 642, 360, 110, 0x6A140A, 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 Not @error Then
- ; Found the box, return true
- $coords = $boxCoords
- Return True
- EndIf
- ; Box not found
- Return False
- EndFunc
- Func PanicButton()
- ; Add the logic for the panic button action here
- Exit
- EndFunc
- Func StartAutoClicker()
- While $autoClickerActive
- MouseClick("left") ; Perform a left click
- Sleep($autoClickerDelay) ; Delay between clicks
- WEnd
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement