#include #include HotKeySet("^x", "Terminate") $hGUI = GUICreate("Duck Search", 300, 150, -1, -1) Global $btnStart = GUICtrlCreateButton("Start", 20, 40, 100, 30) Global $btnStop = GUICtrlCreateButton("Stop", 160, 40, 100, 30) Global $lblStatus = GUICtrlCreateLabel("Nhấn start để bắt đầu chương trình", 20, 80, 260, 20) Global $isRunning = False Global $hLabel = GUICtrlCreateLabel("", 50, 100, 200, 50) GUICtrlSetFont($hLabel, 16, 800) Global $remainingTime = 0 GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $btnStop $isRunning = False Case $btnStart $isRunning = True FindDuck() EndSwitch WEnd Func Terminate() ConsoleWrite("Terminating program..." & @CRLF) Exit EndFunc Func FindDuck() While $isRunning Local $checkDucker = PixelSearch(3456, 755, 3763, 877, 0xEEDF58) If IsArray($checkDucker) Then GUICtrlSetData($lblStatus, "Đã tìm thấy vịt mẹ") SoundPlay("C:\Users\dinhh\Desktop\alert.mp3") $remainingTime = 0 MouseMove($checkDucker[0] + 10, $checkDucker[1] + 10, 0) For $i = 1 To 10 MouseClick("left") Local $checkClaim = PixelSearch(3456, 546, 3763, 877, 0x34BF14) If IsArray($checkClaim) Then MouseMove($checkClaim[0], $checkClaim[1], 10) Sleep(500) MouseClick("left") $remainingTime = 29 * 60 UpdateTime() $remainingTime = 0 ;GUICtrlSetData($lblStatus, "Chương trình sẽ tạm dừng 25 phút") ;Sleep(25 * 60 * 1000) ExitLoop EndIf Sleep(500) Next Else GUICtrlSetData($lblStatus, "Không tìm thấy vịt mẹ") ConsoleWrite("Khong tim thay vit me" & @CRLF) Sleep(3000) EndIf WEnd EndFunc Func UpdateTime() While $remainingTime > 0 If $remainingTime > 0 Then Local $mins = Int($remainingTime / 60) Local $secs = Mod($remainingTime, 60) GUICtrlSetData($hLabel, "Còn lại: " & StringFormat("%02d:%02d", $mins, $secs)) $remainingTime -= 1 Sleep(1000) Else GUICtrlSetData($hLabel, "Coming soon...") EndIf WEnd EndFunc