$version01 = "A" $version01update = "11.1" ;============================== ; Author: Toady ; Site: www.itoady.com ; Updated: May 21, 2008 ; AutoIt Ver: 3.2.12.0 ; ; A * Searching Alorithm ; Artificial Intelligence ; Robot path finding ;============================== #include #include #Include #Include #include ;#include "FastFind.au3" #include #include #RequireAdmin ; ko thong bao khi thieu var co them quyen admin ghi vao bo x32 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "WinHttp.au3" #include "demem.au3" #include #include ;#include "VirtDsktLibrary01.au3" #include #include _WinAPI_SetErrorMode($SEM_FAILCRITICALERRORS Or $SEM_NOGPFAULTERRORBOX) $not_responding_num01 = 0 $file_battle_server00 = "0_MEO_D01_SERVER.txt" Global $data_server[25] _FileReadToArray("c:\acc\"&$file_battle_server00, $data_server, $FRTA_COUNT) $str_BAN = "BAN" ; Khởi tạo sẵn 2 Struct dùng chung cho toàn bộ script (Chỉ tạo 1 lần duy nhất lúc bật bot) Global $gh_vReadDataPtr = DllStructCreate("dword_ptr") ; khoi tao asm_bfs _________________________________________________________________________________________________ ;Global $procHwnd_autoit01 = _Memoryopen($process_autoit01,0x1f0fff,0) Global $row_bfs01 = 50 Global $col_bfs01 = 50 Global $row_bfs00 = 34 ; 34 50 Global $sx_bfs = 9 Global $sy_bfs = 11 Global $gx_bfs = 22 Global $gy_bfs = 44 ; ============================ ; Khởi tạo vùng nhớ BFS 50x50 ; ============================ Global $mapBase = _MemVirtualAlloc(0x0, 0x9C4, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; MAP[50][50] = 2500 ô × 1 byte = 2500 bytes Global $visitedBase = _MemVirtualAlloc(0x0, 0x9C4, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; Visited[50][50] = 2500 ô × 1 byte = 2500 bytes Global $prevBase = _MemVirtualAlloc(0x0, 0x4E20, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; Prev[50][50][2] = 5000 ô × 4 bytes = 20,000 bytes Global $queueBase = _MemVirtualAlloc(0x0, 0x4E20, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; Queue[2500][2] = 5000 ô × 4 bytes = 20,000 bytes Global $pathBase = _MemVirtualAlloc(0x0, 0x4E20, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; Path[2500][2] = 5000 ô × 4 bytes = 20,000 bytes Global $BFS = _MemVirtualAlloc(0x0, 0x1000, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; BFS variables (front, rear, sx, sy, gx, gy) giữ nguyên 4096 bytes Global $newmem = _MemVirtualAlloc(0x0, 0x2000, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; newmem workspace giữ nguyên 8192 bytes Global $data_map_bfs[$row_bfs01][$col_bfs01] = [ _ ["x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x","0","0","0","x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x","x","x","x","x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x"]] ; ============================ ; Tạo buffer ASM 64-bit tại BFS ; ============================ Global $startBFS = ASM64_opcode02vtmem("1000",$BFS) ; Ghi opcode NOP và RET ;DllStructSetData($startBFS, "ASM", 0x90C3, 1) ; ASM[1] = NOP ;DllStructSetData($startBFS, "ASM", 0xC3, 2) ; ASM[2] = RE Global $startBFS_address = DllStructGetPtr( $startBFS ) _cmp_BFS01($mapBase,$visitedBase,$prevBase,$queueBase,$pathBase,$BFS,$newmem,$startBFS) ; khoi tao asm_bfs end _________________________________________________________________________________________________ Func _reghive04EX($missing00=0) ; --- Đọc từ registry --- Local $regPath = "HKCU\Software\Blizzard Entertainment\Battle.net\UnifiedAuth" Local $validKeys = "" Local $invalidKeys = "" $missing_number01 = 0 Local $missing_all01 = "" Local $i = 1 While 1 Local $valueName = RegEnumVal($regPath, $i) If @error Then ExitLoop Local $value = RegRead($regPath, $valueName) If IsBinary($value) Then If BinaryLen($value) >= 16 Then $validKeys &= $valueName & "|" Else $invalidKeys &= $valueName & "|" EndIf EndIf $i += 1 WEnd ; --- Đọc từ các file .reg --- Local $folder = "D:\sb_reghive\" Local $resultList = "" $missing00_exit = 0 For $i = 1 To 24 If $data_server[$i] <> $str_BAN Then ; $data_server[$lp_math01] <> $str_BAN Local $filePath = $folder & "Battle_RegHive_reg" & $i & ".reg" If FileExists($filePath) Then Local $content = FileRead($filePath) Local $lines = StringSplit($content, @CRLF, 1) For $j = 1 To $lines[0] Local $line = $lines[$j] If StringRegExp($line, '^"\w+"=hex:') Then Local $match = StringRegExpReplace($line, '^"(\w+)"=hex:.*', '$1') If StringInStr($validKeys, $match & "|") Then $resultList &= "[OK] File A" & $i & ": " & $match & @CRLF ElseIf StringInStr($invalidKeys, $match & "|") Then $resultList &= "[LỖI: Dưới 16 byte] File A" & $i & ": " & $match & @CRLF Else $resultList &= "[MISSING] File A" & $i & ": " & $match & @CRLF If $missing_number01 = 0 and $missing00=0 Then $missing_number01 = $i ElseIf $missing_number01 = 0 and $missing00=1 Then $missing_number01 = $i $missing00_exit = 1 ElseIf $missing00=2 Then If $missing_number01 = 0 Then $missing_number01 = $i $missing_all01 &= " M"&$i ElseIf $missing00=3 Then $missing_all01 &= " M"&$i EndIf EndIf EndIf If $missing00_exit = 1 Then ExitLoop Next EndIf EndIf ; end $data_server[$lp_math01] <> $str_BAN If $missing00_exit = 1 Then ExitLoop Next ; --- Hiển thị kết quả --- ;MsgBox(64, "Đối chiếu hex", "Kết quả kiểm tra các khóa hex từ file .reg:" & @CRLF & @CRLF & $resultList) ;MsgBox(64, "Đối chiếu hex", "Kết quả kiểm tra các khóa hex từ file .reg:" & @CRLF & @CRLF & $missing_number01) Local $arrMatchList = StringSplit($resultList, @CRLF, 1) If $missing00 <> 3 Then For $lp_math01 = 1 To $arrMatchList[0] GUICtrlSetData_down01($idCheckbox35_tiled02_02, $arrMatchList[$lp_math01] & @CRLF) Next EndIf If $missing00 = 0 Then Return $missing_number01 ElseIf $missing00 = 1 Then If $missing_number01 = 0 Then $missing_number01 = 1 Return $missing_number01 ElseIf $missing00 = 2 Then GUICtrlSetData_down01($idCheckbox35_tiled02_02, $missing_all01 & @CRLF) If $missing_number01 = 0 Then $missing_number01 = 1 Return $missing_number01 ElseIf $missing00 = 3 Then Return $missing_all01 EndIf EndFunc ;_CompareProcess01("DiabloImmortal.exe", "[#] [a1] Diablo Immortal [#]") Func _CompareProcess01($ExecutableName, $WindowTitle) Local $Snapshot, $ProcessEntry, $ProcessDetails[0][3], $GameProcessCount = 0, $GameProcessClose $Snapshot = DllCall("Kernel32.dll", "handle", "CreateToolhelp32Snapshot", "int", 2, "int", 0) If $Snapshot[0] = -1 Then MsgBox(16, "Error", "Failed to create process snapshot!") Return SetError(1, 0, 0) EndIf $ProcessEntry = DllStructCreate("dword Size; dword CntUsage; dword ProcessID; uint64 DefaultHeapID; dword ModuleID; dword Threads; dword ParentProcessID; dword PriorityBase; dword Flags; char ExeFile[260]") DllStructSetData($ProcessEntry, "Size", DllStructGetSize($ProcessEntry)) If DllCall("Kernel32.dll", "bool", "Process32First", "handle", $Snapshot[0], "ptr", DllStructGetPtr($ProcessEntry))[0] Then Do Local $CurrentExe = DllStructGetData($ProcessEntry, "ExeFile") Local $CurrentPID = DllStructGetData($ProcessEntry, "ProcessID") If StringInStr($CurrentExe, $ExecutableName) Then Local $WindowList = WinList() For $i = 1 To $WindowList[0][0] If BitAND(WinGetState($WindowList[$i][1]), 2) Then Local $VisibleTitle = $WindowList[$i][0] Local $VisiblePID = WinGetProcess($WindowList[$i][1]) If $VisiblePID = $CurrentPID And $VisibleTitle = $WindowTitle Then ;_ArrayAdd($ProcessDetails, $CurrentPID & "|" & $CurrentExe & "|" & $VisibleTitle) $GameProcessCount += 1 $GameProcessClose = $CurrentPID ;ConsoleWrite("N"&$GameProcessCount & "|" & $CurrentPID & "|" & $CurrentExe & "|" & $VisibleTitle& @CRLF) ExitLoop EndIf EndIf Next EndIf Until $GameProcessCount > 1 Or Not DllCall("Kernel32.dll", "bool", "Process32Next", "handle", $Snapshot[0], "ptr", DllStructGetPtr($ProcessEntry))[0] EndIf DllCall("Kernel32.dll", "bool", "CloseHandle", "handle", $Snapshot[0]) ; Output Results If $GameProcessCount = 0 Then ;MsgBox(64, "Result", "No matching process found.") ElseIf $GameProcessCount > 1 Then ProcessClose($GameProcessClose) ;ConsoleWrite("N"&$GameProcessCount & "|" & $CurrentPID & "|" & $CurrentExe & "|" & $VisibleTitle& @CRLF) EndIf EndFunc ;_battle_diablo_title01() Func _battle_diablo_title01() $aWinGetHandle05 = WinGetHandle("Diablo Immortal") If $aWinGetHandle05 <> "" Then $iPid05 = WinGetProcess($aWinGetHandle05) Global $procHwnd05 = _Process_Open($iPid05) $address_dll_switch01 = 1 $hook_SDL2_dll = dec(hex(_Module_GetBaseAddress($procHwnd05, "DiabloImmortal.exe"))) If $address_dll_switch01 = 1 Then ; $address_dll_switch01 ;$g_address01 = _MemoryRead64($hook_SDL2_dll+0x04CDC0B8, $procHwnd05, 'byte[8]',"dec") ; rsi ;$g_address01 = _MemoryRead64($hook_SDL2_dll+0x04DC4B00, $procHwnd05, 'byte[8]',"dec") ; rsi ;$g_address01 = _MemoryRead64($hook_SDL2_dll+0x04E53C80, $procHwnd05, 'byte[8]',"dec") ; rsi ;$g_address01 = _MemoryRead64($hook_SDL2_dll+0x04E55020, $procHwnd05, 'byte[8]',"dec") ; rsi ;$g_address01 = _MemoryRead64($hook_SDL2_dll+0x04E57F18, $procHwnd05, 'byte[8]',"dec") ; rsi $g_address01 = _MemoryRead64($hook_SDL2_dll+0x051D80F8, $procHwnd05, 'byte[8]',"dec") ; rsi $g_address01offset = _MemoryRead64("0x"&Hex($g_address01+0x0), $procHwnd05, 'byte[8]',"hex") ; rsi $g_address01offset = _MemoryRead64("0x"&Hex($g_address01offset+0x60), $procHwnd05, 'byte[8]',"hex") ; rsi $g_address01offset = _MemoryRead64("0x"&Hex($g_address01offset+0x2D8), $procHwnd05, 'byte[8]',"hex") ; rsi EndIf ; end $address_dll_switch01 $g_address01text = _MemoryRead6401_fix( "0x"&Hex($g_address01offset+0x978) , $procHwnd05, 'wchar[14]') ; type = ( byte, float, dword, char[], byte[] ... etc ) win 1803 1703 If StringInStr($g_address01text,"batt") < 0+1 Then $g_address01text = _MemoryRead6401_fix( "0x"&Hex($g_address01offset+0xC2C) , $procHwnd05, 'wchar[14]') ; type = ( byte, float, dword, char[], byte[] ... etc ) win 1511 EndIf If StringInStr($g_address01text,"batt") < 0+1 Then $g_address01text = _MemoryRead6401_fix( "0x"&Hex($g_address01offset+0xB80) , $procHwnd05, 'wchar[14]') ; type = ( byte, float, dword, char[], byte[] ... etc ) win 1903 EndIf ;MsgBox($MB_SYSTEMMODAL, "$game_hookX1 "&$aWinGetHandle05 , "$game_hookX1 " & Hex($hook_SDL2_dll) & "$g_address01 " & "$g_address01text " & $g_address01text ) Select Case $g_address01text = "Batt01.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a1] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt02.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a2] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt03.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a3] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt04.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a4] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt05.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a5] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt06.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a6] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt07.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a7] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt08.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a8] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt09.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a9] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt10.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a10] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt11.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a11] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt12.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a12] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt13.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a13] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt14.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a14] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt15.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a15] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt16.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a16] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt17.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a17] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt18.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a18] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt19.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a19] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt20.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a20] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt21.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a21] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt22.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a22] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt23.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a23] Diablo Immortal [#]") ProcessClose($g_address01text) Case $g_address01text = "Batt24.net.exe" WinSetTitle($aWinGetHandle05, "", "[#] [a24] Diablo Immortal [#]") ProcessClose($g_address01text) EndSelect EndIf EndFunc Func find_process02($file00="MSIAfterburner.exe") ; $login_e00 $file_list01 = ProcessList($file00) $file_check01 = "" Local $return[4] For $i = 1 To $file_list01 [0][0] ;MsgBox($MB_SYSTEMMODAL, "", $file_list01[$i][0] & @CRLF & "PID: " &$file_list01[$i][1]) If $file_list01[$i][0] = $file00 Then $file_name01 = $file_list01[$i][0] $file_check01 = $file_list01[$i][1] $aWinList = WinList() For $A = 1 To $aWinList[0][0] If WinGetProcess($aWinList[$A][1]) = $file_check01 And BitAND(WinGetState($aWinList[$A][1]), 2) Then $handle0 = $aWinList[$A][1] $title0 = $aWinList[$A][0] ; MsgBox($MB_SYSTEMMODAL, "", "file name= "&$file_list01[$i][0] & @CRLF & "PID: " &$file_list01[$i][1]& @CRLF & $handle0 & @CRLF & $title0 ) $return[0] = $file_name01 ; file name $return[1] = $file_check01 ; PID $return[2] = $handle0 ; handle $return[3] = $title0 ; title Return $return EndIf Next EndIf Next ;ConsoleWrite("$file00 = "&$file00&" $file_check01 = "&$file_check01&@CRLF) Return $return EndFunc ;_angent_playing_now01() Func _angent_playing_now01() Local $tProcessList = ProcessList("Agent.exe") For $t = 1 To $tProcessList[0][0] If $tProcessList[$t][0] = "Agent.exe" Then $procHwnd_Agent01 = _Process_Open($tProcessList[$t][1]) $Agent01_hook = _Module_GetBaseAddress($procHwnd_Agent01, "Agent.exe") ;MsgBox($MB_SYSTEMMODAL, "", $tProcessList[$t][0] & @CRLF & "PID: " & $tProcessList[$t][1]&" HEX "&Hex($Agent01_hook) ) ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x5ADD24, $procHwnd_Agent01, 'byte[4]',"Dec") ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x3BD330, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.8916 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x43CDE0, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.8988 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x43D290, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.8999 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x43DB60, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9054 FAIL ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x43D5E0, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9054 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x43DA90, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9098 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x44C3E0, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9124 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x44DBD0, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9149 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x44DBC0, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9166 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x4570C0, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9242 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x457D50, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9262 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x457DD0, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9370 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x459B70, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9390 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x45A870, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9414 ;$check_vtmemX = _MemoryRead64($Agent01_hook+0x475C00, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9695 $check_vtmemX = _MemoryRead64($Agent01_hook+0x475E20, $procHwnd_Agent01, 'byte[1]',"Dec") ; C:\ProgramData\Battle.net\Agent\Agent.9700 ;$check_vtmemX = 0 ;If $check_vtmemX<1000 Then $vtmemX01 = "" If $check_vtmemX <> 233 Then $vtmemX01 = VirtualAllocEx($procHwnd_Agent01[1], 0x2B00) ;????????? _MemoryWrite64($Agent01_hook+0x5ADD24, $procHwnd_Agent01, $vtmemX01,'byte[8]') EndIf ;ElseIf $check_vtmemX>1000-1 Then ;$vtmemX01 = $check_vtmemX ;EndIf $vtmem_Agent_Playing_Now03 = $vtmemX01+0x1000 ; 0x500 $vtmem_Agent_Playing_Now03var = $vtmemX01+0x1500 ; 0x500 ;MsgBox($MB_SYSTEMMODAL, "", "$check_vtmemX: " & Hex($check_vtmemX)& "$Agent01_hook: " & Hex($Agent01_hook,8)&" $vtmemX01 "&Hex($vtmemX01) &" $vtmem_Agent_Playing_Now03 "&Hex($vtmem_Agent_Playing_Now03) &" $vtmem_Agent_Playing_Now03var "&Hex($vtmem_Agent_Playing_Now03var) ) If $check_vtmemX <> 233 Then ;MsgBox($MB_SYSTEMMODAL, "", "$check_vtmemX: " & Hex($check_vtmemX)& "$Agent01_hook: " & Hex($Agent01_hook,8)&" $vtmemX01 "&Hex($vtmemX01) &" $vtmem_Agent_Playing_Now03 "&Hex($vtmem_Agent_Playing_Now03) &" $vtmem_Agent_Playing_Now03var "&Hex($vtmem_Agent_Playing_Now03var) ) _cmp_Agent_Playing_Now03(1, $procHwnd_Agent01, $vtmem_Agent_Playing_Now03, $vtmem_Agent_Playing_Now03var, "Agent.exe") ; ve draw mini map elder rift EndIf EndIf Next ;Exit EndFunc ; da update done > CMP JMP 32BIT BATTLE.NET Func _cmp_Agent_Playing_Now03($loopacc0,$procHwnd0,$vtmem0, $vtmem0var,$module0,$address0=0x475E20) ; kiem tra enemy ; "Agent.exe"+3BD330: ;// DiabloImmortal.exe dectect process playing now ;// esi = Engine/Binaries/Win64/DiabloImmortal.exe ;// esi > hex = 88 45 6E 67 69 6E 65 2F 42 69 6E 61 72 69 65 73 2F 57 69 6E 36 34 2F 44 69 61 62 6C 6F 49 6D 6D 6F 72 74 61 6C 2E 65 78 65 00 ;// edi = Handle Event: "update processes event" ;// lea ebx,[ebx+00000000] ;movdqu xmm0,[esi] ;movdqu xmm1,[esi+10] ;// movdqu [edi],xmm0 ;// movdqu [edi+10],xmm1 ;// lea esi,[esi+20] ;// lea edi,[edi+20] ;// dec edx Local $return[9] $ws_send01_jmp = 0x4 ; $module0+$address0 jmp Next > 4byte de check co vtmem $ws_send01_back = 0x9 ; $module0+$address0 jmp back +1 $ws_send01_op01 = "F3 0F 6F 06 F3 0F 6F 4E 10" ; movdqu xmm0,[esi] ;F3 0F 7F 07 F3 0F 7F 4F 10 $vtmem_cmp00 = $vtmem0+$ws_send01_jmp $vtmem_cmp00var = $vtmem0var $cmp_jmp00 = _Module_GetBaseAddress($procHwnd0, $module0)+$address0 $vtmem_cmp00_fix = $vtmem0+$ws_send01_jmp+0x5 ; fix nop ;$cmp_jmp00 = _WinAPI_GetModuleHandle($WS2_32_dll) ;$cmp_jmp00 = _WinAPI_GetProcAddress($cmp_jmp00, "send")+$ws_send01_jmp $cmp_op00 = StringReplace("", " ", "") ; fist jmp vtmem $cmp_op00last = StringReplace($ws_send01_op01, " ", "") ; last jmp vtmem Global $op_code00 = "" Global $op_code01 = "" $vtmem_cmp00_32bit = dec(hex($vtmem_cmp00-$cmp_jmp00-0x5)) ; fix jmp 32bit $op_code00 &= $cmp_op00 ; push rax ; $op_code01 &= "50" $op_code01 &= "80 7E FF 88 0F 85 6D 00 00 00 81 3E 45 6E 67 69 0F 85 61 00 00 00 81 7E 04 6E 65 2F 42 0F 85 54 00 00 00 81 7E 16 44 69 61 62 0F 85 47 00 00 00 81 7E 1A 6C 6F 49 6D 0F 85 3A 00 00 00 81 7E 1E 6D 6F 72 74 0F 85 2D 00 00 00 81 3F 48 61 6E 64 0F 85 21 00 00 00 81 7F 16 70 72 6F 63 0F 85 14 00 00 00 81 7F 20 65 76 65 6E 0F 85 07 00 00 00 C7 46 20 72 74 30 37" ; exit01: ; pop rax ; $op_code01 &= "58" $op_code00 &= $op_code01 ;mov rcx,[rcx] ;mov rcx,[rcx+000001B8] $op_code00 &= $cmp_op00last ; jmp 7FFD9677B0CF ;$op_code00 &= "FF 25 00 00 00 00"&_ReadF($cmp_jmp00+$ws_send01_back,0)&"90" ; > v64bit ;MsgBox("","check","00 = "&Hex($vtmem_cmp00,8)&" 01 = "&Hex($cmp_jmp00+$ws_send01_back,8)&" 02 = "&"68"& _ReadF(StringReplace($cmp_jmp00+$ws_send01_back, "00000000", ""),0) &"C3 90",0) ; push address > ret $op_code00 &= "68"&HexReverse02(Hex($cmp_jmp00+$ws_send01_back,8),0)&"C3 90" ; > 32bit $op_code00 = StringReplace($op_code00, " ", "") _MemoryWrite64($vtmem_cmp00, $procHwnd0, "0x"&$op_code00,"byte["&StringLen($op_code00)/2&"]") $op_code00 = "" ;ClipPut(Hex($vtmem_cmp00)) ;MsgBox("","check","01 = "&hex($cmp_jmp00)&" 02 = "&hex($vtmem_cmp00)&" 03 = "&$op_code00,0) ; jmp to vtmem 7FFD9677B0CF ;// 32bit ;// jmp E9 CB 2C 5D 08 > 08A00000 ;// 0042D330 > 085D2CCB - 08A00000 ;// 42D335 ;// 08A00000-0042D330-5 = 85D 2CCB ;$op_code00 &= "FF 25 00 00 00 00"&_ReadF($vtmem_cmp00,0)&"90" ;MsgBox("","check","01 = "&Hex($Agent01_hook,8)&" 02 = "&Hex($cmp_jmp00,8)&" 03 = "&Hex($vtmem_cmp00_32bit),0) ;MsgBox("","check","01 = "&Hex($vtmem_cmp00_32bit,8)&" 02 = "&Hex($cmp_jmp00,8)&" 03 = "&Hex($vtmem_cmp00-$cmp_jmp00-0x5,8)&" 04 = "&Hex($vtmem0),0) ;$address_jmp_opcode = StringReplace(_ReadF($vtmem_cmp00_32bit,0), "00000000", "") $address_jmp_opcode = HexReverse02(Hex($vtmem_cmp00_32bit,8),0) $op_code00 &= "E9"&$address_jmp_opcode&"90909090" ; nop nop nop nop fix $op_code00 = StringReplace($op_code00, " ", "") ; jmp op next ; $vtmem_cmp00 = $vtmem0+$ws_send01_jmp ; $vtmem_cmp00_32bit = $vtmem_cmp00-$cmp_jmp00-0x5 ; fix jmp 32bit _MemoryWrite64($cmp_jmp00, $procHwnd0, "0x"&$op_code00,"byte["&StringLen($op_code00)/2&"]") ; > 64bit ; _Pause($process[$loopacc0],"pause") ; "pause" "return" $op_code00 = "" ;_MemoryWrite64($cmp_jmp00, $procHwnd0, $op_code00,"byte["&StringLen($op_code00)/2&"]") ;$op_code00 = "" ;_MemoryWrite64($vtmem_cmp00_fix, $procHwnd0, 0x90909090,'byte[4]') ; fix > nop $return[0] = "0x"&Hex($vtmem_cmp00) ; jmp to vtmem vi tri allocate = $vtmem_cmp00 $return[1] = "0x"&Hex($vtmem_cmp00var) ; jmp to vtmem value vi tri allocate = $vtmem_cmp00var $return[2] = "0x"&Hex($cmp_jmp00) ; vi tri default asm game = $cmp_jmp00 $return[3] = "0x"&Hex($cmp_jmp00+$ws_send01_back) ; jmp op back vi tri default asm game = $cmp_jmp00+$ws_send01_back Return $return EndFunc ; $tool_multi01 = find_class01(1, "class_name", "有米网游加速器") ; multi fake ip ; $tool_multi01 = find_class01(0, "visible_text", "登陆") ; dang nhap no title ; $tool_multi01 = find_class01(1, "class_name", "到期时间") ; multi client Func find_class01($tile00on=1, $text00="class_name",$find_class00="WTWindow") ; co tile ; Retrieve a list of window handles. Local $return00[4] = ["", "", "",""] Local $aList = WinList() If $tile00on=1 Then ; Loop through the array displaying only visable windows with a title. For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then $g_title01 = $aList[$i][0] $g_handle01 = $aList[$i][1] $g_visible_text01 = WinGetText($aList[$i][1]) ;$find_text01 = StringInStr($g_title01, $find_class00) $g_class_name01 = _WinAPI_GetClassName($aList[$i][1]) $find_text01 = StringInStr($g_class_name01, $find_class00) ;MsgBox($MB_SYSTEMMODAL, "", "$g_title01= "&$g_title01&@CRLF&" $g_handle01="&$g_handle01&" $g_class_name01="&$g_class_name01&" $g_visible_text01="&$g_visible_text01) If $text00="class_name" and $find_text01 > 0 Then ConsoleWrite("$g_title01= "&$g_title01&@CRLF&" $g_handle01="&$g_handle01&" $g_class_name01="&$g_class_name01&" $g_visible_text01="&$g_visible_text01&@CRLF) Local $return00[4] = [$g_title01, $g_handle01, $g_class_name01,$g_visible_text01] Return $return00 ElseIf $text00="visible_text" and $find_text01 > 0 Then ConsoleWrite("$g_title01= "&$g_title01&@CRLF&" $g_handle01="&$g_handle01&" $g_class_name01="&$g_class_name01&" $g_visible_text01="&$g_visible_text01&@CRLF) Local $return00[4] = [$g_title01, $g_handle01, $g_class_name01,$g_visible_text01] Return $return00 EndIf EndIf Next ElseIf $tile00on=0 Then ; Loop through the array displaying only visable windows with a title. For $i = 1 To $aList[0][0] If $aList[$i][0] = "" And BitAND(WinGetState($aList[$i][1]), 2) Then $g_title01 = $aList[$i][0] $g_handle01 = $aList[$i][1] $g_visible_text01 = WinGetText($aList[$i][1]) $find_text01 = StringInStr($g_visible_text01, $find_class00) $g_class_name01 = _WinAPI_GetClassName($aList[$i][1]) ;MsgBox($MB_SYSTEMMODAL, "", "$g_title01= "&$g_title01&@CRLF&" $g_handle01="&$g_handle01&" $g_class_name01="&$g_class_name01&" $g_visible_text01="&$g_visible_text01) If $text00="visible_text" and $find_text01 > 0 Then ConsoleWrite("$g_title01= "&$g_title01&@CRLF&" $g_handle01="&$g_handle01&" $g_class_name01="&$g_class_name01&" $g_visible_text01="&$g_visible_text01&@CRLF) Local $return00[4] = [$g_title01, $g_handle01, $g_class_name01,$g_visible_text01] Return $return00 EndIf EndIf Next EndIf Return $return00 EndFunc ;==>Example Func HexReverse01($HexString) If Not String($HexString) Then Return SetError(1, 0, 0) Local $aResult = StringSplit(StringStripWS(StringRegExpReplace(StringUpper($HexString), "\b([[:xdigit:]])\b", "0\1"), 7), " ", 2) _ArrayReverse($aResult) Return _ArrayToString($aResult, " ") EndFunc ;==>HexReverse ; No includes needed Func HexReverse02($HexString,$space0=1) If Not String($HexString) Then Return SetError(1, 0, 0) Local $aResult $HexString = StringStripWS(StringRegExpReplace($HexString, "\b([[:xdigit:]])\b", "0\1"), 8) For $i = 1 To StringLen($HexString) Step 2 If $space0=1 Then $aResult = StringMid($HexString, $i, 2) & " " & $aResult ; co dau cach If $space0=0 Then $aResult = StringMid($HexString, $i, 2) & "" & $aResult Next Return StringUpper($aResult) EndFunc ;==>HexReverse1 ; RegWrite("HKEY_CURRENT_USER\Software\d01_screen", "kvm", "REG_MULTI_SZ", $inputbox01) $vtmem_autoitX = _MemVirtualAlloc(0x0, 0x2B0000, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; khoi tao 1 lan duy nhat khong se bi error memory $vtmem_autoit_screenX = _MemVirtualAlloc(0x0, 0x2B0000, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; khoi tao 1 lan duy nhat khong se bi error memory $tCodeBuffer = ASM64_opcode01vtmem() ; khoi tao 1 lan duy nhat khong se bi error memory $title_a_star01_A12 = all_cuaso03("A_A12 ") $title_a_star01_A24 = all_cuaso03("A_A24 ") $find_title_a_star01_A12 = StringInStr($title_a_star01_A12[0], "A_A12 ") $find_title_a_star01_A24 = StringInStr($title_a_star01_A24[0], "A_A24 ") If $find_title_a_star01_A12 > 0 and $find_title_a_star01_A24 > 0 Then ; If $find_title_a_star01_A12 > 0 Then exit ElseIf $find_title_a_star01_A12 < 0+1 and $find_title_a_star01_A24 < 0+1 Then $version01 &= "_A12 "&$version01update $acc_min = 1 $loopacc = $acc_min $acc_max = 12 ElseIf $find_title_a_star01_A12 > 0 and $find_title_a_star01_A24 < 0+1 Then $version01 &= "_A24 "&$version01update $acc_min = 13 $loopacc = $acc_min $acc_max = 24 ElseIf $find_title_a_star01_A12 < 0+1 and $find_title_a_star01_A24 > 0 Then $version01 &= "_A12 "&$version01update $acc_min = 1 $loopacc = $acc_min $acc_max = 12 EndIf $loop_view01 = $acc_min $version01 &= " vtmem="&$vtmem_autoitX $vtmem_local01 = $vtmem_autoitX+0x10000 ; 0x24000 $local_case01 = 0 ; 0 = wait 1 = check find map 2 = done a star* $a_star01run = 1 ; tu dong auto = 1, tat = 0, test = 2 $not_map_max01 = 21 ; array not map max = < 9 , 21 to 41 TraySetState(2) $lp_test01max = 9999999 ; = 1 or = 9999999 $mini_map01on = 1 $Dis_star01max = 5 If $mini_map01on = 0 Then $start_red_x01 = 84-3 $start_red_y01 = 59+1 ElseIf $mini_map01on = 1 Then $start_red_x01 = 64 ; mini $start_red_y01 = 43 ; mini EndIf $map_c01x = 175 $map_c01y = 120 $find_green01max = 20 ; so sanh duong di dai nhat $find_goal01max = 2 ; so sanh duong di dai nhat $a_sandbox_fix01 = 0 ; 0 = off > num > 0 = on $a_sandbox_name01 = "b" $a_sandbox_fix02 = 0 ; 0 = off > num > 0 = on $a_sandbox_name02 = "b" $a_sandbox_fix03 = 0 ; 0 = off > num > 0 = on $a_sandbox_name03 = "b" ; START SCREEN GDI MAP ------------------------------------------------------------------------------------------------ ;Global $g_aDefault[11] = [10000, 10000, 10000, 250, 6000, 100, 0, 0, 0, 0, 0] ;set Tint to 100 > black ;Global $g_aDefault[11] = [65000, 25000, 65000, 4000, 10000, 100, 0, 0, 0, 0, 0] ;set Tint to 100 > White ;Global $g_aDefault[11] = [65000, 18000, 65000, 4000, 10000, 100, 0, 0, 0, 0, 0] ;set Tint to 100 > White MINI MAP ;Global $g_aDefault[11] = [65000, 65000, 65000, 4000, 10000, 100, -100, -100, 0, 0, 0] ;set Tint to 100 > White LARGE MAP Global $g_aDefault[11] = [65000, 17000, 65000, 4000, 10000, 100, -100, -100, 0, 0, 0] ;set Tint to 100 > White LARGE MAP $copy_view01 = 0 ; 0 = tat 1 = bat $view_screen01 = 1 ; 1 = tat 2 = copy screen $scale0 = 2.7 ; scale CATPURE02CS > screenshot full/scale $gamex01 = 720 ; 920 NOX $gamey01 = 530 ; 500 NOX $gamex01f = $gamex01-18 $gamey01f = $gamey01-41 $game_mx = 360 ; mini chrome $game_my = 400 ; mini chrome $game_cap_x01 = 0 ; 5 $game_cap_y01 = 0 ; 35 $game_cap_x02 = $gamex01 $game_cap_y02 = $gamey01 $g_x = 0 $g_y = 0 If $copy_view01=1 Then $g_hGUI = GUICreate("BitmapCloneArea test", $gamex01-6, $gamey01-29,-1,-1) GUISetState(@SW_SHOW, $g_hGUI) EndIf $process_autoit01 = @AutoItPID $version01 &= " pid="&$process_autoit01 Dim $a_sandbox[$acc_max+1] for $lp_count = 1 to $acc_max ;$m4_cuaso01[$lp_count] = "LDPlayer-"&$lp_count ;$m4_cuaso01[$lp_count] = "NoxPlayer0"&$lp_count $a_sandbox[$lp_count] = "a" If $a_sandbox_fix01 = $lp_count and $a_sandbox_fix01 <> 0 Then $a_sandbox[$lp_count] = $a_sandbox_name01 If $a_sandbox_fix02 = $lp_count and $a_sandbox_fix02 <> 0 Then $a_sandbox[$lp_count] = $a_sandbox_name02 If $a_sandbox_fix03 = $lp_count and $a_sandbox_fix03 <> 0 Then $a_sandbox[$lp_count] = $a_sandbox_name03 ;$m4_cuaso01[$lp_count] = "[#] ["& $a_sandbox[$lp_count] & $lp_count&"] Diablo Immortal [#]" ;$m4_cuaso01[$lp_count] = "[#] [a"&$lp_count&"] Diablo Immortal [#]" Next Global $procHwnd_autoit01 = _Memoryopen($process_autoit01,0x1f0fff,0) $i = $acc_min $control01 = WinGetHandle("[REGEXPTITLE:\[#\] \["& $a_sandbox[$i] & $i&"\] Diablo Immortal \[#\]]") Local $hToolTip = _GUIToolTip_Create(0), $hDC = _WinAPI_GetDC(0) Local $hFont = _WinAPI_CreateFont(32, 0, 0, 0, 800, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma') Local $hOldFont = _WinAPI_SelectObject($hDC, $hFont) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hToolTip, "wstr", 0, "wstr", 0) _SendMessage($hToolTip, $WM_SETFONT, $hFont, True) _GUIToolTip_SetTipBkColor($hToolTip, 0x000000) _GUIToolTip_SetTipTextColor($hToolTip, 0xFFFFFF) _GUIToolTip_AddTool($hToolTip, 0, "00", 0, 0, 0, 0, 0, BitOR($TTF_TRACK, $TTF_ABSOLUTE)) ; <<<<<<<<<<<<<<< _GUIToolTip_TrackPosition($hToolTip, 120, 0) ; END SCREEN GDI MAP ------------------------------------------------------------------------------------------------ Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client ;==================== START OF MAIN ================= ; Example GUI by, Hallman and Toady ; Event ID: the ID of the control sending the message ; $GUI_EVENT_NONE (0): No event ; $GUI_EVENT_CLOSE: dialog box being closed (either by defined button or system menu). ; $GUI_EVENT_MINIMIZE: dialog box minimized with Windows title bar button. ; $GUI_EVENT_RESTORE: dialog box restored by click on task bar icon. ; $GUI_EVENT_MAXIMIZE: dialog box maximized with Windows title bar button. ; $GUI_EVENT_MOUSEMOVE: the mouse cursor has moved. ; $GUI_EVENT_PRIMARYDOWN: the primary mouse button was pressed. ; $GUI_EVENT_PRIMARYUP: the primary mouse button was released. ; $GUI_EVENT_SECONDARYDOWN: the secondary mouse button was pressed. ; $GUI_EVENT_SECONDARYUP: the secondary mouse button was released. ; $GUI_EVENT_RESIZED: dialog box has been resized. ; $GUI_EVENT_DROPPED: End of a Drag&Drop action @GUI_DragId, @GUI_DragFile and @GUI_DropId will be used to retrieve the ID's/file corresponding to the involve control. Global $first_label = 0 Global $last_label = 0 ;Global Const $rows = 36 ;Global Const $cols = 36 Global $estimate Global $closedList_data Global $closedList_Str = "_" Global $openList_Str = "_" Global $start_handel[3] Global $end_handel[3] Global $barrier[] = [-1] Global $heuristic = 1 Global $allow_diagonals_Boolean = 1 ; 1 = chay 8 0 = chay 4 ;Global $cols = Int(51*2) ;Global $rows = Int(38*2) ;Global $cols = Int(166/1)+1 ;Global $rows = Int(129/1)+1 $col_scale = Int(129/$scale0) +3 $rows_scale = Int(87/$scale0) +3 ;$col_scale = 320 ;$rows_scale = 241 Global $cols = $col_scale Global $rows = $rows_scale $tiled_map01 = 1 $crop_check = 0 ; 1 = minx+1 maxx-1 miny+1 maxy-1 Global $start_cols01, $start_rows01, $start_red = 0 Global $goal_cols01, $goal_rows01, $goal_green = 0 Global $listnindex, $target_found = 0 Dim $open[$cols * $rows + 1] ;why one-dimensional? so that you can convert it to a struct^^ Dim $close[$cols * $rows + 1][3] ;list of the best candidates Dim $path01[0] ;start from goal node Dim $a_map_goal01[$acc_max + 1] ; all goal node Dim $a_op_code[199999] Dim $a_fog_map01[$acc_max + 1] Dim $a_local01[$acc_max + 1] Dim $a_map_min00x[$acc_max + 1] Dim $a_map_max00x[$acc_max + 1] Dim $a_map_min00y[$acc_max + 1] Dim $a_map_max00y[$acc_max + 1] Dim $a_not_map01[$acc_max + 1] Dim $battle01exeX[$acc_max + 1] For $loopacc = $acc_min to $acc_max $a_map_goal01[$loopacc] = 0 ; all goal node $a_fog_map01[$loopacc] = 0 $a_local01[$loopacc] = $vtmem_local01+0x1000*$loopacc $a_not_map01[$loopacc] = 0 If $loopacc > 0 and $loopacc < 10 Then $battle01exeX[$loopacc] = "Batt0"&$loopacc&".net.exe" ElseIf $loopacc > 10-1 and $loopacc < 24+1 Then $battle01exeX[$loopacc] = "Batt"&$loopacc&".net.exe" EndIf Next $loopacc = $i ; reset one tab game ;ClipPut($a_local01[$loopacc]) $w = 720 ; 720-17 $h = 530 ; 530-43 $distance = 0 ; khoang cach tiled map $sleep_find01 = 0 $map_trans01 = 255 ;$tileWidth = ($w/$col_scale)-$distance ;$tileHeight = ($h/$rows_scale)-$distance $tileWidth = $scale0 $tileHeight = $scale0 $tileWidth_pos = $tileWidth $tileHeight_pos = $tileHeight $title_size01x = ($tileWidth + $distance) $title_size01y = ($tileHeight + $distance) $mini_min01x = Int(550/$scale0) $mini_max01x = Int(679/$scale0) $mini_min01y = Int(2/$scale0) $mini_max01y = Int(89/$scale0) ; 129 ; 87 $start_cols01 = Int(64/$scale0) $start_rows01 = Int(43/$scale0) Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client ; Create GUI $hGUI = GUICreate($version01, $w, $h+$rows+190, -1, -1, -1, $WS_EX_LAYERED) GUICtrlCreateGraphic(0, 0, $w, $h) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, $w, $h) GUICtrlSetBkColor(-1, 0xABCDEF) DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hGUI, "long", 0xEFCDAB , "byte", 255, "long", 0x1 + 0x2) $button_auto01 = button_all01(5,$h+(19*11)-185,0xbadeff,"AUTO01","CHECK Responding","VIEW_NUMBER01", "REMOVE_NUMBER01", "View_Not_Map","LOOP_NEXT","AUTO STOP" ) $button_auto02 = button_all01(5,$h+(19*12)-185,0xb4a7d6,"AUTO02","START_S","TARGET_T", "WALL_X", "FLAT_0","DIAGONA","PATHFIND_A*" ) $button_auto03 = button_all01(5,$h+(19*13)-185,0x22a7d6,"AUTO03","G_MAP1","G_MINI_MAP1", "SLOW_MOVE01", "VIEW_GDI01","START_FLIP01","ALL_FIND_A*" ) $background01color = 0x333333 ;$button_submit01 = GUICtrlCreateEdit("$N_SUBMIT01"&@CRLF&"Type here"&@CRLF, 5,$h+(19*14)-190, 350, 140 ) Global $button_submit01 = GUICtrlCreateList("VIEW img list", 5,$h+(19*15)-190, 350, 140, BitOr($LBS_EXTENDEDSEL, $WS_BORDER, $WS_HSCROLL, $WS_VSCROLL)) ; tat xep array theo abc GUICtrlSetLimit($button_submit01, 2000) GUICtrlSetColor($button_submit01, 0x9fc5e8) GUICtrlSetBkColor($button_submit01, $background01color) ;$button_submit02 = GUICtrlCreateEdit("$N_SUBMIT02"&@CRLF&"Type here"&@CRLF, 360,$h+(19*14)-190, 350, 140, BitOR($WS_HSCROLL, $WS_VSCROLL)) ;Global $button_submit02 = GUICtrlCreateList("VIEW img list", 360,$h+(19*15)-190, 350, 140, BitOr($LBS_EXTENDEDSEL, $WS_BORDER, $WS_HSCROLL, $WS_VSCROLL)) ; tat xep array theo abc Global $button_submit02 = GUICtrlCreateEdit("VIEW img list", 360,$h+(19*15)-190, 350, 140, BitOr($LBS_EXTENDEDSEL, $WS_BORDER, $WS_HSCROLL, $WS_VSCROLL)) ; tat xep array theo abc GUICtrlSetLimit($button_submit02, 2000) GUICtrlSetColor($button_submit02, 0x9fc5e8) GUICtrlSetBkColor($button_submit02, $background01color) ;GUICtrlSetState( ($button_auto01[1])[7-1], $GUI_CHECKED) ;GUICtrlSetState( ($button_auto03[4])[7-1], $GUI_CHECKED) GUICtrlSetState( ($button_auto02[5])[7-1], $GUI_CHECKED) GUISetState(@SW_SHOW) ;WinSetTrans($hGUI , "" ,155) Sleep(100) Func button_all01($x0=10,$y0=$h+(19*3)-185,$color0=0xffffff,$name0="name0",$name1="name1",$name2="name2",$name3="name3",$name4="name4",$name5="name5",$name6="name6") ; 0 "ACTIVE" 7-1 check point, 1 "DESCRIPTION", 2 "ADDRESS", 3 "TYPE", 4 "VALUE" Local $button_memory00[7] $all_width01 = 105-9 $all_width02 = $all_width01+5 $button_memory00[0] = button_view01($name0&" ?", $x0+0, $y0, $all_width01, 20,$color0) $button_memory00[1] = button_checkbox01($name1,$x0+$all_width02*1, $y0, $all_width01, 20,$color0-0x000111) $button_memory00[2] = button_checkbox01($name2,$x0+$all_width02*2, $y0, $all_width01, 20,$color0-0x000111) $button_memory00[3] = button_checkbox01($name3,$x0+$all_width02*3, $y0, $all_width01, 20,$color0-0x000111) $button_memory00[4] = button_checkbox01($name4,$x0+$all_width02*4, $y0, $all_width01, 20,$color0-0x000111) $button_memory00[5] = button_checkbox01($name5,$x0+$all_width02*5, $y0, $all_width01, 20,$color0-0x000111) $button_memory00[6] = button_checkbox01($name6, $x0+$all_width02*6, $y0, $all_width01, 20,$color0-0x000111) Return $button_memory00 EndFunc Func button_view01($name0,$x0,$y0,$w0,$h0,$color0) Local $button01[7] = [$name0, $x0, $y0, $w0, $h0, $color0,"id"] ; x y width height color id $button00xy = $button01 $button01[7-1] = GUICtrlCreateButton($button00xy[0], $button00xy[1], $button00xy[2], $button00xy[3], $button00xy[4]) If $color0 <> "" Then GUICtrlSetBkColor($button01[7-1], $color0) $button00xy = $button01 Return $button00xy EndFunc Func button_checkbox01($name0,$x0,$y0,$w0,$h0,$color0) Local $button01[7] = [$name0, $x0, $y0, $w0, $h0, $color0,"id"] ; x y width height color id $button00xy = $button01 $button01[7-1] = GUICtrlCreateCheckbox($button00xy[0], $button00xy[1], $button00xy[2], $button00xy[3], $button00xy[4]) If $color0 <> "" Then GUICtrlSetBkColor($button01[7-1], $color0) $button00xy = $button01 Return $button00xy EndFunc Local $hGUI01 = GUICreate("11", $w, $h, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI) ;GUISetBkColor(0xABCDEF) ;_WinAPI_SetLayeredWindowAttributes($hGUI01, 0xABCDEF) GUISetState(@SW_SHOW, $hGUI01) WinSetTrans($hGUI01 , "" ,$map_trans01) $red = 0xFFFF0000 $green = 0xFF00FF00 $blue = 0xFF0000FF $black = 0xFF000000 $white = 0xFFF6F6F4 $gray = 0xFFFFFFFF $mask = 0xFFFF00FF $yellow = 0xFFFF9A31 ; Start GDIPlus _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI01) ; Create solid brush $Brush_red = _GDIPlus_BrushCreateSolid() $Brush_green = _GDIPlus_BrushCreateSolid() $Brush_blue = _GDIPlus_BrushCreateSolid() $Brush_black = _GDIPlus_BrushCreateSolid() $Brush_white = _GDIPlus_BrushCreateSolid() $Brush_gray = _GDIPlus_BrushCreateSolid() $Brush_mask = _GDIPlus_BrushCreateSolid() $Brush_yellow = _GDIPlus_BrushCreateSolid() ; Get solid brush color ;$iClr1 = _GDIPlus_BrushGetSolidColor($hBrush1) ; Draw some graphics with the original brush color ;_GDIPlus_GraphicsFillEllipse($hGraphic, 25, 25, 100, 100, $hBrush1) ; Set new brush color (0xFFFF0000 = Red) _GDIPlus_BrushSetSolidColor($Brush_red, $red) _GDIPlus_BrushSetSolidColor($Brush_green, $green) _GDIPlus_BrushSetSolidColor($Brush_blue, $blue) _GDIPlus_BrushSetSolidColor($Brush_black, $black) _GDIPlus_BrushSetSolidColor($Brush_white, $white) _GDIPlus_BrushSetSolidColor($Brush_gray, $gray) _GDIPlus_BrushSetSolidColor($Brush_mask, $mask) _GDIPlus_BrushSetSolidColor($Brush_yellow, $yellow) ; Get new solid brush color ;$iClr2 = _GDIPlus_BrushGetSolidColor($hBrush1) ;============ * How to use this code * ============ ; Below is the A * Searching algorithm and its ; required functions to work. ; This is coded to work with 2D spaces only. ; Everything below is all you need to get started. Dim $data_reset[$rows][$cols] Local $iColsX = UBound($data_reset, $UBOUND_COLUMNS) ; Total number of columns. In this example it will be 20. Local $iRowsY = UBound($data_reset, $UBOUND_ROWS) ; Total number of rows. In this example it will be 10. For $lp_y = 0 to $iRowsY-1 For $lp_x = 0 to $iColsX-1 $data_reset[$lp_y][$lp_x] = "x" Next Next Dim $data[$rows][$cols] ; 1. Initialize a 2D array Dim $data_map[$rows][$cols] = [["x","x","x","x","x","x","x","x","x","x","x","x","x","x","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","x","0","0","0","0","0","0","0","0","x"], _ ["x","0","s","0","0","x","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","x","0","0","g","0","0","0","0","0","x"], _ ["x","0","0","0","0","x","0","0","0","0","0","0","0","0","x"], _ ["x","0","0","0","0","x","0","0","0","0","0","0","0","0","x"], _ ["x","x","x","x","x","x","x","x","x","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","x","x","x","x","x","x","x","x","0","0","0","0","0","x"], _ ["x","0","0","0","0","0","0","0","0","0","0","0","0","0","x"], _ ["x","x","x","x","x","x","x","x","x","0","0","0","0","0","x"], _ ["x","x","x","x","x","x","x","x","x","x","x","x","x","x","x"]] ;_ArrayDisplay($data_map) ; will show the the full path ;MsgBox($MB_SYSTEMMODAL, "Title", "$start_cols01="&$data_map[0][0], 0) ;_GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $w, $w+50, $Brush_mask) $data = $data_map ;draw_map01($tiled_map01,0, $cols, 0,$rows) ;_ArrayDisplay($data_map) ; will show the the full path GUISetState() While 1 ;$msg = GUIGetMsg() ;Switch $msg Switch 1 ;Case $GUI_EVENT_CLOSE ; bo ko dung toi ;ExitLoop Case $GUI_EVENT_RESTORE ;draw_map01($tiled_map01,$mini_min01x, $mini_max01x, $mini_min01y,$mini_max01y) ;Case _IsPressed('01') = True or $a_star01run = 1 ; $open[0] To $open[$cols * $rows - 1] ; If _IsPressed('01') = True or $a_star01run = 1 Then ; start check press mouse left Case $a_star01run > 0 ; $open[0] To $open[$cols * $rows - 1] ;If $a_star01run = 1 Then ; start check press mouse left > DONE If $a_star01run = 1 or $a_star01run = 2 and _IsPressed('01') = True Then ; start check press mouse left > TEST Local $aPos = MouseGetPos() $xx = Int($aPos[0]/($tileWidth+$distance)) $yy = Int($aPos[1]/($tileHeight+$distance)) ;If $xx > 0 And $yy > 0 And $xx < $cols -1 And $yy < $rows -1 or $a_star01run = 1 Then ; within the border area If $a_star01run > 0 Then ; within the border area ;ConsoleWrite("Primary down"&" MouseGetPos="&$aPos[0]&","&$aPos[1]&" $xxyy="&$xx&","&$yy& @CR) If _IsChecked( ($button_auto02[1])[7-1] ) = True Then If $start_red <> 0 Then $data_map[$start_rows01][$start_cols01] = "0" If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $start_cols01 * ($tileWidth + $distance) + $distance, $start_rows01 * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_gray) EndIf $start_cols01 = $xx $start_rows01 = $yy $data_map[$start_rows01][$start_cols01] = "s" $start_red = ($yy - 0) * $cols + ($xx - 0) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $start_cols01 * ($tileWidth + $distance) + $distance, $start_rows01 * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_red) GUICtrlSetData($button_submit02, "") GUICtrlSetData($button_submit02, "$MOVE_X_Y"&" X="&$xx&" Y="&$yy&@CR) ;ConsoleWrite("$GUI_EVENT_PRIMARYDOWN"&" $start_cols01="&$start_cols01&" $start_rows01="&$start_rows01& @CR) ;_ArrayDisplay($data_map) ; will show the the full path EndIf ; end checkbox MEmu01 If _IsChecked( ($button_auto02[2])[7-1] ) = True Then If $goal_green <> 0 Then $data_map[$goal_rows01][$goal_cols01] = "0" If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $goal_cols01 * ($tileWidth + $distance) + $distance, $goal_rows01 * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_gray) EndIf $goal_cols01 = $xx $goal_rows01 = $yy $data_map[$goal_rows01][$goal_cols01] = "g" $goal_green = ($yy - 0) * $cols + ($xx - 0) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $goal_cols01 * ($tileWidth + $distance) + $distance, $goal_rows01 * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_green) GUICtrlSetData($button_submit02, "") GUICtrlSetData($button_submit02, "$MOVE_X_Y"&" X="&$xx&" Y="&$yy&@CR) ;ConsoleWrite("$GUI_EVENT_PRIMARYDOWN"&" $goal_cols01="&$goal_cols01&" $goal_rows01="&$goal_rows01& @CR) ;_ArrayDisplay($data_map) ; will show the the full path EndIf ; end checkbox MEmu01 If _IsChecked( ($button_auto02[3])[7-1] ) = True Then $wall_cols01 = $xx $wall_rows01 = $yy $data_map[$wall_rows01][$wall_cols01] = "x" If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $xx * ($tileWidth + $distance) + $distance, $yy * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_black) GUICtrlSetData($button_submit02, "") GUICtrlSetData($button_submit02, "$MOVE_X_Y"&" X="&$xx&" Y="&$yy&@CR) ;ConsoleWrite("$GUI_EVENT_PRIMARYDOWN"&" $wall_cols01="&$wall_cols01&" $wall_rows01="&$wall_rows01& @CR) EndIf ; end checkbox MEmu01 If _IsChecked( ($button_auto02[4])[7-1] ) = True Then $flat_cols01 = $xx $flat_rows01 = $yy $data_map[$flat_rows01][$flat_cols01] = "0" If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $xx * ($tileWidth + $distance) + $distance, $yy * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_gray) GUICtrlSetData($button_submit02, "") GUICtrlSetData($button_submit02, "$MOVE_X_Y"&" X="&$xx&" Y="&$yy&@CR) ;ConsoleWrite("$GUI_EVENT_PRIMARYDOWN"&" $flat_cols01="&$flat_cols01&" $flat_rows01="&$flat_rows01& @CR) EndIf ; end checkbox MEmu01 EndIf ; end within the border area ;Sleep(10) Local $aPos = MouseGetPos() $mx = Int($aPos[0]) $my = Int($aPos[1]) Local $aPos = WinGetPos("[ACTIVE]") $wx = $aPos[0] $wy = $aPos[1] $xx = $mx $yy = $my ; START ALL BUTTION ; button_auto01 ----------------------------------------- ;If $xx > ($button_auto01[0])[1] And $yy > ($button_auto01[0])[2] And $xx < ($button_auto01[0])[1]+($button_auto01[0])[3] And $yy < ($button_auto01[0])[2]+($button_auto01[0])[4] or $a_star01run = 1 Then ; click button "Select" If $a_star01run = 1 Then ; click button "Select" $time_start01 = TimerInit() $tooltip_sleep01 = 0 ; SKILL 1 summon danh xa 7s $tooltip_sleep02 = 0 For $loop_auto01 = 1 to 99999999 ; vong lap auto For $loopacc = $acc_min to $acc_max $i = $loopacc $control01 = WinGetHandle("[REGEXPTITLE:\[#\] \["& $a_sandbox[$i] & $i&"\] Diablo Immortal \[#\]]") $time_stop01 = int(TimerDiff($time_start01)) ;ToolTip("N="&$loopacc&" $time_stop01="&$time_stop01&" $tooltip_sleep01="&$tooltip_sleep01&" $tooltip_sleep02="&$tooltip_sleep02, 0, 0) If $acc_min = 1 Then _battle_diablo_title01() EndIf If $acc_min = 1 Then $battle01 = find_process02($battle01exeX[$i]) If $battle01[0] = $battle01exeX[$i] and StringInStr($battle01[3],"[#]") < 0+1 Then ;_ArrayDisplay($battle01) WinSetTitle($battle01[2], "", "[#] [a"&$i&"] "&$battle01[3]&" [#]") EndIf If $time_stop01 > $tooltip_sleep02 Then _CompareProcess01("DiabloImmortal.exe", "[#] [a"&$i&"] "&"Diablo Immortal [#]") $tooltip_sleep02 = $time_stop01+1000 EndIf $diablo_fix01 = find_class01(0, "visible_text", "New version available, please restart the game to continue downloading. (EUWF)") ; dang nhap no title ;_ArrayDisplay( $diablo_fix01) If $diablo_fix01[3] <> "" Then ;_ArrayDisplay( $diablo_fix01) WinClose($diablo_fix01[1]) ;ControlSend($diablo_fix01[1], "", "", "{ENTER}") EndIf ElseIf $acc_min = 13 Then $battle01 = find_process02($battle01exeX[$i]) If $battle01[0] = $battle01exeX[$i] and StringInStr($battle01[3],"[#]") < 0+1 Then ;_ArrayDisplay($battle01) WinSetTitle($battle01[2], "", "[#] [a"&$i&"] "&$battle01[3]&" [#]") EndIf If $time_stop01 > $tooltip_sleep02 Then _CompareProcess01("DiabloImmortal.exe", "[#] [a"&$i&"] "&"Diablo Immortal [#]") $tooltip_sleep02 = $time_stop01+1000 EndIf EndIf _angent_playing_now01() If $time_stop01 > $tooltip_sleep01 Then ; kvm tooltip If $acc_min = 1 and _IsChecked( ($button_auto01[2])[7-1] ) = True Then $hToolTip_reg = RegRead("HKEY_CURRENT_USER\Software\d01_screen", "kvm" ) If $acc_min = 1 and $hToolTip_reg = "" Then $inputbox01 = InputBox("VIEW_NUMBER01 " , "VIEW_NUMBER01 = 01 > 04 "&@CRLF&@CRLF , "00" , " M99") _GUIToolTip_UpdateTipText($hToolTip, 0, 0, $inputbox01) _GUIToolTip_TrackActivate($hToolTip, True, 0, 0) RegWrite("HKEY_CURRENT_USER\Software\d01_screen", "kvm", "REG_MULTI_SZ", $inputbox01) ElseIf $acc_min = 1 and $hToolTip_reg <> "" Then _GUIToolTip_UpdateTipText($hToolTip, 0, 0, $hToolTip_reg&_reghive04EX(3)) _GUIToolTip_TrackActivate($hToolTip, True, 0, 0) EndIf GUICtrlSetState( ($button_auto01[2])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto01[3])[7-1], $GUI_CHECKED) ElseIf $acc_min = 1 and _IsChecked( ($button_auto01[3])[7-1] ) = True Then ;$hToolTip = RegRead("HKEY_CURRENT_USER\Software\d01_screen", "kvm" ) ;MsgBox($MB_SYSTEMMODAL, "", "kvm = "&$hToolTip) _GUIToolTip_UpdateTipText($hToolTip, 0, 0, $hToolTip_reg&_reghive04EX(3)) WinSetOnTop($hToolTip, "", 1) ElseIf $acc_min = 1 and _IsChecked( ($button_auto01[3])[7-1] ) = False Then _GUIToolTip_TrackActivate($hToolTip, False, 0, 0) EndIf If $acc_min = 13 Then $state = find_process_no_title_03("DiabloImmortal.exe") If $state = 2 and $not_responding_num01 < 30+1 Then $not_responding_num01 += 1 GUICtrlSetData( ($button_auto01[1])[7-1] ,"NOT "&$not_responding_num01&" Responding" ) ; date ElseIf $state = 2 and $not_responding_num01 > 30 Then $state = find_process_no_title_03("DiabloImmortal.exe",1) GUICtrlSetData( ($button_auto01[1])[7-1] ,"NOT "&$not_responding_num01&" CLOSE" ) ; date ElseIf $state <> 2 Then $not_responding_num01 = 0 GUICtrlSetData( ($button_auto01[1])[7-1] ,"CHECK "&$not_responding_num01&" Responding" ) ; date EndIf Func find_process_no_title_03($exeName="DiabloImmortal.exe",$close0=0) Local $procList = ProcessList($exeName) If @error Or $procList[0][0] = 0 Then Return 0 ; chưa có process nào For $i = 1 To $procList[0][0] Local $pid = $procList[$i][1] Local $winList = WinList() Local $hasWindow = False For $j = 1 To $winList[0][0] If WinGetProcess($winList[$j][1]) = $pid And BitAND(WinGetState($winList[$j][1]), 2) Then $hasWindow = True Local $title = $winList[$j][0] Local $hWnd = $winList[$j][1] ; kiểm tra treo trước If _IsHungWindow($hWnd) Then If $close0=1 Then ProcessClose($pid) ; kill process Return 2 ; treo EndIf ; nếu chưa treo nhưng title rỗng → coi như đang load If $title = "" Then Return 1 EndIf Next ; nếu có PID nhưng chưa có cửa sổ nào → coi như đang load If Not $hasWindow Then Return 1 Next Return 0 ; bình thường EndFunc Func _IsHungWindow($hWnd) Local $ret = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $hWnd) If @error Then Return False Return $ret[0] <> 0 EndFunc EndIf $tooltip_sleep01 = $time_stop01+7000 EndIf ; end kvm tooltip If $control01 = "" Then ; $time_stop01 = int(TimerDiff($time_start01)) _MemoryWrite64($a_local01[$loopacc]+0x104, $procHwnd_autoit01, ptr(0),'byte[4]') ; reset value = 0 ;$local_case01 = _MemoryRead64($a_local01[$loopacc]+0x0, $procHwnd_autoit01, 'byte[4]',"Dec") $local_case01 = 0 Sleep(150) ; GUICtrlSetData($button_submit02, "") ; GUICtrlSetData($button_submit02,"N="&$loopacc&" $time_stop01="&$time_stop01&" $local_case01="&$local_case01&" $control01 = 0 ","") ElseIf $control01 <> "" Then ; find diablo tab ; $time_stop01 = int(TimerDiff($time_start01)) $local_case01 = _MemoryRead64($a_local01[$loopacc]+0x0, $procHwnd_autoit01, 'byte[4]',"Dec") ; $local_case01x1 = _MemoryRead64($a_local01[$loopacc]+0x10, $procHwnd_autoit01, 'byte[4]',"Dec") ; $local_case01y1 = _MemoryRead64($a_local01[$loopacc]+0x14, $procHwnd_autoit01, 'byte[4]',"Dec") ; $local_case01x2 = _MemoryRead64($a_local01[$loopacc]+0x20, $procHwnd_autoit01, 'byte[4]',"Dec") ; $local_case01y2 = _MemoryRead64($a_local01[$loopacc]+0x24, $procHwnd_autoit01, 'byte[4]',"Dec") $local_case01x1 = Int( _MemoryRead6401_fix( "0x"&Hex($a_local01[$loopacc]+0x10) , $procHwnd_autoit01, 'float') ) ; type = ( byte, float, dword, char[], byte[] ... etc ) $local_case01y1 = Int( _MemoryRead6401_fix( "0x"&Hex($a_local01[$loopacc]+0x14) , $procHwnd_autoit01, 'float') ) ; type = ( byte, float, dword, char[], byte[] ... etc ) $local_case01x2 = Int( _MemoryRead6401_fix( "0x"&Hex($a_local01[$loopacc]+0x20) , $procHwnd_autoit01, 'float') ) ; type = ( byte, float, dword, char[], byte[] ... etc ) $local_case01y2 = Int( _MemoryRead6401_fix( "0x"&Hex($a_local01[$loopacc]+0x24) , $procHwnd_autoit01, 'float') ) ; type = ( byte, float, dword, char[], byte[] ... etc ) $local_case01x3 = ($local_case01x2-$local_case01x1) $local_case01y3 = ($local_case01y2-$local_case01y1) $portal_x01 = 347 $portal_y01 = 257 $portal_x02 = $portal_x01+$local_case01x3 $portal_y02 = $portal_y01+$local_case01y3 ;$portal_xy03 = _mouse45( $portal_x02, $portal_y02,$portal_x01,$portal_y01,1,1,347,257) $Distance_portal01 = -1 If $local_case01x1 = 0 and $local_case01x2 = 0 and $a_not_map01[$loopacc] <> 0 Then ; 0 reset not map $a_not_map01[$loopacc] = 0 EndIf $local_path01max = _MemoryRead64($a_local01[$loopacc]+0x104, $procHwnd_autoit01, 'byte[4]',"Dec") Sleep(100) $k = $local_case01 $t = $local_case01 If _IsChecked( ($button_auto01[5])[7-1] ) = True Then $inputbox01 = InputBox("PASS " , "$LOOP_ACC "&$acc_min&" > "&$acc_max&@CRLF&@CRLF&"$LOOP_ACC "&$acc_min&" > "&$acc_max , "1" , " M99") $loop_view01 = $inputbox01 GUICtrlSetState( ($button_auto01[5])[7-1], $GUI_UNCHECKED) EndIf If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, "") If _IsChecked( ($button_auto01[4])[7-1] ) = False Then ;GUICtrlSetData($button_submit02,"$k[0]="&$k[0]&" $k[1]="&$k[1]&" $k[2]="&$k[2]&" $k[3]="&$k[3]&" $k[4]="&$k[4]&" $k[5]="&$k[5]&" $k[6]="&$k[6],"") ;GUICtrlSetData($button_submit02,"$t[0]="&$t[0]&" $t[1]="&$t[1]&" $t[2]="&$t[2]&" $t[3]="&$t[3]&" $t[4]="&$t[4]&" $t[5]="&$t[5]&" $t[6]="&$t[6],"") ; GUICtrlSetData($button_submit02,"N="&$loopacc&" $time_stop01="&$time_stop01&" $local_case01="&$local_case01,"") ; GUICtrlSetData($button_submit02,"N="&$loopacc&" $local_path01max="&$local_path01max&" $local_case01="&$local_case01,"") ; GUICtrlSetData($button_submit02,"N="&$loopacc&" $find_green01max="&$find_green01max&" $find_goal01max="&$find_goal01max,"") ; GUICtrlSetData($button_submit02,"N="&$loopacc&" _case01x1="&$local_case01x1&" _case01y1="&$local_case01y1&" _case01x2="&$local_case01x2&" _case01y2="&$local_case01y2,"") ; GUICtrlSetData($button_submit02,"N="&$loopacc&" _case01x3="&$local_case01x3&" _case01y3="&$local_case01y3&" $portal_x01="&$portal_x01&" $portal_y01="&$portal_y01,"") ; GUICtrlSetData($button_submit02,"N="&$loopacc&" $portal_x02="&$portal_x02&" $portal_y02="&$portal_y02&" $Distance_portal01="&$Distance_portal01&" $a_local01[]="&Hex($a_local01[$loopacc]),"") GUICtrlSetData($button_submit02, "" & _ "N="&$loopacc&" $time_stop01="&$time_stop01&" $local_case01="&$local_case01&@CRLF & _ "N="&$loopacc&" $local_path01max="&$local_path01max&" $local_case01="&$local_case01&@CRLF & _ "N="&$loopacc&" $find_green01max="&$find_green01max&" $find_goal01max="&$find_goal01max&@CRLF & _ "N="&$loopacc&" _case01x1="&$local_case01x1&" _case01y1="&$local_case01y1&" _case01x2="&$local_case01x2&" _case01y2="&$local_case01y2&@CRLF & _ "N="&$loopacc&" _case01x3="&$local_case01x3&" _case01y3="&$local_case01y3&" $portal_x01="&$portal_x01&" $portal_y01="&$portal_y01&@CRLF & _ "N="&$loopacc&" $portal_x02="&$portal_x02&" $portal_y02="&$portal_y02&" $Distance_portal01="&$Distance_portal01&" $a_local01[]="&Hex($a_local01[$loopacc])&@CRLF & _ "" ) ElseIf _IsChecked( ($button_auto01[4])[7-1] ) = True Then GUICtrlSetData($button_submit02, _ArrayToString($a_not_map01[$loopacc])) EndIf EndIf Select Case $local_case01 = 1 ; 1 start new map Local $hTimer = TimerInit() ; START WinCapture_cs03 ---------------------------------------------------------------------------------------------------------------------- Global $stream02 = WinCapture_cs05($control01,3,$game_cap_x02,$game_cap_y02,$view_screen01,$game_cap_x01,$game_cap_y01,$g_x,$g_y,$copy_view01) ; chay only show gui image $a_fog_green02xy = $stream02[12] WinCapture_ce03($stream02[3], $stream02[4], $stream02[5], $stream02[6], $stream02[7], $stream02[0], $stream02[13]) ; remove print image -------------------------- ; END WinCapture_cs03 ---------------------------------------------------------------------------------------------------------------------- $control01 = WinGetHandle("[REGEXPTITLE:\[#\] \["& $a_sandbox[$i] & $i&"\] Diablo Immortal \[#\]]") $local_case01 = _MemoryRead64($a_local01[$loopacc]+0x0, $procHwnd_autoit01, 'byte[4]',"Dec") If $control01 = "" or $local_case01 = 0 Then _MemoryWrite64($a_local01[$loopacc]+0x104, $procHwnd_autoit01, ptr(0),'byte[4]') ; reset value = 0 Local $iDiff = TimerDiff($hTimer) ; time in seconds ; If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " $iDiff="&Int($iDiff)&"s"&@CRLF&" _all_find_a03($loopacc) FALSE") ElseIf $control01 <> "" and $local_case01 = 1 Then ; find diablo tab If $a_map_min00x[$loopacc] < 20 and $a_map_max00x[$loopacc] > $col_scale-20 and $a_map_min00y[$loopacc] < 20 and $a_map_max00y[$loopacc] > $rows_scale-20 Then _MemoryWrite64($a_local01[$loopacc]+0x104, $procHwnd_autoit01, ptr(0),'byte[4]') ; reset value = 0 ; If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " N="&$loopacc&" _all_find_a03($loopacc) = "&"FALSE LARGE MAP") ElseIf $stream02[14] = 0 Then _MemoryWrite64($a_local01[$loopacc]+0x104, $procHwnd_autoit01, ptr(0),'byte[4]') ; reset value = 0 ; If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " N="&$loopacc&" _all_find_a03($loopacc) = "&"FALSE LARGE MAP") Else ; If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " N="&$loopacc&" _all_find_a03($loopacc) = "&"TRUE LARGE MAP") $max6 = UBound($a_not_map01[$loopacc], $UBOUND_ROWS)-1 ;If $local_case01x1 = 0 and $local_case01x2 = 0 and $a_not_map01[$loopacc] <> 0 Then ; 0 reset not map ; $a_not_map01[$loopacc] = 0 ;EndIf If $local_case01x1 <> 0 and $local_case01x2 <> 0 and $a_not_map01[$loopacc] = 0 Then ; 1 start not map Local $aArray_not_map01[1][6] = [["ID NAME", "SPACE X", "SPACE Y", "N SPACE X", "N SPACE Y", "DISTANCE"]] $a_not_map01[$loopacc] = $aArray_not_map01 ; _ArrayAdd($a_fog_map01[$loopacc] > ($a_fog_map01[$loopacc])[1][2] _ArrayAdd($a_not_map01[$loopacc], "por="&1& " | "& $portal_x01 & " | "&$portal_y01& " | "&$portal_x02&" | "&$portal_y02&" | "&"-1") ElseIf $local_case01x1 <> 0 and $local_case01x2 <> 0 and $a_not_map01[$loopacc] <> 0 and $max6 > 0 and $max6 < $not_map_max01 Then ; 2 add not map $portal_xy03 = _mouse45( $portal_x02, $portal_y02,$portal_x01,$portal_y01,1,1,347,257) $player_step01x = ($a_not_map01[$loopacc])[$max6][3] $player_step01y = ($a_not_map01[$loopacc])[$max6][4] $Distance_portal01 = Int( Distance($portal_xy03[0],$portal_xy03[1],$player_step01x,$player_step01y) ) If $Distance_portal01 > 28 Then _ArrayAdd($a_not_map01[$loopacc], "por="&$max6+1& " | "& $player_step01x &" | "&$player_step01y&" | "&$portal_xy03[0]&" | "&$portal_xy03[1]&" | "&"-1") EndIf ; end 0 reset not map $random0 = Random(1,2,1) _all_find_a04($loopacc,35,$random0,$max6) If $loopacc = $loop_view01 Then If $max6 > 0 Then For $lp_n = 1 to $max6 $player_step01x = ($a_not_map01[$loopacc])[$lp_n][3] $player_step01y = ($a_not_map01[$loopacc])[$lp_n][4] _GDIPlus_GraphicsFillRect($hGraphic, $player_step01x+0, $player_step01y+0 , $tileWidth, $tileHeight, $Brush_yellow) Next EndIf EndIf EndIf Local $iDiff = TimerDiff($hTimer) ; time in seconds ; If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " $iDiff="&Int($iDiff)&"s"&@CRLF&" _all_find_a03($loopacc) TRUE") _MemoryWrite64($a_local01[$loopacc]+0x0, $procHwnd_autoit01, ptr(2),'byte[4]') ; reset value = 0 EndIf EndSelect EndIf ; end find diablo tab Next If _IsChecked( ($button_auto01[6])[7-1] ) = True Then Exit $loop_auto01 = 999999999 ; check x stop auto GUICtrlSetState( ($button_auto01[6])[7-1], $GUI_UNCHECKED) Sleep(500) GUICtrlSetState( ($button_auto01[6])[7-1], $GUI_UNCHECKED) GUICtrlSetData($button_submit02, "") GUICtrlSetData($button_submit02, "------------------------------AUTO STOP-------------------------------") ExitLoop EndIf Next ; end vong lap auto Func _mouse45($x1,$y1,$x2,$y2,$title_x01=20,$title_y01=20,$xc1=350,$yc1=247) ; 3dxy45 > 2dxy diablo import Local $return[3] $fx0 = $x1 - $x2 $fy0 = $y1 - $y2 $fx0_x = 0 $fx0_y = 0 $fy0_x = 0 $fy0_y = 0 If $fx0 > 0 Then $fx0_x += $fx0*$title_x01 ; +20 $fx0_y -= $fx0*$title_y01 ; -20 ElseIf $fx0 < 0+1 Then $fx0_x = $fx0*$title_x01 ; -20 $fx0_y -= $fx0*$title_y01 ; +20 EndIf If $fy0 > 0 Then $fy0_x = $fy0*$title_x01 ; +20 $fy0_y = $fy0*$title_y01 ; +20 ElseIf $fy0 < 0+1 Then $fy0_x = $fy0*$title_x01 ; -20 $fy0_y = $fy0*$title_y01 ; -20 EndIf $mouse45x = $xc1 + $fx0_x + $fy0_x $mouse45y = $yc1 + $fx0_y + $fy0_y $return[0] = Int($mouse45x) $return[1] = Int($mouse45y) ;MouseMove( $mouse45x, $mouse45y+30, 0) ;MsgBox("","check","$mouse45x = "&$mouse45x& "$mouse45y = "&$mouse45y&" $x1 = "&$x1& " $y1 = "&$y1&" $x2 = "&$x2& "$y2 = "&$y2,0) Return $return EndFunc ElseIf $xx > ($button_auto01[1])[1] And $yy > ($button_auto01[1])[2] And $xx < ($button_auto01[1])[1]+($button_auto01[1])[3] And $yy < ($button_auto01[1])[2]+($button_auto01[1])[4] Then ; click button "Select" ElseIf $xx > ($button_auto01[2])[1] And $yy > ($button_auto01[2])[2] And $xx < ($button_auto01[2])[1]+($button_auto01[2])[3] And $yy < ($button_auto01[2])[2]+($button_auto01[2])[4] Then ; click button "Select" ElseIf $xx > ($button_auto01[3])[1] And $yy > ($button_auto01[3])[2] And $xx < ($button_auto01[3])[1]+($button_auto01[3])[3] And $yy < ($button_auto01[3])[2]+($button_auto01[3])[4] Then ; click button "Select" ElseIf $xx > ($button_auto01[4])[1] And $yy > ($button_auto01[4])[2] And $xx < ($button_auto01[4])[1]+($button_auto01[4])[3] And $yy < ($button_auto01[4])[2]+($button_auto01[4])[4] Then ; click button "Select" ElseIf $xx > ($button_auto01[5])[1] And $yy > ($button_auto01[5])[2] And $xx < ($button_auto01[5])[1]+($button_auto01[5])[3] And $yy < ($button_auto01[5])[2]+($button_auto01[5])[4] Then ; click button "Select" ElseIf $xx > ($button_auto01[6])[1] And $yy > ($button_auto01[6])[2] And $xx < ($button_auto01[6])[1]+($button_auto01[6])[3] And $yy < ($button_auto01[6])[2]+($button_auto01[6])[4] Then ; click button "Select" ; button_auto02 ----------------------------------------- ElseIf $xx > ($button_auto02[0])[1] And $yy > ($button_auto02[0])[2] And $xx < ($button_auto02[0])[1]+($button_auto02[0])[3] And $yy < ($button_auto02[0])[2]+($button_auto02[0])[4] Then ; click button "Select" ElseIf $xx > ($button_auto02[1])[1] And $yy > ($button_auto02[1])[2] And $xx < ($button_auto02[1])[1]+($button_auto02[1])[3] And $yy < ($button_auto02[1])[2]+($button_auto02[1])[4] Then ; click button "Select" Sleep(300) GUICtrlSetState( ($button_auto02[1])[7-1], $GUI_CHECKED) GUICtrlSetState( ($button_auto02[2])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[3])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[4])[7-1], $GUI_UNCHECKED) ElseIf $xx > ($button_auto02[2])[1] And $yy > ($button_auto02[2])[2] And $xx < ($button_auto02[2])[1]+($button_auto02[2])[3] And $yy < ($button_auto02[2])[2]+($button_auto02[2])[4] Then ; click button "Select" Sleep(300) GUICtrlSetState( ($button_auto02[1])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[2])[7-1], $GUI_CHECKED) GUICtrlSetState( ($button_auto02[3])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[4])[7-1], $GUI_UNCHECKED) ElseIf $xx > ($button_auto02[3])[1] And $yy > ($button_auto02[3])[2] And $xx < ($button_auto02[3])[1]+($button_auto02[3])[3] And $yy < ($button_auto02[3])[2]+($button_auto02[3])[4] Then ; click button "Select" Sleep(300) GUICtrlSetState( ($button_auto02[1])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[2])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[3])[7-1], $GUI_CHECKED) GUICtrlSetState( ($button_auto02[4])[7-1], $GUI_UNCHECKED) ElseIf $xx > ($button_auto02[4])[1] And $yy > ($button_auto02[4])[2] And $xx < ($button_auto02[4])[1]+($button_auto02[4])[3] And $yy < ($button_auto02[4])[2]+($button_auto02[4])[4] Then ; click button "Select" Sleep(300) GUICtrlSetState( ($button_auto02[1])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[2])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[3])[7-1], $GUI_UNCHECKED) GUICtrlSetState( ($button_auto02[4])[7-1], $GUI_CHECKED) ElseIf $xx > ($button_auto02[5])[1] And $yy > ($button_auto02[5])[2] And $xx < ($button_auto02[5])[1]+($button_auto02[5])[3] And $yy < ($button_auto02[5])[2]+($button_auto02[5])[4] Then ; click button "Select" ElseIf $xx > ($button_auto02[6])[1] And $yy > ($button_auto02[6])[2] And $xx < ($button_auto02[6])[1]+($button_auto02[6])[3] And $yy < ($button_auto02[6])[2]+($button_auto02[6])[4] Then ; click button "Select" If _IsChecked( ($button_auto02[5])[7-1] ) = True Then _start_find01(1) ElseIf _IsChecked( ($button_auto02[5])[7-1] ) = False Then _start_find01(0) EndIf Func _start_find01($allow_diagonals_Boolean0=0,$f_start0x=0,$f_start0y=0,$f_goal0x=0,$f_goaly=0) $allow_diagonals_Boolean = $allow_diagonals_Boolean0 If _IsChecked( ($button_auto03[3])[7-1] ) = True Then $sleep_find01 = 100 If _IsChecked( ($button_auto03[3])[7-1] ) = False Then $sleep_find01 = 0 ; reset map Global $closedList_Str = "_" Global $openList_Str = "_" Local $hTimer = TimerInit() ; end reset map ; MsgBox($MB_SYSTEMMODAL, "Title", "$start_cols01="&$start_cols01&" $start_rows01="&$start_rows01&" $goal_cols01="&$goal_cols01&" $goal_rows01="&$goal_rows01, 0) ; NOTE: Array MUST have x's around entire paremeter ; There must be a "s" and a "g". "0" means bot can walk here ; 2. Convert array into node objects $data = $data_map ;MsgBox($MB_SYSTEMMODAL, "Title", "$UBOUND_ROWS = "&UBound($data_map, $UBOUND_ROWS)&" $UBOUND_COLUMNS = "&UBound($data_map, $UBOUND_COLUMNS)&" $rows = "&$rows&" $cols = "&$cols, 0) _CreateMap($data_map,0,0,$cols,$rows) ;_ArrayDisplay($data_map) ; will show the the full path ; 3. Calculate path $path = -1 ; fix array If $f_start0x=0 and $f_start0y=0 and $f_goal0x=0 and $f_goaly=0 Then Dim $path = _FindPath($data,$data[$start_rows01][$start_cols01],$data[$goal_rows01][$goal_cols01]) ElseIf $f_start0x>0 and $f_start0y>0 and $f_goal0x>0 and $f_goaly>0 Then Dim $path = _FindPath($data,$data[$f_start0y][$f_start0x],$data[$f_goaly][$f_goal0x]) EndIf ; 4. Thats all! ; The variable $path contains an array of the path in "x,y" format ; _ArrayDisplay($path) ; will show the the full path $path01_Rows = UBound($path, $UBOUND_ROWS) ;_ArrayDisplay($path) ; will show the the full path If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit01, "") GUICtrlSetData($button_submit01, "N="&$loopacc&" STEP = "&$path01_Rows) GUICtrlSetData($button_submit01, _ArrayToString($path)) EndIf For $i = 0 To $path01_Rows - 1 Local $node_coord = StringSplit($path[$i], ",") Local $x = $node_coord[1] ; dao $x $y Local $y = $node_coord[2] ; thanh $y $x If $i < $path01_Rows - 1 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x *$title_size01x+279, $y *$title_size01y+211, $tileWidth, $tileHeight, $Brush_blue) Sleep($sleep_find01) ;If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x * ($tileWidth + $distance) + $distance, $y * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_gray) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x*$title_size01x+279, $y*$title_size01y+211, $tileWidth, $tileHeight, $Brush_mask) EndIf If $tiled_map01 = 1 and $i = $path01_Rows-1 Then ;starting point > goal If _IsChecked( ($button_auto03[5])[7-1] ) = True Then If $start_red <> 0 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $start_cols01 *$title_size01x+279, $start_rows01 *$title_size01y+211, $tileWidth, $tileHeight, $Brush_gray) $data_map[$start_rows01][$start_cols01] = "0" EndIf If $goal_green <> 0 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $goal_cols01 *$title_size01x+279, $goal_rows01 *$title_size01y+211, $tileWidth, $tileHeight, $Brush_gray) $data_map[$goal_rows01][$goal_cols01] = "0" EndIf $goal_cols01 = $start_cols01 $goal_rows01 = $start_rows01 $data_map[$start_rows01][$start_cols01] = "g" $goal_green = $y * $cols + $x If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $goal_cols01 *$title_size01x+279, $goal_rows01 *$title_size01y+211, $tileWidth, $tileHeight, $Brush_green) $start_cols01 = $x $start_rows01 = $y $data_map[$start_rows01][$start_cols01] = "s" $start_red = $y * $cols + $x If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $start_cols01 *$title_size01x+279, $start_rows01 *$title_size01y+211, $tileWidth, $tileHeight, $Brush_red) EndIf EndIf ; end starting point > goal Next Local $iDiff = TimerDiff($hTimer) ; time in seconds Return $path ;ConsoleWrite("$iDiff"&" $iDiff="&Int($iDiff)&"s"&" $xxyy="&$xx&","&$yy& @CR) EndFunc ; button_auto03 ----------------------------------------- ElseIf $xx > ($button_auto03[0])[1] And $yy > ($button_auto03[0])[2] And $xx < ($button_auto03[0])[1]+($button_auto03[0])[3] And $yy < ($button_auto03[0])[2]+($button_auto03[0])[4] Then ; click button "Select" ElseIf $xx > ($button_auto03[1])[1] And $yy > ($button_auto03[1])[2] And $xx < ($button_auto03[1])[1]+($button_auto03[1])[3] And $yy < ($button_auto03[1])[2]+($button_auto03[1])[4] Then ; click button "Select" Local $hTimer = TimerInit() ; START WinCapture_cs03 ---------------------------------------------------------------------------------------------------------------------- Global $stream02 = WinCapture_cs05($control01,3,$game_cap_x02,$game_cap_y02,$view_screen01,$game_cap_x01,$game_cap_y01,$g_x,$g_y,$copy_view01) ; chay only show gui image WinCapture_ce03($stream02[3], $stream02[4], $stream02[5], $stream02[6], $stream02[7], $stream02[0], $stream02[13]) ; remove print image -------------------------- ; END WinCapture_cs03 ---------------------------------------------------------------------------------------------------------------------- Local $iDiff = TimerDiff($hTimer) ; time in seconds GUICtrlSetData($button_submit02, "") GUICtrlSetData($button_submit02, " $iDiff="&Int($iDiff)&"s"&@CRLF&" WinCapture_cs03") ;_ArrayDisplay($stream02[12]) ;$hBrush = _GDIPlus_BrushCreateSolid() Local $iDiff = TimerDiff($hTimer) ; time in seconds If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " $iDiff="&Int($iDiff)&"s"&@CRLF&" _check_map03($loopacc,$tiled_map01)") If $a_map_min00x[$loopacc] < 20 and $a_map_max00x[$loopacc] > $col_scale-20 and $a_map_min00y[$loopacc] < 20 and $a_map_max00y[$loopacc] > $rows_scale-20 Then _MemoryWrite64($a_local01[$loopacc]+0x4, $procHwnd_autoit01, ptr(0),'byte[4]') ; reset value = 0 GUICtrlSetData($button_submit02, " N="&$loopacc&" _all_find_a03($loopacc) = "&"FALSE LARGE MAP") Else GUICtrlSetData($button_submit02, " N="&$loopacc&" _all_find_a03($loopacc) = "&"TRUE LARGE MAP") $random0 = Random(1,2,1) _all_find_a04($loopacc,40,$random0) EndIf Local $iDiff = TimerDiff($hTimer) ; time in seconds GUICtrlSetData($button_submit02, " $iDiff="&Int($iDiff)&"s"&@CRLF&" _all_find_a03($loopacc)") ;draw_map01($tiled_map01,0, 320, 0, 241 ) Func _all_find_a04($loopacc0,$lp_green0=100,$lp_goal0=5,$not_map_max0=-1) ; random GOAL MAP Local $a_goal01xy[11][2] $goal_random01min = 0 $goal_random01max = $lp_goal0 $dis_center01max = 7 $dis_center02max = 7 $dis_portal01max = 6 $dis_portal02max = 6 $dis_portal03max = 6 $start_red_x01 = $start_cols01 $start_red_y01 = $start_rows01 $find_switch01 = 1 $lp_switch_exit = 0 ;If $a_fog_green02xy[1][0] <> "" and $a_fog_green02xy[1][1] <> "" and $a_fog_green02xy[2][0] <> "" and $a_fog_green02xy[2][1] <> "" and $a_fog_green02xy[3][0] <> "" and $a_fog_green02xy[3][1] <> "" Then $find_switch01 = 2 ;_ArrayDisplay($a_fog_green02xy) ;_ArrayDisplay($data_map) ;_ArrayDisplay($a_goal01xy) ; will show the the full path For $lp_switch = 2 To 2 ; $find_switch01 = 1 > 2 If $lp_switch = 2 Then For $lp = 1 To $lp_green0 $goal_map01x = Random($a_map_min00x[$loopacc0], $a_map_max00x[$loopacc0], 3) $goal_map01y = Random($a_map_min00y[$loopacc0], $a_map_max00y[$loopacc0], 3) $dis_center01 = Int(Distance($goal_map01x - $mini_min01x, $goal_map01y - $mini_min01y, $start_red_x01, $start_red_y01)) ; TỐI ƯU 1: Khởi tạo luôn khoảng cách là ĐẠT (lớn hơn max), bỏ trò gán -1 rồi IF lằng nhằng Local $dis_portal01 = $dis_portal01max + 1 Local $dis_portal02 = $dis_portal02max + 1 Local $dis_portal03 = $dis_portal03max + 1 ; TỐI ƯU 2: Gộp khối Portal, không viết lại phép tính 1 & 2 lần thứ hai If $not_map_max0 > 1 Then $portal01x = Int(($a_not_map01[$loopacc])[$not_map_max0][3] / ($tileWidth + $distance)) $portal01y = Int(($a_not_map01[$loopacc])[$not_map_max0][4] / ($tileHeight + $distance)) $dis_portal01 = Int(Distance($goal_map01x - $mini_min01x, $goal_map01y - $mini_min01y, $portal01x, $portal01y)) $portal02x = Int(($a_not_map01[$loopacc])[$not_map_max0 - 1][3] / ($tileWidth + $distance)) $portal02y = Int(($a_not_map01[$loopacc])[$not_map_max0 - 1][4] / ($tileHeight + $distance)) $dis_portal02 = Int(Distance($goal_map01x - $mini_min01x, $goal_map01y - $mini_min01y, $portal02x, $portal02y)) EndIf If $not_map_max0 > 2 Then $portal03x = Int(($a_not_map01[$loopacc])[$not_map_max0 - 2][3] / ($tileWidth + $distance)) $portal03y = Int(($a_not_map01[$loopacc])[$not_map_max0 - 2][4] / ($tileHeight + $distance)) $dis_portal03 = Int(Distance($goal_map01x - $mini_min01x, $goal_map01y - $mini_min01y, $portal03x, $portal03y)) EndIf ; TỐI ƯU 3: Lọc điều kiện Map và Khoảng cách sơ bộ If $data_map[$goal_map01y - $mini_min01y][$goal_map01x - $mini_min01x] = "0" And $dis_center01 > $dis_center01max And $dis_portal01 > $dis_portal01max And $dis_portal02 > $dis_portal02max And $dis_portal03 > $dis_portal03max Then Local $b_IsValidPoint = False ; Lọc điều kiện điểm Rand đầu tiên và các điểm tiếp theo If $goal_random01min = 0 Then $b_IsValidPoint = True Else ; Nếu không phải điểm đầu, check khoảng cách với điểm cũ Local $dis_center_prev = Int(Distance($goal_map01x - $mini_min01x, $goal_map01y - $mini_min01y, $a_goal01xy[$goal_random01min][0], $a_goal01xy[$goal_random01min][1])) If $dis_center_prev > $dis_center02max Then $b_IsValidPoint = True EndIf ; TỐI ƯU 4: NẾU TỌA ĐỘ CHUẨN -> CHỈ VẼ GDI VÀ LƯU DATA 1 LẦN DUY NHẤT If $b_IsValidPoint = True Then ; Khối giao diện GDI+ gọi đúng 1 nhịp If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " N=" & $loopacc0 & " $goal_map01x=" & $goal_map01x & "$goal_map01y=" & $goal_map01y & "$data_map[y][x]" & $data_map[$goal_map01y - $mini_min01y][$goal_map01x - $mini_min01x] & " $dis_center01=" & $dis_center01) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x + 0) * $title_size01x - 270, ($goal_map01y + 0) * $title_size01y + 210, $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x + 1) * $title_size01x - 270, ($goal_map01y + 1) * $title_size01y + 210, $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x + 1) * $title_size01x - 270, ($goal_map01y + 0) * $title_size01y + 210, $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x + 0) * $title_size01x - 270, ($goal_map01y + 1) * $title_size01y + 210, $tileWidth, $tileHeight, $Brush_green) EndIf ; Đẩy mảng $goal_random01min += 1 $a_goal01xy[$goal_random01min][0] = Int($goal_map01x - $mini_min01x) $a_goal01xy[$goal_random01min][1] = Int($goal_map01y - $mini_min01y) If $goal_random01min > $goal_random01max - 1 Then ExitLoop EndIf EndIf Next EndIf ; end random GOAL MAP ;_ArrayDisplay($a_goal01xy) ; will show the the full path ; _start_find01 Local $a_path01xy[11][2] ;SyncMapToMemory02($procHwnd_autoit01, $mapBase,$row_bfs00) ;_ArrayDisplay($data_map) ; will show the the full path ; Đặt reset biến đếm Max ngay trước khi vào vòng lặp tìm path $step_max01num = 0 $step_max01step = 0 For $lp_find = 1 to $goal_random01max ; 1. NẾU KHÔNG CÓ TỌA ĐỘ ĐÍCH -> THOÁT LUP If $a_goal01xy[$lp_find][0] = "" Then ExitLoop EndIf ; Cập nhật log giao diện If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " N="&$loopacc0&" $start_red_x01="&$start_red_x01&" $start_red_y01="&$start_red_y01&" $a_goal01xy[$lp_find][0]="&$a_goal01xy[$lp_find][0]&" $a_goal01xy[$lp_find][1]="&$a_goal01xy[$lp_find][1]) EndIf ; 2. NẾU NÚT CHECKBOX BẬT -> TIẾN HÀNH TÌM ĐƯỜNG If _IsChecked( ($button_auto02[5])[7-1] ) = True Then ; --- KHÚC BẠN QUÊN ĐÃ ĐƯỢC THÊM VÀO --- Global $row_bfs01 = 50 Global $col_bfs01 = 50 Global $row_bfs00 = 34 Global $sx_bfs = $start_red_x01-0 Global $sy_bfs = $start_red_y01-0 Global $gx_bfs = $a_goal01xy[$lp_find][0]-0 Global $gy_bfs = $a_goal01xy[$lp_find][1]-0 ; Chạy BFS quét mảng path $a_path01xy[$lp_find][0] = _BFS_RESET01($sx_bfs,$sy_bfs,$gx_bfs,$gy_bfs,$procHwnd_autoit01,$startBFS_address,$mapBase,$visitedBase,$prevBase,$queueBase,$pathBase,$newmem) ; Đếm số bước đi Local $current_steps = UBound($a_path01xy[$lp_find][0], $UBOUND_ROWS) $a_path01xy[$lp_find][1] = $current_steps If $loopacc = $loop_view01 Then _bfs_gui02($a_path01xy[$lp_find][0]) ; --- TÌM PATH DÀI NHẤT NGAY TRONG LÚC NÀY --- If $current_steps > $step_max01step Then $step_max01step = $current_steps $step_max01num = $lp_find EndIf EndIf Next ; ========================================================================= ; XỬ LÝ CHUYỂN LUỒNG EXIT (Giữ nguyên logic vòng lặp ngoài của bạn) ; ========================================================================= If $lp_switch = 1 and $a_path01xy[1][1] <> "" and $a_path01xy[1][1] <> 0 Then $lp_switch_exit = 1 If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit01, "$lp_switch = "& $lp_switch & " $lp_switch_exit = "&$lp_switch_exit) EndIf If $lp_switch_exit = 1 Then ExitLoop Next ; end $find_switch01 = 1 > 2 ; ========================================================================= ; ĐỔ DỮ LIỆU PATH DÀI NHẤT VÀO RAM GAME (ĐÃ FIX CHUẨN KIỂU DWORD 4 BYTE) ; ========================================================================= If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit01, " $step_max01num = "&$step_max01num & " $step_max01step = "&$step_max01step) GUICtrlSetData($button_submit01, _ArrayToString($a_path01xy[$step_max01num][0], ",", -1, -1, " | ")) EndIf Local $a_path01 = $a_path01xy[$step_max01num][0] Local $max1 = 0 If IsArray($a_path01) Then $max1 = UBound($a_path01) - 1 If $max1 > 0 Then Local $base_addr = $a_local01[$loopacc0] For $lp_a = 0 to $max1 Local $x = $a_path01[$lp_a][0] Local $y = $a_path01[$lp_a][1] ; Ghi số nguyên tọa độ vào RAM, bỏ lệnh Ptr() sai quy chuẩn _MemoryWrite64($base_addr + 0x108 + 0x8 * $lp_a, $procHwnd_autoit01, $x, 'dword') _MemoryWrite64($base_addr + 0x10C + 0x8 * $lp_a, $procHwnd_autoit01, $y, 'dword') Next ; Ghi tổng số bước chạy vào RAM _MemoryWrite64($base_addr + 0x104, $procHwnd_autoit01, $max1, 'dword') EndIf ;GUICtrlSetData($button_submit01, "$step_max01num = "&$step_max01num & " $step_max01step = "&$step_max01step& " $a_local01[$loopacc0] = "&Hex($a_local01[$loopacc0]) ) ;Return $a_path01xy[$step_max01num][0] ; end _start_find01 EndFunc Func _SmoothPath_Tension_Fast($originalPath, $windowSize = 2, $stepJump = 3, $tension = 0.25) Local $numPoints = UBound($originalPath) If $numPoints <= 2 Then Return $originalPath Local $startX = $originalPath[0][0] Local $startY = $originalPath[0][1] Local $goalX = $originalPath[$numPoints - 1][0] Local $goalY = $originalPath[$numPoints - 1][1] Local $curvedPath[$numPoints][2] ; BƯỚC 1: Uốn cong (Giữ nguyên logic) For $i = 0 To $numPoints - 1 Local $sumX = 0, $sumY = 0, $count = 0 Local $start = $i - $windowSize If $start < 0 Then $start = 0 Local $end = $i + $windowSize If $end > $numPoints - 1 Then $end = $numPoints - 1 For $j = $start To $end $sumX += $originalPath[$j][0] $sumY += $originalPath[$j][1] $count += 1 Next Local $avgX = $sumX / $count Local $avgY = $sumY / $count Local $t = $i / ($numPoints - 1) Local $lineX = $startX + ($goalX - $startX) * $t Local $lineY = $startY + ($goalY - $startY) * $t $curvedPath[$i][0] = Int($avgX * (1 - $tension) + $lineX * $tension) $curvedPath[$i][1] = Int($avgY * (1 - $tension) + $lineY * $tension) Next ; ========================================== ; BƯỚC 2: TỐI ƯU SIÊU TỐC - KHÔNG DÙNG REDIM TRONG LOOP ; ========================================== ; Cấp phát sẵn 1 mảng to bằng mảng gốc (Thừa còn hơn thiếu) Local $smoothed[$numPoints][2] $smoothed[0][0] = $curvedPath[0][0] $smoothed[0][1] = $curvedPath[0][1] Local $smoothCount = 1 For $i = $stepJump To $numPoints - 2 Step $stepJump $smoothed[$smoothCount][0] = $curvedPath[$i][0] $smoothed[$smoothCount][1] = $curvedPath[$i][1] $smoothCount += 1 Next ; Chốt điểm cuối $smoothed[$smoothCount][0] = $goalX $smoothed[$smoothCount][1] = $goalY ; Gọi ReDim ĐÚNG 1 LẦN DUY NHẤT để gọt bỏ phần mảng thừa ReDim $smoothed[$smoothCount + 1][2] Return $smoothed EndFunc Func _SmoothPath_Tension($originalPath, $windowSize = 2, $stepJump = 3, $tension = 0.25) Local $numPoints = UBound($originalPath) ; Nếu quá ngắn thì không cần uốn If $numPoints <= 2 Then Return $originalPath Local $startX = $originalPath[0][0] Local $startY = $originalPath[0][1] Local $goalX = $originalPath[$numPoints - 1][0] Local $goalY = $originalPath[$numPoints - 1][1] Local $curvedPath[$numPoints][2] ; ------------------------------------------------------------ ; BƯỚC 1: UỐN CONG VÀ KÉO DÂY THUN VỀ ĐÍCH ; ------------------------------------------------------------ For $i = 0 To $numPoints - 1 ; A. Tính điểm Trung bình động (Làm mượt góc vuông) Local $sumX = 0, $sumY = 0, $count = 0 Local $start = $i - $windowSize If $start < 0 Then $start = 0 Local $end = $i + $windowSize If $end > $numPoints - 1 Then $end = $numPoints - 1 For $j = $start To $end $sumX += $originalPath[$j][0] $sumY += $originalPath[$j][1] $count += 1 Next Local $avgX = $sumX / $count Local $avgY = $sumY / $count ; B. Tính tọa độ của điểm tương ứng trên đường thẳng lý tưởng (Start -> Goal) Local $t = $i / ($numPoints - 1) ; Tỷ lệ quãng đường từ 0 đến 1 Local $lineX = $startX + ($goalX - $startX) * $t Local $lineY = $startY + ($goalY - $startY) * $t ; C. Lai tạp (Nội suy) kéo điểm mượt về phía đường thẳng đích ; Ép kiểu Int để ghi RAM không bị lỗi số thập phân $curvedPath[$i][0] = Int($avgX * (1 - $tension) + $lineX * $tension) $curvedPath[$i][1] = Int($avgY * (1 - $tension) + $lineY * $tension) Next ; ------------------------------------------------------------ ; BƯỚC 2: RÚT GỌN BƯỚC NHẢY (CẮT BỚT CLICK) ; ------------------------------------------------------------ Local $smoothed[1][2] $smoothed[0][0] = $curvedPath[0][0] $smoothed[0][1] = $curvedPath[0][1] Local $smoothCount = 1 For $i = $stepJump To $numPoints - 2 Step $stepJump ReDim $smoothed[$smoothCount + 1][2] $smoothed[$smoothCount][0] = $curvedPath[$i][0] $smoothed[$smoothCount][1] = $curvedPath[$i][1] $smoothCount += 1 Next ; Luôn chốt chặn bằng điểm đích thực tế ReDim $smoothed[$smoothCount + 1][2] $smoothed[$smoothCount][0] = $goalX $smoothed[$smoothCount][1] = $goalY Return $smoothed EndFunc Func _bfs_gui02($pathArray0) ; Khai báo mảng 2D từ ASM thay vì gọi _FindPath cũ Local $path01_Rows = 0 If IsArray($pathArray0) Then $path01_Rows = UBound($pathArray0) If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit01, "") GUICtrlSetData($button_submit01, "N=" & $loopacc & " STEP = " & $path01_Rows) GUICtrlSetData($button_submit01, _ArrayToString($pathArray0, ",", -1, -1, " | ")) ; In ra String dễ nhìn EndIf ; ======================================================================= ; VÒNG LẶP VẼ ĐƯỜNG ĐI TRÊN GUI THẬT (Chạy lùi từ Start -> Goal) ; ======================================================================= If $path01_Rows > 0 Then ; Bắt đầu từ áp chót (vì index cuối cùng là Start) lùi về 1 (sát Goal) For $i = $path01_Rows - 1 To 1 Step -1 ; KHÔNG DÙNG StringSplit NỮA. Lấy thẳng tọa độ từ ASM: Local $x = $pathArray0[$i][0] Local $y = $pathArray0[$i][1] ; VẼ ANIMATION ĐƯỜNG ĐI If $loopacc = $loop_view01 Then ; Vẽ ô màu xanh dương theo tọa độ gốc của bảng điều khiển (+279, +211) _GDIPlus_GraphicsFillRect($hGraphic, $x * $title_size01x + 279, $y * $title_size01y + 211, $tileWidth, $tileHeight, $Brush_blue) Sleep($sleep_find01) ; Độ trễ hoạt họa ; Vẽ ô mặt nạ đè lên _GDIPlus_GraphicsFillRect($hGraphic, $x * $title_size01x + 279, $y * $title_size01y + 211, $tileWidth, $tileHeight, $Brush_mask) EndIf ; ================================================================= ; KHỐI LOGIC DỊCH CHUYỂN "S" VÀ "G" ; (Chỉ kích hoạt khi chạm đến đích: $i = 1) ; ================================================================= If $tiled_map01 = 1 And $i = 1 Then If _IsChecked( ($button_auto03[5])[7-1] ) = True Then ; 1. Xóa màu của Start/Goal cũ If $start_red <> 0 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $start_cols01 * $title_size01x + 279, $start_rows01 * $title_size01y + 211, $tileWidth, $tileHeight, $Brush_gray) $data_map[$start_rows01][$start_cols01] = "0" EndIf If $goal_green <> 0 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $goal_cols01 * $title_size01x + 279, $goal_rows01 * $title_size01y + 211, $tileWidth, $tileHeight, $Brush_gray) $data_map[$goal_rows01][$goal_cols01] = "0" EndIf ; 2. Cập nhật vị trí Start/Goal mới $goal_cols01 = $start_cols01 $goal_rows01 = $start_rows01 $data_map[$start_rows01][$start_cols01] = "g" $goal_green = $y * $cols + $x If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $goal_cols01 * $title_size01x + 279, $goal_rows01 * $title_size01y + 211, $tileWidth, $tileHeight, $Brush_green) $start_cols01 = $x $start_rows01 = $y $data_map[$start_rows01][$start_cols01] = "s" $start_red = $y * $cols + $x If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $start_cols01 * $title_size01x + 279, $start_rows01 * $title_size01y + 211, $tileWidth, $tileHeight, $Brush_red) EndIf EndIf ; Kết thúc khối dịch chuyển Next EndIf EndFunc Func _bfs_gui01($pathArray0) ; ===================================================================== ; TÍCH HỢP GDI+ ĐỂ VẼ BẢN ĐỒ VÀ ĐƯỜNG ĐI ASM TÌM ĐƯỢC ; ===================================================================== ; Khởi tạo GDI+ và tạo cửa sổ hiển thị _GDIPlus_Startup() Local $tileW_bfs = 12, $tileH_bfs = 12 Local $GUI_W_bfs = 50 * $tileW_bfs ; Map 50 ô Local $GUI_H_bfs = 50 * $tileH_bfs ; Map 50 ô Global $hGUI_Map_bfs = GUICreate("Radar BFS 50x50"&" $start_red_x01="&$start_red_x01&" $start_red_y01="&$start_red_y01, $GUI_W_bfs, $GUI_H_bfs) Global $hGraphic_bfs = _GDIPlus_GraphicsCreateFromHWND($hGUI_Map_bfs) GUISetState(@SW_SHOW, $hGUI_Map_bfs) ; Tạo các bảng màu (Brush) Global $BrushWall = _GDIPlus_BrushCreateSolid(0xFF333333) ; Xám đen (Tường - x) Global $BrushPath = _GDIPlus_BrushCreateSolid(0xFFEEEE55) ; Trắng xám (Đường trống - 0) Global $BrushRoute = _GDIPlus_BrushCreateSolid(0xFF00AFFF) ; Xanh dương (Đường đi của ASM) Global $BrushStart = _GDIPlus_BrushCreateSolid(0xFF00FF00) ; Xanh lá cây (Điểm Start) Global $BrushGoal = _GDIPlus_BrushCreateSolid(0xFFFF0000) ; Đỏ (Điểm Goal) ; 1. Vẽ nền bản đồ (Đọc thẳng từ RAM chứa mapBase) For $y = 0 To $row_bfs00 For $x = 0 To 49 Local $addr = $mapBase + ($x * 50 + $y) ; Đọc 1 byte từ RAM và ép về ký tự Local $val = Chr(_MemoryRead64($addr, $procHwnd_autoit01, "byte[1]", "dec")) If $val == "x" Then _GDIPlus_GraphicsFillRect($hGraphic_bfs, $x * $tileW_bfs, $y * $tileH_bfs, $tileW_bfs, $tileH_bfs, $BrushWall) Else _GDIPlus_GraphicsFillRect($hGraphic_bfs, $x * $tileW_bfs, $y * $tileH_bfs, $tileW_bfs, $tileH_bfs, $BrushPath) EndIf Next Next ; 2. Vẽ đường đi (Dựa vào mảng $pathArray0 do ASM trả về) If IsArray($pathArray0) Then ; Chạy từ 1 để không tô đè lên Goal (index 0) For $i = 1 To UBound($pathArray0) - 1 Local $px = $pathArray0[$i][0] Local $py = $pathArray0[$i][1] ; CHỈ VẼ nếu tọa độ Y nằm trong phạm vi Mini Map (0 đến 34) If $py <= $row_bfs00 Then ; Vẽ đường đi bằng màu xanh dương _GDIPlus_GraphicsFillRect($hGraphic_bfs, $px * $tileW_bfs, $py * $tileH_bfs, $tileW_bfs, $tileH_bfs, $BrushRoute) EndIf Next EndIf ; 3. Vẽ đè làm nổi bật điểm Start và Goal _GDIPlus_GraphicsFillRect($hGraphic_bfs, $sx_bfs * $tileW_bfs, $sy_bfs * $tileH_bfs, $tileW_bfs, $tileH_bfs, $BrushStart) _GDIPlus_GraphicsFillRect($hGraphic_bfs, $gx_bfs * $tileW_bfs, $gy_bfs * $tileH_bfs, $tileW_bfs, $tileH_bfs, $BrushGoal) ; Vòng lặp giữ cửa sổ không bị tắt While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Dọn dẹp RAM đồ họa sau khi tắt cửa sổ Radar _GDIPlus_BrushDispose($BrushWall) _GDIPlus_BrushDispose($BrushPath) _GDIPlus_BrushDispose($BrushRoute) _GDIPlus_BrushDispose($BrushStart) _GDIPlus_BrushDispose($BrushGoal) _GDIPlus_GraphicsDispose($hGraphic_bfs) _GDIPlus_Shutdown() GUIDelete($hGUI_Map_bfs) ; ... (Có thể gọi tiếp các hàm khác sau khi đóng bảng vẽ) ... EndFunc Func SyncMapToMemory01($hProc, $pMapBase) For $y = 0 To $row_bfs01 - 1 For $x = 0 To $col_bfs01 - 1 Local $char = $data_map_bfs[$y][$x] Local $byteVal = Asc($char) ; Chuyển ký tự thành giá trị số (ví dụ: 'x' = 120) ; Ghi từng byte vào địa chỉ tương ứng ; Mỗi ô nhớ cách nhau 1 byte (offset = y * 50 + x) Local $offset = ($x * $col_bfs01) + $y _MemoryWrite64($pMapBase + $offset, $hProc, ptr($byteVal), 'byte[1]') Next Next EndFunc Func SyncMapToMemory02($hProc, $pMapBase,$row_bfs00=34) ; Duyệt theo cột trước (X), hàng sau (Y) để khớp với cách bạn đã tìm ra offset ($x * $col_bfs01 + $y) For $x = 0 To $col_bfs01 - 1 Local $string_x_add01 = "" For $y = 0 To $row_bfs00 - 1 ;Local $char = $data_map_bfs[$y][$x] Local $char = $data_map[$y][$x] Local $byteVal = Asc($char) $string_x_add01 &= Hex($byteVal, 2) Next ; Offset bây giờ được tính theo X (cột) ; Vì mỗi cột có 50 ô (rows), nên $x * 50 sẽ nhảy sang cột tiếp theo Local $offset = ($x * $row_bfs01) _MemoryWrite64($pMapBase + $offset, $hProc, "0x" & $string_x_add01, 'byte[50]') Next EndFunc Func _BFS_RESET01($sx_bfs0,$sy_bfs0,$gx_bfs0,$gy_bfs0,$procHwnd0,$startBFS_address0,$mapBase0,$visitedBase0,$prevBase0,$queueBase0,$pathBase0,$newmem0) _MemoryWrite64($startBFS_address0+0x24, $procHwnd0, ptr($sx_bfs0),'byte[1]') ; reset value = 0 _MemoryWrite64($startBFS_address0+0x2C, $procHwnd0, ptr($sy_bfs0),'byte[1]') ; reset value = 0 _MemoryWrite64($startBFS_address0+0x34, $procHwnd0, ptr($gx_bfs0),'byte[1]') ; reset value = 0 _MemoryWrite64($startBFS_address0+0x3C, $procHwnd0, ptr($gy_bfs0),'byte[1]') ; reset value = 0 ; gọi hàm ASM tại địa chỉ $startBFS_address DllCallAddress("uint:cdecl", $startBFS_address0) ; Fill toàn bộ vùng nhớ bằng 0 ;DllCall("kernel32.dll", "none", "RtlFillMemory", "ptr", $mapBase, "dword", 0x9C4, "byte", 0) DllCall("kernel32.dll", "none", "RtlFillMemory", "ptr", $visitedBase, "dword", 0x9C4, "byte", 0) DllCall("kernel32.dll", "none", "RtlFillMemory", "ptr", $prevBase, "dword", 0x4E20, "byte", 0) DllCall("kernel32.dll", "none", "RtlFillMemory", "ptr", $queueBase, "dword", 0x4E20, "byte", 0) DllCall("kernel32.dll", "none", "RtlFillMemory", "ptr", $pathBase, "dword", 0x4E20, "byte", 0) ;ClipPut($mapBase0) Return GetPathArray03($newmem+0x1000, $procHwnd0 ) EndFunc Func GetPathArray03($baseAddr, $procHwnd) ; 1. Đọc số bước (Vẫn dùng _MemoryRead64 vì chỉ đọc 1 lần) Local $steps = _MemoryRead64($baseAddr, $procHwnd, 'byte[4]', "dec") Local $path[1][2] If $steps <= 1 Or $steps >= 100 Then Return $path ; 2. ĐỌC NGUYÊN KHỐI DỮ LIỆU (Đọc từ Offset 0x4 trở đi, độ dài $steps * 8) Local $totalBytes = $steps * 8 Local $tPathBuffer = DllStructCreate("int[" & ($steps * 2) & "]") ; Chứa cả X và Y ; Đọc thẳng vào Struct (cần đổi $procHwnd theo cách hàm _MemoryRead dùng) ; Nếu _MemoryRead64 của bạn trả về handle, hãy dùng trực tiếp handle đó Local $ahCall = DllCall("kernel32.dll", "bool", "ReadProcessMemory", _ "handle", $procHwnd[1], _ ; Hoặc $procHwnd nếu nó là handle "ptr", $baseAddr + 0x4, _ "ptr", DllStructGetPtr($tPathBuffer), _ "ulong_ptr", $totalBytes, _ "ptr", 0) ; 3. CHUYỂN DỮ LIỆU & ĐẢO CHIỀU (Sử dụng Struct nội bộ, KHÔNG gọi ReadMem nữa) Local $path[$steps][2] For $i = 0 To $steps - 1 ; Truy xuất cặp X, Y từ Struct nội bộ ; Bước i trong buffer nằm tại index: $i * 2 + 1 (X) và $i * 2 + 2 (Y) Local $x0 = DllStructGetData($tPathBuffer, 1, ($i * 2) + 1) Local $y0 = DllStructGetData($tPathBuffer, 1, ($i * 2) + 2) If $x0 <> 0 Or $y0 <> 0 Then Local $rev_index = ($steps - 1) - $i $path[$rev_index][0] = $x0 $path[$rev_index][1] = $y0 EndIf Next ; Lấy kích thước tối đa của map để kiểm tra an toàn Local $maxRows = UBound($data_map, 1) - 1 Local $maxCols = UBound($data_map, 2) - 1 For $i = 0 To $steps - 1 Local $cx = $path[$i][0] Local $cy = $path[$i][1] Local $offset_x = 0 Local $offset_y = 0 ; CHỈ KIỂM TRA NẾU TỌA ĐỘ NẰM TRONG PHẠM VI AN TOÀN ; Kiểm tra bên phải (cộng 1 và 2) If $cx + 2 <= $maxCols Then If $data_map[$cy][$cx + 1] == "x" Or $data_map[$cy][$cx + 2] == "x" Then $offset_x -= 1 EndIf ; Kiểm tra bên trái (trừ 1 và 2) If $cx - 2 >= 0 Then If $data_map[$cy][$cx - 1] == "x" Or $data_map[$cy][$cx - 2] == "x" Then $offset_x += 1 EndIf ; Kiểm tra bên dưới (cộng 1 và 2) If $cy + 2 <= $maxRows Then If $data_map[$cy + 1][$cx] == "x" Or $data_map[$cy + 2][$cx] == "x" Then $offset_y -= 1 EndIf ; Kiểm tra bên trên (trừ 1 và 2) If $cy - 2 >= 0 Then If $data_map[$cy - 1][$cx] == "x" Or $data_map[$cy - 2][$cx] == "x" Then $offset_y += 1 EndIf ; Cập nhật tọa độ $path[$i][0] += $offset_x $path[$i][1] += $offset_y Next Return $path EndFunc Func GetPathArray02($baseAddr, $procHwnd) ; đọc số bước (dword tại offset 0) Local $steps = _MemoryRead64($baseAddr, $procHwnd, 'byte[4]', "dec") ; tạo mảng mặc định tránh lỗi Local $path[1][2] If $steps > 1 and $steps < 100 Then Local $path[$steps][2] For $i = 0 To $steps - 1 ; Đọc tọa độ từ RAM (Bản chất RAM vẫn đang lưu từ Goal -> Start) Local $x0 = _MemoryRead64($baseAddr + (0x8 * $i) + 0x4, $procHwnd, 'byte[4]', "dec") Local $y0 = _MemoryRead64($baseAddr + (0x8 * $i) + 0x8, $procHwnd, 'byte[4]', "dec") ; KIỂM TRA TỌA ĐỘ HỢP LỆ ; Tôi đổi thành 'Or' thay vì 'And', vì nếu quái vô tình đứng sát mép trái (x=0) hoặc mép trên (y=0) thì nó vẫn nhận diện được. If $x0 <> 0 Or $y0 <> 0 Then ; TÍNH TOÁN INDEX ĐẢO NGƯỢC ; Ví dụ: Có 10 bước ($steps = 10). ; Khi $i = 0 (Goal trong RAM), index sẽ là (10 - 1) - 0 = 9 (Đẩy Goal xuống đáy mảng) ; Khi $i = 9 (Start trong RAM), index sẽ là (10 - 1) - 9 = 0 (Đưa Start lên đỉnh mảng) Local $rev_index = ($steps - 1) - $i $path[$rev_index][0] = $x0 ; x $path[$rev_index][1] = $y0 ; y EndIf Next Return $path EndIf Return $path EndFunc Func GetPathArray01($baseAddr, $procHwnd) ; đọc số bước (dword tại offset 0) Local $steps = _MemoryRead64($baseAddr, $procHwnd, 'byte[4]', "dec") ;MsgBox("","check","$baseAddr = "&$baseAddr& "$steps = "&$steps,0) ; tạo mảng chứa các cặp tọa độ Local $path[1][2] If $steps > 1 and $steps < 100 Then Local $path[$steps][2] ; $path[0][0] = $gx_bfs0 ; x ; $path[0][1] = $gy_bfs0 ; y For $i = 0 To $steps - 1 ; mỗi bước chiếm 16 byte (0x10) Local $x0 = _MemoryRead64($baseAddr + (0x8 * $i)+0x4, $procHwnd, 'byte[4]', "dec") Local $y0 = _MemoryRead64($baseAddr + (0x8 * $i)+0x8, $procHwnd, 'byte[4]', "dec") If $x0 <> 0 and $y0 <> 0 Then $path[$i][0] = $x0 ; x $path[$i][1] = $y0 ; y EndIf Next Return $path EndIf Return $path EndFunc Func _cmp_BFS01($mapBase0,$visitedBase0,$prevBase0,$queueBase0,$pathBase0,$BFS0,$newmem0,$startBFS0) $int_20 = 32 ; width hex 32 dec 50 $op_code00 = "" $op_code01 = "" ;// DllCallAddress("uint:cdecl", DllStructGetPtr($tCodeBuffer_bfs), "ptr", DllStructGetPtr($tPixelData), "ptr", DllStructGetPtr($tStruct_ARGB), "int", $iPixels) ;// ;64Bit! -> ;first 4 parameters will be saved in rcx,rdx,r8,r9 ;push rdi ;push rsi ;push rbx ;push rbp $op_code01 &= "57 56 53 55 48 8B F1" ; mov r14, newmem // r14 = base của newmem $op_code01 &= "49 BE "&_ReadF($newmem0,0) ;mov [r14+0], 0 // $front = 0 r10 = $front ;mov [r14+4], 1 // $rear = 1 r11 = $rear ;mov [r14+10], (Int)9 // $sx_bfs rsi = $sx_bfs ;mov [r14+14], (Int)11 // $sy_bfs rdi = $sy_bfs ;mov [r14+20], (Int)19 // $gx_bfs r12 = $gx_bfs ;mov [r14+24], (Int)19 // $gy_bfs r13 = $gy_bfs ;mov [r14+30], (Int)10 // $px ;mov [r14+34], (Int)10 // $py ;mov r10d, [r14+0] // Global $front = 0 ;mov r11d, [r14+4] // Global $rear = 1 ;mov rsi, [r14+10] // Global rsi = $sx_bfs ;mov rdi, [r14+14] // Global rdi = $sy_bfs $op_code01 &= "41 C7 06 00 00 00 00 41 C7 46 04 01 00 00 00 41 C7 46 10 09 00 00 00 41 C7 46 14 0B 00 00 00 41 C7 46 20 13 00 00 00 41 C7 46 24 13 00 00 00 41 C7 46 30 0A 00 00 00 41 C7 46 34 0A 00 00 00 45 8B 16 45 8B 5E 04 49 8B 76 10 49 8B 7E 14" ;mov r15, queueBase // r15 = base của Queue ;mov [r15+0],rsi // $Queue[0][0] = $sx_bfs ;mov [r15+4],rdi // $Queue[0][1] = $sy_bfs $op_code01 &= "49 BF "&_ReadF($queueBase0,0) $op_code01 &= "49 89 37 49 89 7F 04" ;// Gán "s" vào MAP[$sx_bfs][$sy_bfs] ; mov r14, newmem // r14 = base của newmem $op_code01 &= "49 BE "&_ReadF($newmem0,0) ;mov esi, [r14+10] // $sx_bfs = 9 ;mov edi, [r14+14] // $sy_bfs = 11 ;imul edx, esi, (Int)20 // edx = $sx_bfs * 20 ;add edx, edi // edx = $sx_bfs * 20 + $sy_bfs $op_code01 &= "41 8B 76 10 41 8B 7E 14 69 D6 "&$int_20&" 00 00 00 01 FA" ;mov rsi, mapBase // base của MAP $op_code01 &= "48 BE "&_ReadF($mapBase0,0) ;mov r14, rsi ;add r14, edx // rax = địa chỉ MAP[$sx_bfs][$sy_bfs] ;mov byte ptr [r14], 's' // gán ký tự 's' $op_code01 &= "4C 8B F6 49 01 D6 41 C6 06 73" ;//Gán "g" vào MAP[$gx_bfs][$gy_bfs] ; mov r14, newmem $op_code01 &= "49 BE "&_ReadF($newmem0,0) ;mov esi, [r14+20] // $gx_bfs ;mov edi, [r14+24] // $gy_bfs ;imul edx, esi, (Int)20 ;add edx, edi // edx = $gx_bfs * 20 + $gy_bfs $op_code01 &= "41 8B 76 20 41 8B 7E 24 69 D6 "&$int_20&" 00 00 00 01 FA" ;mov rsi, mapBase // base của MAP $op_code01 &= "48 BE "&_ReadF($mapBase0,0) ;mov r14, rsi ;add r14, edx ;mov byte ptr [r14], 'g' // gán ký tự 'g' $op_code01 &= "4C 8B F6 49 01 D6 41 C6 06 67" ;// $Visited[$sx_bfs][$sy_bfs] = 1 ; mov r14, newmem $op_code01 &= "49 BE "&_ReadF($newmem0,0) ;mov esi, [r14+10] // Global esi = $sx_bfs = 10 ;mov edi, [r14+14] // Global edi = $sy_bfs = 10 $op_code01 &= "41 8B 76 10 41 8B 7E 14" ; mov r14, visitedBase // base của Visited $op_code01 &= "49 BE "&_ReadF($visitedBase0,0) ;mov rdx, esi // rdx = $sx_bfs ;imul rdx, (Int)20 // rdx = $sx_bfs * 20 ;add rdx, edi // rdx = $sx_bfs * 20 + $sy_bfs ;mov byte ptr [r14+rdx], 1 // Visited[$sx_bfs][$sy_bfs] = 1 $op_code01 &= "48 8B D6 48 6B D2 "&$int_20&" 48 01 FA 42 C6 04 32 01" ;// Func BFS_Search($gx_bfs, $gy_bfs) ---------------------------------------- ; mov r14, newmem // r14 = base của newmem $op_code01 &= "49 BE "&_ReadF($newmem0,0) ;mov r15, queueBase // r15 = base của Queue $op_code01 &= "49 BF "&_ReadF($queueBase0,0) ;mov r10d, [r14+0] // r10d = front ;mov r11d, [r14+4] // r11d = rear ;mov r12d, [r14+20] // r12d = gx ;mov r13d, [r14+24] // r13d = gy ;mov ecx, 1 // ecx = i = 1 ;LoopStart: ;cmp ecx, 9C4 // For $i = 1 to 2500 $op_code01 &= "45 8B 16 45 8B 5E 04 45 8B 66 20 45 8B 6E 24 B9 01 00 00 00 81 F9 C4 09 00 00" ;jge LoopEnd $op_code01 &= "0F 8D 95 01 00 00" ;cmp r10d, r11d // If $front < $rear Then ;jge SkipBody ;imul r8d, r10d, 8 // offset = front * 8 ;mov rdx, r15 // rdx = base của Queue ;add rdx, r8 // rdx = Queue + offset ;mov esi, [rdx] // $x = Queue[front][0] ;mov edi, [rdx+4] // $y = Queue[front][1] ;inc r10d // $front += 1 $op_code01 &= "45 39 DA 0F 8D 85 01 00 00 45 6B C2 08 49 8B D7 4C 01 C2 8B 32 8B 7A 04 41 FF C2" ;cmp esi, r12d // If $x = $gx_bfs ;jne SkipCheck ; cmp edi, r13d // And $y = $gy_bfs ; jne SkipCheck ;// Đến đích rồi → dùng lại thanh ghi thoải mái ;jmp LoopEnd // ExitLoop nếu đến đích ;SkipCheck: ;mov [r14+30], esi // lưu $x cũ ;mov [r14+34], edi // lưu $y cũ $op_code01 &= "44 39 E6 75 1B 90 90 90 90 44 39 EF 75 12 90 90 90 90 E9 63 01 00 00 90 90 90 90 90 90 90 90 90 41 89 76 30 41 89 7E 34" ;mov r9d, 0 // For $d = 0 to 3 ;DirectionLoop: ;cmp r9d, 4 // kiểm tra d < 4 ;jge EndDirection ;mov eax, [r14+30] // load $nx = $x cũ ;mov ebx, [r14+34] // load $ny = $y cũ $op_code01 &= "41 B9 00 00 00 00 41 83 F9 04 0F 8D 3B 01 00 00 41 8B 46 30 41 8B 5E 34" ;cmp r9d, 0 ;jne Case1 ;dec eax // Case 0: $ny -= 1 → đi sang trái (←) ;jmp AfterSwitch ;Case1: ;cmp r9d, 1 ;jne Case2 ;inc eax // Case 1: $ny += 1 → đi sang phải (→) lỗi ;jmp AfterSwitch ;Case2: ;cmp r9d, 2 ;jne Case3 ;dec ebx // Case 2: $nx -= 1 → đi lên (↑) ;jmp AfterSwitch ;Case3: ;inc ebx // Case 3: $nx += 1 → đi xuống (↓) lỗi ;AfterSwitch: ;mov rsi, eax // rsi = nx hiện tại ;mov rdi, ebx // rdi = ny hiện tại $op_code01 &= "41 83 F9 00 75 14 90 90 90 90 FF C8 EB 42 90 90 90 90 90 90 90 90 90 90 90 90 41 83 F9 01 75 14 90 90 90 90 FF C0 EB 28 90 90 90 90 90 90 90 90 90 90 90 90 41 83 F9 02 75 14 90 90 90 90 FF CB EB 0E 90 90 90 90 90 90 90 90 90 90 90 90 FF C3 48 8B F0 48 8B FB" ;// If $nx < 0 Or $ny < 0 Or $nx >= 20 Or $ny >= 20 Then ContinueLoop ;cmp rsi, 0 // $nx < 0 ;jl SkipDirection ;cmp rdi, 0 // $ny < 0 ;jl SkipDirection ;cmp rsi, (Int)20 // $nx >= 20 ;jnl SkipDirection ;cmp rdi, (Int)20 // $ny >= 20 ;jnl SkipDirection ;// end kiểm tra biên $op_code01 &= "48 83 FE 00 0F 8C CB 00 00 00 48 83 FF 00 0F 8C C1 00 00 00 48 81 FE "&$int_20&" 00 00 00 0F 8D B4 00 00 00 48 81 FF "&$int_20&" 00 00 00 0F 8D A7 00 00 00" ;// If $map_bfs[$nx][$ny] = "x" Or $Visited[$nx][$ny] = 1 Then ContinueLoop ;mov r8d, rsi ;imul r8d, (Int)20 ;add r8d, rdi // r8d = nx * 20 + ny $op_code01 &= "4C 8B C6 45 6B C0 "&$int_20&" 49 01 F8" ;mov rdx, mapBase $op_code01 &= "48 BA "&_ReadF($mapBase0,0) ;add rdx, r8 ;mov al, [rdx] // đọc MAP[nx][ny] ;cmp al, 'x' // nếu là 'x' thì bỏ qua ;je SkipDirection $op_code01 &= "4C 01 C2 8A 02 3C 78 0F 84 86 00 00 00" ; mov rdx, visitedBase $op_code01 &= "48 BA "&_ReadF($visitedBase0,0) ;add rdx, r8 ;mov al, [rdx] // kiểm tra Visited[nx][ny] = 1 ;cmp al, 1 ;je SkipDirection ;// end kiểm tra chướng ngại và đã đi ;mov [r14+40], rsi // lưu $nx hiện tại ;mov [r14+44], rdi // lưu $ny hiện tại $op_code01 &= "4C 01 C2 8A 02 3C 01 74 73 90 90 90 90 49 89 76 40 49 89 7E 44" ; // $Visited[$nx][$ny] = 1 $op_code01 &= "48 BA "&_ReadF($visitedBase0,0) ;mov r8d, rsi ;imul r8d, (Int)20 ;add r8d, rdi // r8d = nx * 20 + ny ;add rdx, r8 ;mov byte ptr [rdx], 1 $op_code01 &= "4C 8B C6 45 6B C0 "&$int_20&" 49 01 F8 4C 01 C2 C6 02 01" ;// $Prev[$nx][$ny][0] = $x ;// $Prev[$nx][$ny][1] = $y ;mov rax, rsi // rsi = nx ;imul rax, (Int)20 // bị đổi thành imul rax,rax,14 ;add rax, rdi // rax = nx*20 + ny ;shl rax, 3 // *8 $op_code01 &= "48 8B C6 48 6B C0 "&$int_20&" 48 01 F8 48 C1 E0 03" ;mov rdx, prevBase $op_code01 &= "48 BA "&_ReadF($prevBase0,0) ;add rdx, rax ;mov esi, [r14+30] // load $x lúc đầu ;mov edi, [r14+34] // load $y lúc đầu ;mov [rdx], esi // x hiện tại ;mov [rdx+4], edi // y hiện tại ;mov rsi, [r14+40] // load $nx hiện tại ;mov rdi, [r14+44] // load $ny hiện tại $op_code01 &= "48 01 C2 41 8B 76 30 41 8B 7E 34 89 32 89 7A 04 49 8B 76 40 49 8B 7E 44" ;// $Queue[$rear][0] = $nx ;// $Queue[$rear][1] = $ny ;mov eax, r11d // eax = rear ;imul eax,eax,08 // eax = rear * 8 $op_code01 &= "41 8B C3 6B C0 08" ;mov rdx, queueBase $op_code01 &= "48 BA "&_ReadF($queueBase0,0) ;add rdx, rax ;mov [rdx+0], rsi // Queue[rear][0] = nx ;mov [rdx+4], rdi // Queue[rear][1] = ny ;//mov r10d, r11d // eax = rear bớt đường đi ;inc r11d // $rear += 1 ;SkipDirection: ;inc r9d // d++ ;jmp DirectionLoop ;EndDirection: ;SkipBody: ;inc ecx // i++ ;jmp LoopStart ;LoopEnd: $op_code01 &= "48 01 C2 48 89 32 48 89 7A 04 41 FF C3 41 FF C1 E9 BB FE FF FF FF C1 E9 5F FE FF FF" ; push r15 $op_code01 &= "41 57" ; mov r15, newmem+1000 // r15 = địa chỉ bắt đầu ghi đường đi 4096 = 0x1000 $op_code01 &= "49 BF "&_ReadF($newmem0+0x1000,0) ; mov r14, newmem // r14 = base chứa các biến sx, sy, gx, gy $op_code01 &= "49 BE "&_ReadF($newmem0,0) ;mov esi, [r14+20] // esi = gx (tọa độ x đích) ;mov edi, [r14+24] // edi = gy (tọa độ y đích) ;xor rbx, rbx // rbx = số bước đã ghi = 0 $op_code01 &= "41 8B 76 20 41 8B 7E 24 48 31 DB" ;LoopBack: ; cmp rbx, (Int)400 // giới hạn số bước tối đa ; jge ExitLoop // nếu vượt quá → thoát ; imul rcx, rbx, 8 // rcx = offset của bước thứ rbx ; add rcx, 4 // bỏ qua ô đầu tiên chứa số bước ; mov rdx, r15 ; add rdx, rcx // rdx = địa chỉ ghi bước hiện tại ; mov [rdx], esi // ghi x vào Path[rbx][0] ; mov [rdx+4], edi // ghi y vào Path[rbx][1] ; inc rbx // tăng số bước $op_code01 &= "48 81 FB 90 01 00 00 7D 68 90 90 90 90 48 6B CB 08 48 83 C1 04 49 8B D7 48 01 CA 89 32 89 7A 04 48 FF C3" ; // === Truy ngược từ prevBase[x][y] === ; mov eax, esi // eax = x ; imul eax, (Int)20 // x * 20 ; add eax, edi // x * 20 + y ; imul eax, 8 // offset trong prevBase $op_code01 &= "8B C6 6B C0 "&$int_20&" 01 F8 6B C0 08" ; mov r13, prevBase $op_code01 &= "49 BD"&_ReadF($prevBase0,0) ; add r13, rax // r13 = địa chỉ prevBase[x][y] ; mov esi, [r13] // esi = px (tọa độ x bước trước) ; mov edi, [r13+4] // edi = py (tọa độ y bước trước) $op_code01 &= "49 01 C5 41 8B 75 00 41 8B 7D 04" ; // === Kiểm tra đã về tới nguồn chưa === ; cmp esi, [r14+10] // sx ; jne LoopBack ; cmp edi, [r14+14] // sy ; jne LoopBack $op_code01 &= "41 3B 76 10 75 B8 41 3B 7E 14 75 B2" ; // === Ghi bước cuối cùng (nguồn) === ; cmp rbx, (Int)400 ; jge ExitLoop ; imul rcx, rbx, 8 ; add rcx, 4 ; mov rdx, r15 ; add rdx, rcx ; mov [rdx], esi // ghi sx vào Path[rbx][0] ; mov [rdx+4], edi // ghi sy vào Path[rbx][1] ; inc rbx ;ExitLoop: ;mov dword ptr [r15], ebx // ghi tổng số bước vào Path[0] ;pop r15 // khôi phục r15 $op_code01 &= "48 81 FB 90 01 00 00 7D 1A 90 90 90 90 48 6B CB 08 48 83 C1 04 49 8B D7 48 01 CA 89 32 89 7A 04 48 FF C3 41 89 1F 41 5F" ;pop rbp ;pop rbx ;pop rsi ;pop rdi ;ret // kết thúc an toàn $op_code01 &= "5D 5B 5E 5F C3" $op_code01 &= "" $op_code00 &= $op_code01 $op_code00 = StringReplace($op_code00, " ", "") $startBFS0.ASM = "0x"&$op_code00 EndFunc Func ASM64_opcode02vtmem($bytes0="1000", $alloc_address0=0) ; Tạo struct byte ASM[$bytes0] tại địa chỉ $alloc_address0 Local $tCodeBuffer_bfs = _DllStructCreate64_bfs("byte ASM[" & $bytes0 & "]", $alloc_address0) Return $tCodeBuffer_bfs EndFunc Func _DllStructCreate64_bfs($struct, $alloc_address0=0) ; align auf 16-byte adresse ; Nếu có địa chỉ cấp phát thì dùng luôn If $alloc_address0 <> 0 Then Local $sstruct = DllStructCreate($struct, $alloc_address0) Return $sstruct EndIf ; Nếu không có địa chỉ thì tự cấp phát mới Local $temp = DllStructCreate($struct) Local $tempsize = DllStructGetSize($temp) + 64 Local $ptr = DllStructGetPtr($temp) Local $a1 = Mod(Number($ptr), 64) Local $mem = _MemVirtualAlloc($ptr + $a1, $tempsize, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Local $a2 = Mod(Number($mem), 64) ; rest div 16 adresse = offset Local $sstruct = DllStructCreate($struct, (Number($mem) - $a2 + 64)) Return $sstruct ; auf 16 aligned pointer EndFunc ElseIf $xx > ($button_auto03[2])[1] And $yy > ($button_auto03[2])[2] And $xx < ($button_auto03[2])[1]+($button_auto03[2])[3] And $yy < ($button_auto03[2])[2]+($button_auto03[2])[4] Then ; click button "Select" $i = 1 ;$control01 = WinGetHandle("[REGEXPTITLE:\[#\] \[a"&$i&"\] Diablo Immortal \[#\]]") For $lp_test01 = 1 to $lp_test01max ; test error $control01 = WinGetHandle("[REGEXPTITLE:\[#\] \["& $a_sandbox[$i] & $i&"\] Diablo Immortal \[#\]]") Local $hTimer = TimerInit() ; START WinCapture_cs03 ---------------------------------------------------------------------------------------------------------------------- Global $stream02 = WinCapture_cs03($control01,3,$game_cap_x02,$game_cap_y02,$view_screen01,$game_cap_x01,$game_cap_y01,$g_x,$g_y,$copy_view01) ; chay only show gui image $a_fog_green02xy = $stream02[12] WinCapture_ce03($stream02[3], $stream02[4], $stream02[5], $stream02[6], $stream02[7], $stream02[0], $stream02[13]) ; remove print image -------------------------- ; END WinCapture_cs03 ---------------------------------------------------------------------------------------------------------------------- Local $iDiff = TimerDiff($hTimer) ; time in seconds GUICtrlSetData($button_submit02, "") GUICtrlSetData($button_submit02, "$control01="&$control01&" $iDiff="&Int($iDiff)&"s"&@CRLF&" WinCapture_cs03") ;MsgBox($MB_SYSTEMMODAL, "Title", "$control01="&$control01&" $iDiff="&Int($iDiff)&"s"&@CRLF&" WinCapture_cs03" , 0) ;_ArrayDisplay($stream02[12]) ;$hBrush = _GDIPlus_BrushCreateSolid() ;_ArrayDisplay($stream02[12]) ;$hBrush = _GDIPlus_BrushCreateSolid() ;$a_fog_green02xy = _check_map03($loopacc,$tiled_map01) Func _check_map03($loopacc0=1,$tiled_map0=0) If $tiled_map0 = 1 Then ; $tiled_map01 = 1 If $loopacc = $loop_view01 Then _GDIPlus_GraphicsClear($hGraphic) $view_gdi01on = 0 If _IsChecked( ($button_auto03[4])[7-1] ) = True Then $view_gdi01on = 1 Dim $data_map[$rows_scale][$col_scale] $map_min01x = $map_c01x $map_max01x = $map_c01x $map_min01y = $map_c01y $map_max01y = $map_c01y $iY_max = UBound($stream02[12], $UBOUND_ROWS)-1 $iX_max = UBound($stream02[12], $UBOUND_COLUMNS)-1 ;MsgBox($MB_SYSTEMMODAL, "Title", "$col_scale+1="&$col_scale+1 & "$rows_scale+1="&$rows_scale+1&" $iX_max="&$iX_max & "$iY_max="&$iY_max , 0) $MAP_LEFT_UP = 0 $MAP_RIGHT_UP = 0 $MAP_LEFT_DOWN = 0 $MAP_RIGHT_DOWN = 0 $MAP_CENTER_MAX = 5 For $iY = $mini_min01y To $MAP_CENTER_MAX For $iX = $mini_min01x To $MAP_CENTER_MAX If TestTrans05("000000", ($stream02[12])[$iY][$iX], 70) = 1 Then $MAP_LEFT_UP = 1 ExitLoop EndIf Next Next For $iY = $mini_min01y To $MAP_CENTER_MAX For $iX = $mini_max01x-$MAP_CENTER_MAX To $iX_max If TestTrans05("000000", ($stream02[12])[$iY][$iX], 70) = 1 Then $MAP_RIGHT_UP = 1 ExitLoop EndIf Next Next For $iY = $mini_max01y-$MAP_CENTER_MAX To $iY_max For $iX = $mini_min01x To $MAP_CENTER_MAX If TestTrans05("000000", ($stream02[12])[$iY][$iX], 70) = 1 Then $MAP_LEFT_DOWN = 1 ExitLoop EndIf Next Next For $iY = $mini_max01y-$MAP_CENTER_MAX To $iY_max For $iX = $mini_max01x-$MAP_CENTER_MAX To $iX_max If TestTrans05("000000", ($stream02[12])[$iY][$iX], 70) = 1 Then $MAP_RIGHT_DOWN = 1 ExitLoop EndIf Next Next If $MAP_LEFT_UP = 1 and $MAP_RIGHT_UP = 1 and $MAP_LEFT_DOWN = 1 and $MAP_RIGHT_DOWN = 1 Then ; CHECK FALSE LARGE MAP $map_min01x = $mini_min01x $map_max01x = $mini_max01x $map_min01y = $mini_min01y $map_max01y = $mini_max01y GUICtrlSetData($button_submit02, " N="&$loopacc0&" _check_map03="&"FALSE LARGE MAP") Else GUICtrlSetData($button_submit02, " N="&$loopacc0&" _check_map03="&"TRUE LARGE MAP") ; MsgBox($MB_SYSTEMMODAL, "Title", "$mini_min01x="&$mini_min01x& " $mini_max01x="&$mini_max01x& " $mini_min01y="&$mini_min01y& " $mini_max01y="&$mini_max01y&" $iY_max="&$iY_max&" $iX_max="&$iX_max , 0) ;_ArrayDisplay($data_map) $switch_map = 2 $fog_green01on = 1 $mini_array = 10+1 Dim $a_fog_green02xy[$mini_array][2] $mini_c01x = $mini_min01x + $start_cols01 $mini_c01y = $mini_min01y + $start_rows01 $mini_max = 10 $a_fog_green02num = 1 $a_fog_green02min = 20 $a_fog_green02max = 25 ;MsgBox($MB_SYSTEMMODAL, "Title", "$mini_c01x="&$mini_c01x & "$mini_c01y="&$mini_c01y&" $iY-$mini_min01y="&$mini_min01y & " $iX-$mini_min01x="&$mini_min01x , 0) If $switch_map = 1 Then For $iY = $mini_min01y To $mini_max01y For $iX = $mini_min01x To $mini_max01x-10 ;_GDIPlus_BrushSetSolidColor($hBrush, $stream02[12][$iY][$iX]) $a_fog_green01dis = 0 If $iX > $mini_c01x-$mini_max and $iX < $mini_c01x+$mini_max and $iY > $mini_c01y-$mini_max and $mini_c01y < $mini_c01y+$mini_max Then $a_fog_green01dis = 1 ;If TestTrans05("000000", ($stream02[12])[$iY][$iX], 1) = 1 Then If ($stream02[12])[$iY][$iX] = "000000" Then If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $iX * $title_size01x-270 , $iY * $title_size01y + 210 , $tileWidth, $tileHeight, $Brush_gray) ;If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $iX * ($tileWidth + $distance) + $distance, $iY * ($tileHeight + $distance) + $distance, $tileWidth, $tileHeight, $Brush_gray) $data_map[$iY-$mini_min01y][$iX-$mini_min01x] = "0" ElseIf $a_fog_green02num < $mini_array-1 and $a_fog_green02min > $a_fog_green02max and $a_fog_green01dis = 0 and ($stream02[12])[$iY+0][$iX+0] = "00FF00" Then $count_green01 = 1 If ($stream02[12])[$iY+1][$iX+1] = "00FF00" Then $count_green01 += 1 If ($stream02[12])[$iY+1][$iX+0] = "00FF00" Then $count_green01 += 1 If ($stream02[12])[$iY+0][$iX+1] = "00FF00" Then $count_green01 += 1 If $count_green01 > 2-1 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $iX * $title_size01x-270, $iY * $title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) GUICtrlSetData($button_submit02, " N="&$loopacc0&" [$a_fog_green02num]="&$a_fog_green02num&" $iX="&$iX&" $iY="&$iY) EndIf $a_fog_green02xy[$a_fog_green02num][0] = $iX $a_fog_green02xy[$a_fog_green02num][1] = $iY $a_fog_green02num += 1 $a_fog_green02min = 0 EndIf Else ;MsgBox($MB_SYSTEMMODAL, "Title", "$iY="&$iY & "$iX="&$iX&" $iY-$mini_min01y="&$iY-$mini_min01y & " $iX-$mini_min01x="&$iX-$mini_min01x , 0) $data_map[$iY-$mini_min01y][$iX-$mini_min01x] = "x" EndIf $a_fog_green02min += 1 Next Next ElseIf $switch_map = 2 Then For $iY = $mini_min01y To $mini_max01y For $iX = $mini_min01x To $mini_max01x-10 ;_GDIPlus_BrushSetSolidColor($hBrush, $stream02[12][$iY][$iX]) $a_fog_green01dis = 0 If $iX > $mini_c01x-$mini_max and $iX < $mini_c01x+$mini_max and $iY > $mini_c01y-$mini_max and $mini_c01y < $mini_c01y+$mini_max Then $a_fog_green01dis = 1 ;If TestTrans05("000000", ($stream02[12])[$iY][$iX], 1) = 1 Then If ($stream02[12])[$iY][$iX] = "FFFFFF" Then ;If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $iX * ($tileWidth + $distance) + $distance, $iY * ($tileHeight + $distance) + $distance, $tileWidth, $tileHeight, $Brush_gray) $data_map[$iY-$mini_min01y][$iX-$mini_min01x] = "x" ElseIf $a_fog_green02num < $mini_array-1 and $a_fog_green02min > $a_fog_green02max and $a_fog_green01dis = 0 and ($stream02[12])[$iY+0][$iX+0] = "00FF00" Then $count_green01 = 1 If ($stream02[12])[$iY+1][$iX+1] = "00FF00" Then $count_green01 += 1 If ($stream02[12])[$iY+1][$iX+0] = "00FF00" Then $count_green01 += 1 If ($stream02[12])[$iY+0][$iX+1] = "00FF00" Then $count_green01 += 1 If $count_green01 > 2-1 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $iX * $title_size01x-270, $iY * $title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) GUICtrlSetData($button_submit02, " N="&$loopacc0&" [$a_fog_green02num]="&$a_fog_green02num&" $iX="&$iX&" $iY="&$iY) EndIf $a_fog_green02xy[$a_fog_green02num][0] = $iX $a_fog_green02xy[$a_fog_green02num][1] = $iY $a_fog_green02num += 1 $a_fog_green02min = 0 EndIf Else ;MsgBox($MB_SYSTEMMODAL, "Title", "$iY="&$iY & "$iX="&$iX&" $iY-$mini_min01y="&$iY-$mini_min01y & " $iX-$mini_min01x="&$iX-$mini_min01x , 0) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $iX * $title_size01x-270 , $iY * $title_size01y + 210 , $tileWidth, $tileHeight, $Brush_gray) $data_map[$iY-$mini_min01y][$iX-$mini_min01x] = "0" EndIf $a_fog_green02min += 1 Next Next EndIf ;_ArrayDisplay($a_fog_green02xy) ; WALL MAP For $y_wall = $mini_min01y to $mini_max01y+2 $data_map[$y_wall-$mini_min01y][$mini_min01x-$mini_min01x] = "x" $data_map[$y_wall-$mini_min01y][$mini_max01x-$mini_min01x] = "x" $data_map[$y_wall-$mini_min01y][$mini_max01x-$mini_min01x-9] = "x" If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $mini_min01x*$title_size01x-270, $y_wall*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $mini_max01x*$title_size01x-270, $y_wall*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) Next For $x_wall = $mini_min01x to $mini_max01x+2 $data_map[$mini_min01y-$mini_min01y][$x_wall-$mini_min01x] = "x" $data_map[$mini_max01y-$mini_min01y][$x_wall-$mini_min01x] = "x" If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x_wall*$title_size01x-270 , ($mini_min01y-$mini_min01y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x_wall*$title_size01x-270 , ($mini_max01y+$mini_min01y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) Next For $lp_y = $start_rows01-3 to $start_rows01+3 For $lp_x = $start_cols01-3 to $start_cols01+3 $data_map[$lp_y][$lp_x] = "0" If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$lp_x)*$title_size01x-270 , ($mini_max01y-$lp_y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_gray) Next Next If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+0)*$title_size01x-270 , ($mini_max01y-$start_rows01+1)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+1)*$title_size01x-270 , ($mini_max01y-$start_rows01+0)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+0)*$title_size01x-270 , ($mini_max01y-$start_rows01+0)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+1)*$title_size01x-270 , ($mini_max01y-$start_rows01+1)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) $data_map[$start_rows01][$start_cols01] = "s" Global $start_red = ($start_rows01 - 0) * $cols + ($start_rows01 - 0) $data = $data_map ;_ArrayDisplay($data_map) ;MsgBox($MB_SYSTEMMODAL, "Title", "x="&UBound($stream02[12], $UBOUND_COLUMNS)-0-40 & "y="&UBound($stream02[12], $UBOUND_ROWS)-0-24 , 0) ; END WALL MAP EndIf ; END CHECK FALSE LARGE MAP $a_map_min00x[$loopacc0] = $mini_min01x $a_map_max00x[$loopacc0] = $mini_max01x $a_map_min00y[$loopacc0] = $mini_min01y $a_map_max00y[$loopacc0] = $mini_max01y GUICtrlSetData($button_submit02, " N="&$loopacc0&" $map_min01x="&$map_min01x&" $map_max01x="&$map_max01x&" $map_min01y="&$map_min01y&" $map_max01y="&$map_max01y) Return $a_fog_green02xy EndIf ; end $tiled_map01 = 1 EndFunc Local $iDiff = TimerDiff($hTimer) ; time in seconds GUICtrlSetData($button_submit02, " $iDiff="&Int($iDiff)&"s"&@CRLF&" _check_map03($loopacc,$tiled_map01)") If $a_map_min00x[$loopacc] < 20 and $a_map_max00x[$loopacc] > $col_scale-20 and $a_map_min00y[$loopacc] < 20 and $a_map_max00y[$loopacc] > $rows_scale-20 Then _MemoryWrite64($a_local01[$loopacc]+0x4, $procHwnd_autoit01, ptr(0),'byte[4]') ; reset value = 0 GUICtrlSetData($button_submit02, " N="&$loopacc&" _all_find_a03($loopacc) = "&"FALSE LARGE MAP") ElseIf $stream02[14] = 0 Then _MemoryWrite64($a_local01[$loopacc]+0x4, $procHwnd_autoit01, ptr(0),'byte[4]') ; reset value = 0 GUICtrlSetData($button_submit02, " N="&$loopacc&" _all_find_a03($loopacc) = "&"FALSE LARGE MAP") Else GUICtrlSetData($button_submit02, " N="&$loopacc&" _all_find_a03($loopacc) = "&"TRUE LARGE MAP") $random0 = Random(1,2,1) _all_find_a03($loopacc,40,$random0) EndIf Local $iDiff = TimerDiff($hTimer) ; time in seconds GUICtrlSetData($button_submit02, " $iDiff="&Int($iDiff)&"s"&@CRLF&" _all_find_a03($loopacc)") Func _all_find_a03($loopacc0,$lp_green0=100,$lp_goal0=5,$not_map_max0=-1) ; random GOAL MAP Local $a_goal01xy[11][2] $goal_random01min = 0 $goal_random01max = $lp_goal0 $dis_center01max = 7 $dis_center02max = 7 $dis_portal01max = 6 $dis_portal02max = 6 $dis_portal03max = 6 $start_red_x01 = $start_cols01 $start_red_y01 = $start_rows01 $find_switch01 = 1 $lp_switch_exit = 0 ;If $a_fog_green02xy[1][0] <> "" and $a_fog_green02xy[1][1] <> "" and $a_fog_green02xy[2][0] <> "" and $a_fog_green02xy[2][1] <> "" and $a_fog_green02xy[3][0] <> "" and $a_fog_green02xy[3][1] <> "" Then $find_switch01 = 2 ;_ArrayDisplay($a_fog_green02xy) ;_ArrayDisplay($data_map) ;_ArrayDisplay($a_goal01xy) ; will show the the full path For $lp_switch = 2 to 2 ; $find_switch01 = 1 > 2 If $lp_switch = 2 Then ; $lp_switch = 2 For $lp = 1 to $lp_green0 $goal_map01x = Random($a_map_min00x[$loopacc0], $a_map_max00x[$loopacc0], 3) $goal_map01y = Random($a_map_min00y[$loopacc0], $a_map_max00y[$loopacc0], 3) $dis_center01 = Int( Distance($goal_map01x-$mini_min01x,$goal_map01y-$mini_min01y,$start_red_x01,$start_red_y01) ) $dis_portal01 = -1 $dis_portal02 = -1 $dis_portal03 = -1 If $not_map_max0 > 1 and $not_map_max0 < 2+1 Then $portal01x = Int( ($a_not_map01[$loopacc])[$not_map_max0][3] /($tileWidth+$distance)) $portal01y = Int( ($a_not_map01[$loopacc])[$not_map_max0][4] /($tileHeight+$distance)) $dis_portal01 = Int( Distance($goal_map01x-$mini_min01x,$goal_map01y-$mini_min01y,$portal01x,$portal01y) ) $portal02x = Int( ($a_not_map01[$loopacc])[$not_map_max0-1][3] /($tileWidth+$distance)) $portal02y = Int( ($a_not_map01[$loopacc])[$not_map_max0-1][4] /($tileHeight+$distance)) $dis_portal02 = Int( Distance($goal_map01x-$mini_min01x,$goal_map01y-$mini_min01y,$portal02x,$portal02y) ) ElseIf $not_map_max0 > 2 Then $portal01x = Int( ($a_not_map01[$loopacc])[$not_map_max0][3] /($tileWidth+$distance)) $portal01y = Int( ($a_not_map01[$loopacc])[$not_map_max0][4] /($tileHeight+$distance)) $dis_portal01 = Int( Distance($goal_map01x-$mini_min01x,$goal_map01y-$mini_min01y,$portal01x,$portal01y) ) $portal02x = Int( ($a_not_map01[$loopacc])[$not_map_max0-1][3] /($tileWidth+$distance)) $portal02y = Int( ($a_not_map01[$loopacc])[$not_map_max0-1][4] /($tileHeight+$distance)) $dis_portal02 = Int( Distance($goal_map01x-$mini_min01x,$goal_map01y-$mini_min01y,$portal02x,$portal02y) ) $portal03x = Int( ($a_not_map01[$loopacc])[$not_map_max0-2][3] /($tileWidth+$distance)) $portal03y = Int( ($a_not_map01[$loopacc])[$not_map_max0-2][4] /($tileHeight+$distance)) $dis_portal03 = Int( Distance($goal_map01x-$mini_min01x,$goal_map01y-$mini_min01y,$portal03x,$portal03y) ) EndIf If $dis_portal01 = -1 and $dis_portal02 = -1 Then ; fix $dis_portal01 = $dis_portal01max+1 $dis_portal02 = $dis_portal02max+1 $dis_portal03 = $dis_portal03max+1 ElseIf $dis_portal01 > -1 and $dis_portal02 > -1 and $dis_portal03 = -1 Then ; fix $dis_portal03 = $dis_portal03max+1 EndIf If $data_map[$goal_map01y-$mini_min01y][$goal_map01x-$mini_min01x] = "0" and $dis_center01 > $dis_center01max and $dis_portal01 > $dis_portal01max and $dis_portal02 > $dis_portal02max and $dis_portal03 > $dis_portal03max Then If $goal_random01min = 0 Then If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " N="&$loopacc0&" $goal_map01x="&$goal_map01x&"$goal_map01y="&$goal_map01y&"$data_map[y][x]"&$data_map[$goal_map01y-$mini_min01y][$goal_map01x-$mini_min01x]&" $dis_center01="&$dis_center01) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x+0) *$title_size01x-270, ($goal_map01y+0) *$title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x+1) *$title_size01x-270, ($goal_map01y+1) *$title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x+1) *$title_size01x-270, ($goal_map01y+0) *$title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x+0) *$title_size01x-270, ($goal_map01y+1) *$title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) EndIf $goal_random01min += 1 $a_goal01xy[$goal_random01min][0] = Int($goal_map01x-$mini_min01x) $a_goal01xy[$goal_random01min][1] = Int($goal_map01y-$mini_min01y) ElseIf $goal_random01min > 0 Then $dis_center01 = Int( Distance($goal_map01x-$mini_min01x,$goal_map01y-$mini_min01y,$a_goal01xy[$goal_random01min][0],$a_goal01xy[$goal_random01min][1]) ) If $dis_center01 > $dis_center02max Then If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " N="&$loopacc0&" $goal_map01x="&$goal_map01x&"$goal_map01y="&$goal_map01y&"$data_map[y][x]"&$data_map[$goal_map01y-$mini_min01y][$goal_map01x-$mini_min01x]&" $dis_center01="&$dis_center01) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x+0) *$title_size01x-270, ($goal_map01y+0) *$title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x+1) *$title_size01x-270, ($goal_map01y+1) *$title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x+1) *$title_size01x-270, ($goal_map01y+0) *$title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) _GDIPlus_GraphicsFillRect($hGraphic, ($goal_map01x+0) *$title_size01x-270, ($goal_map01y+1) *$title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) EndIf $goal_random01min += 1 $a_goal01xy[$goal_random01min][0] = Int($goal_map01x-$mini_min01x) $a_goal01xy[$goal_random01min][1] = Int($goal_map01y-$mini_min01y) EndIf EndIf If $goal_random01min > $goal_random01max-1 Then ExitLoop EndIf Next EndIf ; end $lp_switch = 2 ; end random GOAL MAP ;_ArrayDisplay($a_goal01xy) ; will show the the full path ; _start_find01 Local $a_path01xy[11][2] ;_ArrayDisplay($data_map) ; will show the the full path For $lp_find = 1 to $goal_random01max If $a_goal01xy[$lp_find][0] <> "" Then If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit02, " N="&$loopacc0&" $start_red_x01="&$start_red_x01&" $start_red_y01="&$start_red_y01&" $a_goal01xy[$lp_find][0]="&$a_goal01xy[$lp_find][0]&" $a_goal01xy[$lp_find][1]="&$a_goal01xy[$lp_find][1]) If _IsChecked( ($button_auto02[5])[7-1] ) = True Then $a_path01xy[$lp_find][0] = _start_find01(1,$start_red_x01,$start_red_y01,$a_goal01xy[$lp_find][0],$a_goal01xy[$lp_find][1]) $a_path01xy[$lp_find][1] = UBound( ($a_path01xy[$lp_find][0]), $UBOUND_ROWS) ElseIf _IsChecked( ($button_auto02[5])[7-1] ) = False Then $a_path01xy[$lp_find][0] = _start_find01(0,$start_red_x01,$start_red_y01,$a_goal01xy[$lp_find][0],$a_goal01xy[$lp_find][1]) $a_path01xy[$lp_find][1] = UBound( ($a_path01xy[$lp_find][0]), $UBOUND_ROWS) EndIf ElseIf $a_goal01xy[$lp_find][0] = "" Then ExitLoop EndIf Next If $lp_switch = 1 and $a_path01xy[1][1] <> "" and $a_path01xy[1][1] <> 0 Then $lp_switch_exit = 1 If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit01, "$lp_switch = "& $lp_switch & " $lp_switch_exit = "&$lp_switch_exit) ;_ArrayDisplay($a_path01xy,"$lp_exit="&$lp_switch_exit) ; will show the the full path If $lp_switch_exit = 1 Then ExitLoop Next ; end $find_switch01 = 1 > 2 $step_max01num = 0 $step_max01step = 0 For $lp_max = 1 to $goal_random01max If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit01, "$lp_max = "& $lp_max & " $a_path01xy[$lp_max][1] = "&$a_path01xy[$lp_max][1]) If $a_path01xy[$lp_max][1] > $step_max01step Then $step_max01step = $a_path01xy[$lp_max][1] $step_max01num = $lp_max EndIf Next If $loopacc = $loop_view01 Then GUICtrlSetData($button_submit01, " $step_max01num = "&$step_max01num & " $step_max01step = "&$step_max01step) GUICtrlSetData($button_submit01, _ArrayToString($a_path01xy[$step_max01num][0])) EndIf ;Local $a_path01 = -1 ; fix error check array Local $a_path01 = $a_path01xy[$step_max01num][0] $max1 = 0 If IsArray($a_path01) Then Local $max1 = UBound($a_path01)-1 ; fix error check array If $max1 > 0 Then For $lp_a = 0 to $max1 Local $a_coord = StringSplit($a_path01[$lp_a], ",") Local $x = $a_coord[1] ; dao $x $y Local $y = $a_coord[2] ; thanh $y $x _MemoryWrite64($a_local01[$loopacc0]+0x108+0x8*$lp_a, $procHwnd_autoit01, ptr($x),'byte[4]') ; reset value = 0 _MemoryWrite64($a_local01[$loopacc0]+0x10C+0x8*$lp_a, $procHwnd_autoit01, ptr($y),'byte[4]') ; reset value = 0 Next EndIf _MemoryWrite64($a_local01[$loopacc0]+0x104, $procHwnd_autoit01, ptr($max1),'byte[4]') ; reset value = 0 ;GUICtrlSetData($button_submit01, "$step_max01num = "&$step_max01num & " $step_max01step = "&$step_max01step& " $a_local01[$loopacc0] = "&Hex($a_local01[$loopacc0]) ) ;Return $a_path01xy[$step_max01num][0] ; end _start_find01 EndFunc ;draw_map01($tiled_map01,0, 320, 0, 241 ) Next ; end test error ElseIf $xx > ($button_auto03[3])[1] And $yy > ($button_auto03[3])[2] And $xx < ($button_auto03[3])[1]+($button_auto03[3])[3] And $yy < ($button_auto03[3])[2]+($button_auto03[3])[4] Then ; click button "Select" ElseIf $xx > ($button_auto03[4])[1] And $yy > ($button_auto03[4])[2] And $xx < ($button_auto03[4])[1]+($button_auto03[4])[3] And $yy < ($button_auto03[4])[2]+($button_auto03[4])[4] Then ; click button "Select" ElseIf $xx > ($button_auto03[5])[1] And $yy > ($button_auto03[5])[2] And $xx < ($button_auto03[5])[1]+($button_auto03[5])[3] And $yy < ($button_auto03[5])[2]+($button_auto03[5])[4] Then ; click button "Select" ElseIf $xx > ($button_auto03[6])[1] And $yy > ($button_auto03[6])[2] And $xx < ($button_auto03[6])[1]+($button_auto03[6])[3] And $yy < ($button_auto03[6])[2]+($button_auto03[6])[4] Then ; click button "Select" _all_find_a01() Func _all_find_a01() Local $a_path01 = -1 ; fix error check array Local $max1 = UBound($a_map_goal01[$loopacc], $UBOUND_ROWS)-1 $goal_random01 = Random(1, $max1, 1) For $lpg = $goal_random01 to $max1 $c_g01x = ($a_map_goal01[$loopacc])[$lpg][1] $c_g01y = ($a_map_goal01[$loopacc])[$lpg][2] $green01on = 1 $Dis_star01 = Int( Distance($c_g01x ,$c_g01y , $start_red_x01, $start_red_y01) ) If $green01on = 1 and $Dis_star01 > $Dis_star01max Then GUICtrlSetData($button_submit02, "N="&$lpg&" $data_map"&" X="&$c_g01x&" Y="&$c_g01y&" COLOR="&$data_map[$c_g01y][$c_g01x]&" $Dis_star01="&$Dis_star01& @CR) If _IsChecked( ($button_auto02[5])[7-1] ) = True Then $a_path01 = _start_find01(1,$start_red_x01,$start_red_y01,$c_g01x,$c_g01y) ElseIf _IsChecked( ($button_auto02[5])[7-1] ) = False Then $a_path01 = _start_find01(0,$start_red_x01,$start_red_y01,$c_g01x,$c_g01y) EndIf ;_MemoryWrite64($a_local01[$loopacc], $procHwnd_autoit01, ptr(99),'byte[16]') ; reset value = 0 If $a_path01 <> -1 Then ExitLoop EndIf Next $max1 = 0 If IsArray($a_path01) Then Local $max1 = UBound($a_path01)-1 ; fix error check array If $max1 > 0 Then For $lp_a = 0 to $max1 Local $a_coord = StringSplit($a_path01[$lp_a], ",") Local $x = $a_coord[1] ; dao $x $y Local $y = $a_coord[2] ; thanh $y $x _MemoryWrite64($a_local01[$loopacc]+0x8+0x8*$lp_a, $procHwnd_autoit01, ptr($x),'byte[4]') ; reset value = 0 _MemoryWrite64($a_local01[$loopacc]+0xC+0x8*$lp_a, $procHwnd_autoit01, ptr($y),'byte[4]') ; reset value = 0 Next EndIf _MemoryWrite64($a_local01[$loopacc]+0x4, $procHwnd_autoit01, ptr($max1),'byte[4]') ; reset value = 0 ; _MemoryWrite64($a_local01[$loopacc]+0x0, $procHwnd_autoit01, ptr(0),'byte[4]') ; reset value = 0 ;_ArrayDisplay($a_path01) ; will show the the full path EndFunc EndIf ; END ALL BUTTION EndIf ; end check press mouse left EndSwitch ; end $open[0] To $open[$cols * $rows - 1] WEnd Func draw_map01($tiled_map0=0, $x_min=0, $x_max=1, $y_min=0, $y_max=1) If $tiled_map0 = 1 Then ; $tiled_map01 = 1 If $loopacc = $loop_view01 Then _GDIPlus_GraphicsClear($hGraphic) For $y = $y_min To $y_max - 0 For $x = $x_min To $x_max - 0 $map_cols01 = $x-$mini_min01x $map_rows01 = $y-$mini_min01y Select Case $x = 0 Or $y = 0 Or $x = $cols - 1 Or $y = $rows - 1 ;ConsoleWrite("draw_map01"&" $y_min="&$y_min&" $y_max="&$y_max&" $x_min="&$x_min&" $x_max="&$x_max&" $map_cols01="&$map_cols01&" $map_rows01="&$map_rows01& @CR) $data_map[$map_rows01][$map_cols01] = "x" ;If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x * ($tileWidth + $distance) + $distance, $y * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_mask) Case $data_map[$map_rows01][$map_cols01] = "" $data_map[$map_rows01][$map_cols01] = "x" ;If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x * ($tileWidth + $distance) + $distance, $y * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_black) Case $data_map[$map_rows01][$map_cols01] = "x" ;If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x * ($tileWidth + $distance) + $distance, $y * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_black) Case $data_map[$map_rows01][$map_cols01] = "s" $start_cols01 = $x $start_rows01 = $y $start_red = $y * $cols + $x ;If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x * ($tileWidth + $distance) + $distance, $y * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_red) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x* $title_size01x-270 , $y* $title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) ;ConsoleWrite("draw_map01"&" $start_cols01="&$start_cols01&" $start_rows01="&$start_rows01& @CR) Case $data_map[$map_rows01][$map_cols01] = "0" ;If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x * ($tileWidth + $distance) + $distance, $y * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_gray) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x* $title_size01x-270 , $y* $title_size01y+210 , $tileWidth, $tileHeight, $Brush_gray) Case $data_map[$map_rows01][$map_cols01] = "g" $goal_cols01 = $x $goal_rows01 = $y $goal_green = $y * $cols + $x ;If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x * ($tileWidth + $distance) + $distance, $y * ($tileHeight + $distance) + $distance, $tileWidth_pos, $tileHeight_pos, $Brush_green) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x* $title_size01x-270 , $y* $title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) ;ConsoleWrite("draw_map01"&" $goal_cols01="&$goal_cols01&" $goal_rows01="&$goal_rows01& @CR) Case Else EndSelect ;If $x = 2 and $y = 2 Then MsgBox($MB_SYSTEMMODAL, "Title", "$open[$y * $cols + $x]="&$open[$y * $cols + $x]&" $y * $cols + $x="&$y * $cols + $x&" $x="&$x&" $y="&$y, 0) Next Next EndIf ; end $tiled_map01 = 1 EndFunc Func _ArrayCreate($v_0, $v_1 = 0, $v_2 = 0, $v_3 = 0, $v_4 = 0, $v_5 = 0, $v_6 = 0, $v_7 = 0, $v_8 = 0, $v_9 = 0, $v_10 = 0, $v_11 = 0, $v_12 = 0, $v_13 = 0, $v_14 = 0, $v_15 = 0, $v_16 = 0, $v_17 = 0, $v_18 = 0, $v_19 = 0, $v_20 = 0) Local $av_Array[21] = [$v_0, $v_1, $v_2, $v_3, $v_4, $v_5, $v_6, $v_7, $v_8, $v_9, $v_10, $v_11, $v_12, $v_13, $v_14, $v_15, $v_16, $v_17, $v_18, $v_19, $v_20] ReDim $av_Array[@NumParams] Return $av_Array EndFunc ;==>_ArrayCreate ;============================================================================= ; Replaces data grid with node objects ; Converts $data into a 2D array of node objects from previous $data array ; consisting of only string characters. ;============================================================================= Func _CreateMap(ByRef $data0, $x_min, $y_min, $x_max, $y_max) ;converts a 2D array of data to node objects ; dao x y nguoc ;_CreateMap($data_map,0,0,$cols,$rows) For $i = $y_min To $y_max - 1 ;for each row For $j = $x_min To $x_max - 1 ;for each column ;ConsoleWrite("_CreateMap"&" $y_min="&$y_min&" $y_max="&$y_max&" $x_min="&$x_min&" $x_max="&$x_max&" $i="&$i&" $j="&$j& @CR) ;If StringRegExp($data[$i][$j], "[x,s,g]") <> 1 Then;if not a x,s,g If StringRegExp($data0[$i][$j], "[x,s]") <> 1 Then;if not a x,s fix error g $data[$i][$j] = _CreateNode($i & "," & $j, "null", 0, $data0[$i][$j], 0, $data0[$i][$j]) Else If $data0[$i][$j] = "s" Then $data[$i][$j] = _CreateNode($i & "," & $j, "null", 0, 0, 0, $data0[$i][$j]) Else $data[$i][$j] = _CreateNode($i & "," & $j, "null", 0, 1, 0, $data0[$i][$j]) EndIf EndIf Next Next EndFunc ;==>_CreateMap ;============================================================================= ; Creates a node struct object with the following parameters ; struct node { ; char self_coord[8]; // Format = "x,y" ; char parent_coord[8]; // Format = "x,y" ; int f; // F = G + H ; int g; // G = current cost to this node from start node ; int h; // H = Heuristic cost, this node to goal node ; char value[8]; // Type of node (ex. "s","g","x","1,2,3..n") ; int cost; // Cost of node (difficulty of traveling on this) ; } ;============================================================================= Func _CreateNode($self, $parent, $f, $g, $h, $value) ;returns struct object Local $node[6] = [$self, $parent, $f, $g, $h, $value] ;_ArrayDisplay($node) ; will show the the full path Return $node EndFunc ;==>_CreateNode ;============================================================================= ; Checks to see if start node exists in map ; Returns an array: [y,x] ;============================================================================= Func _GetStartingLocation(ByRef $data, $cols, $rows) For $i = 0 To $cols - 1 For $j = 0 To $rows - 1 If $data[$i][$j] = "s" Then Local $pos[2] = [$j, $i] Return $pos EndIf Next Next Return 0 ;no starting location found EndFunc ;==>_GetStartingLocation ;============================================================================= ; Checks to see if goal node exists in map ; Returns an array: [y,x] ;============================================================================= Func _GetGoalLocation(ByRef $data, $cols, $rows) For $i = 0 To $cols - 1 For $j = 0 To $rows - 1 If $data[$i][$j] = "g" Then Local $pos[2] = [$j, $i] Return $pos EndIf Next Next Return 0 ;no starting location found EndFunc ;==>_GetGoalLocation ;============================================================================= ; Calculates the manhattan distance between two nodes ; MD = |G(x) - N(x)| + |G(y) - N(x)| ; Returns an integer ;============================================================================= Func _MD(ByRef $node, ByRef $goal) ;returns integer Local $node_coord = StringSplit($node[0], ",") ;current node Local $goal_coord = StringSplit($goal[0], ",") ;goal node Return (Abs($goal_coord[1] - $node_coord[1]) + Abs($goal_coord[2] - $node_coord[2])) * $estimate EndFunc ;==>_MD ;============================================================================= ; Calculates the Euclidean distance between two nodes ; MD = SquareRoot ( (G(x) - N(x))^2 + (G(y) - N(x))^2 ) ; Returns an integer ;============================================================================= Func _ED(ByRef $node, ByRef $goal) ;returns integer Local $node_coord = StringSplit($node[0], ",") ;current node Local $goal_coord = StringSplit($goal[0], ",") ;goal node Return Sqrt(($goal_coord[1] - $node_coord[1]) ^ 2 + ($goal_coord[2] - $node_coord[2]) ^ 2) * $estimate EndFunc ;==>_ED ;============================================================================= ; A * Searching Algorithm ; Keep searching nodes until the goal is found. ; Returns: Array if path found ; Returns: 0 if no path ;============================================================================= Func _FindPath(ByRef $map, $start_node, $goal_node) ;returns array of coords Local $openlist = _ArrayCreate("empty") ;start with empty open list Local $closedlist = _ArrayCreate("empty") ;start with empty closed list Local $current_node = $start_node ;set current node to start nodeF $closedList_Str &= $current_node[0] & "_" $openList_Str &= $current_node[0] & "_" ;MsgBox($MB_SYSTEMMODAL, "Title", $closedList_Str, 0) _AddAdjacents_Openlist($map, $openlist, $closedlist, $current_node, $goal_node) ;add all possible adjacents to openlist While 1 ;while goal is not in closed list, or open list is not empty If UBound($openlist) = 1 Then ExitLoop ;if open list is empty then no path found $current_node = _GetLowest_F_Cost_Node($openlist) ;pick node with lowest F cost $closedList_Str &= $current_node[0] & "_" If $current_node[0] = $goal_node[0] Then ExitLoop ;if current node is goal then path is found! Else _AddAdjacents_Openlist($map, $openlist, $closedlist, $current_node, $goal_node) ;add all possible adjacents to openlist EndIf WEnd If _IsInClosedList($goal_node[0]) = 0 Then ;if no goal found then return 0 Return 0 ; no path found Else Return _GetPath($map, $current_node, $start_node) ;return array of coords (x,y) in string format EndIf EndFunc ;==>_FindPath ;============================================================================= ; Returns node object with the lowest F cos t ; F = G + H ; Returns 0 with openlist is emtpy, there is no path ;============================================================================= Func _GetLowest_F_Cost_Node(ByRef $openlist) If UBound($openlist) > 1 Then ;If open list is not empty Local $obj = $openlist[1] ;Pop first item in the queue _ArrayDelete($openlist, 1) ;remove this node from openlist Return $obj ;return lowest F cost node EndIf Return 0 ;openlist is empty EndFunc ;==>_GetLowest_F_Cost_Node ;============================================================================= ; Start from goal node and traverse each parent node until starting node is ; reached. ; Each node will have a parent node (use this to get path bot will take) ; Returns: Array of coords, first index is starting location ;============================================================================= Func _GetPath(ByRef $data, ByRef $ending_node, ByRef $start_node) Local $path = _ArrayCreate($ending_node[0]) ;start from goal node Local $node_coord = StringSplit($path[0], ",") Local $x = $node_coord[1] Local $y = $node_coord[2] Local $start = $start_node[0] ;starting nodes coord Local $obj = $data[$x][$y] ;current node starting from the goal While $obj[1] <> $start ;keep adding until reached starting node _Add_List($path, $y & "," & $x) ;add the parent node to the list $obj = $data[$x][$y] ;get node from 2D data array $node_coord = StringSplit($obj[1], ",") If $node_coord[0] = 1 Then ExitLoop $x = $node_coord[1] $y = $node_coord[2] WEnd _ArrayDelete($path, 0) ;no need to starting node _ArrayReverse($path) ;flip array to make starting node at index 0 Return $path ;return path as array in "x,y" format for each item EndFunc ;==>_GetPath ;============================================================================= ; Adds adjacent nodes to the open list if: ; 1. Node is not a barrier "x" ; 2. Node is not in open list ; 3. Node is not in closed list ; Set newly added node's parent to the current node and update its F,G, and H ; Only need to check North, South, East and West nodes. ;============================================================================= Func _AddAdjacents_Openlist(ByRef $data, ByRef $openlist, ByRef $closedlist, ByRef $node, ByRef $goal) Local $current_coord = StringSplit($node[0], ",") Local $x = $current_coord[1] Local $y = $current_coord[2] Local $h ; heuristic Local $north = 0 Local $south = 0 Local $east = 0 Local $west = 0 Local $obj = $data[$x][$y - 1] If $obj[5] <> "x" And _ ;north Not _IsInAnyList($obj[0]) Then ;If not in closed list or openlist and is not a barrier If $heuristic = 1 Then $h = _MD($obj, $goal) Else $h = _ED($obj, $goal) EndIf $obj[1] = $node[0] ;set nodes parent to last node $obj[3] = $node[3] + $obj[3] ;set g score (current node's G score + adjacent node's G score) $obj[2] = $obj[3] + $h ;set f = g + h score $data[$x][$y - 1] = $obj $north = 1 $openList_Str &= $obj[0] & "_" _Insert_PQ($openlist, $obj) EndIf $obj = $data[$x][$y + 1] If $obj[5] <> "x" And _ ;south Not _IsInAnyList($obj[0]) Then If $heuristic = 1 Then $h = _MD($obj, $goal) Else $h = _ED($obj, $goal) EndIf $obj[1] = $node[0] ;set nodes parent to last node $obj[3] = $node[3] + $obj[3] ;set g score (current node's G score + adjacent node's G score) $obj[2] = $obj[3] + $h ;set f = g + h score $data[$x][$y + 1] = $obj $south = 1 $openList_Str &= $obj[0] & "_" _Insert_PQ($openlist, $obj) EndIf $obj = $data[$x + 1][$y] If $obj[5] <> "x" And _ ;east Not _IsInAnyList($obj[0]) Then If $heuristic = 1 Then $h = _MD($obj, $goal) Else $h = _ED($obj, $goal) EndIf $obj[1] = $node[0] ;set nodes parent to last node $obj[3] = $node[3] + $obj[3] ;set g score (current node's G score + adjacent node's G score) $obj[2] = $obj[3] + $h ;set f = g + h score $data[$x + 1][$y] = $obj $east = 1 $openList_Str &= $obj[0] & "_" _Insert_PQ($openlist, $obj) EndIf $obj = $data[$x - 1][$y] If $obj[5] <> "x" And _ ;west Not _IsInAnyList($obj[0]) Then If $heuristic = 1 Then $h = _MD($obj, $goal) Else $h = _ED($obj, $goal) EndIf $obj[1] = $node[0] ;set nodes parent to last node $obj[3] = $node[3] + $obj[3] ;set g score (current node's G score + adjacent node's G score) $obj[2] = $obj[3] + $h ;set f = g + h score $data[$x - 1][$y] = $obj $west = 1 $openList_Str &= $obj[0] & "_" _Insert_PQ($openlist, $obj) EndIf ;diagonals moves If $allow_diagonals_Boolean Then ;if GUI checkbox is checked, then check other 4 directions If $north + $east = 2 Then ;Not allowed to cut around corners, not realistic $obj = $data[$x + 1][$y - 1] If $obj[5] <> "x" And _ ;northeast Not _IsInAnyList($obj[0]) Then If $heuristic = 1 Then $h = _MD($obj, $goal) Else $h = _ED($obj, $goal) EndIf $obj[1] = $node[0] ;set nodes parent to last node $obj[3] = $node[3] + (Sqrt(2) * $obj[3]) ;set g score (current node's G score + adjacent node's G score* Sqrt(2)) $obj[2] = $obj[3] + $h ;set f = g + h score $data[$x + 1][$y - 1] = $obj $openList_Str &= $obj[0] & "_" _Insert_PQ($openlist, $obj) EndIf EndIf If $north + $west = 2 Then $obj = $data[$x - 1][$y - 1] If $obj[5] <> "x" And _ ;north west Not _IsInAnyList($obj[0]) Then If $heuristic = 1 Then $h = _MD($obj, $goal) Else $h = _ED($obj, $goal) EndIf $obj[1] = $node[0] ;set nodes parent to last node $obj[3] = $node[3] + (Sqrt(2) * $obj[3]) ;set g score (current node's G score + adjacent node's G score* Sqrt(2)) $obj[2] = $obj[3] + $h ;set f = g + h score $data[$x - 1][$y - 1] = $obj $openList_Str &= $obj[0] & "_" _Insert_PQ($openlist, $obj) EndIf EndIf If $south + $east = 2 Then $obj = $data[$x + 1][$y + 1] If $obj[5] <> "x" And _ ;southeast Not _IsInAnyList($obj[0]) Then If $heuristic = 1 Then $h = _MD($obj, $goal) Else $h = _ED($obj, $goal) EndIf $obj[1] = $node[0] ;set nodes parent to last node $obj[3] = $node[3] + (Sqrt(2) * $obj[3]) ;set g score (current node's G score + adjacent node's G score) $obj[2] = $obj[3] + $h ;set f = g + h score $data[$x + 1][$y + 1] = $obj $openList_Str &= $obj[0] & "_" _Insert_PQ($openlist, $obj) EndIf EndIf If $south + $west = 2 Then $obj = $data[$x - 1][$y + 1] If $obj[5] <> "x" And _ ;southwest Not _IsInAnyList($obj[0]) Then If $heuristic = 1 Then $h = _MD($obj, $goal) Else $h = _ED($obj, $goal) EndIf $obj[1] = $node[0] ;set nodes parent to last node $obj[3] = $node[3] + (Sqrt(2) * $obj[3]) ;set g score (current node's G score + adjacent node's G score) $obj[2] = $obj[3] + $h ;set f = g + h score $data[$x - 1][$y + 1] = $obj $openList_Str &= $obj[0] & "_" _Insert_PQ($openlist, $obj) EndIf EndIf EndIf EndFunc ;==>_AddAdjacents_Openlist ;============================================================================= ; Returns true if node is in closed list ; Search the list backwards, its faster ;============================================================================= Func _IsInClosedList(ByRef $node) If StringRegExp($closedList_Str, "_" & $node & "_") Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsInClosedList ;============================================================================= ; Returns true if node is in open list ; Regular expressions are used rather than searching an array list for speed. ;============================================================================= Func _IsInAnyList(ByRef $node) If StringRegExp($openList_Str, "_" & $node & "_") Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsInAnyList ;============================================================================= ; Inserts object into openlist and preserves ascending order ; This way will result in a priority queue with the lowest F cost at ; position 1 in the openlist array. ;============================================================================= Func _Insert_PQ(ByRef $openlist, $node) Local $obj For $i = 1 To UBound($openlist) - 1 Local $obj = $openlist[$i] If $node[2] < $obj[2] Then _ArrayInsert($openlist, $i, $node) Return EndIf Next _Add_List($openlist, $node) EndFunc ;==>_Insert_PQ ;============================================================================= ; Adds nodes the a list ;============================================================================= Func _Add_List(ByRef $list, $node) ReDim $list[UBound($list) + 1] $list[UBound($list) - 1] = $node EndFunc ;==>_Add_List ;============================================================================ ; End of Algorithm ;============================================================================ Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func _MemoryWrite64struct($ivAddress, $ahHandle, ByRef $tStruct) If Not IsArray($ahHandle) Then SetError(1, 0, False) Return False EndIf ; Tạo biến để Windows báo cáo lại số lượng byte đã ghi thành công Local $vNumberOfBytesWritten = DllStructCreate("ulong_ptr lpNumberOfBytesWritten") ; Gọi API Windows ghi ĐÚNG kích thước và ĐÚNG con trỏ của Struct bạn truyền vào Local $ahCall = DllCall($ahHandle[0], "bool", "WriteProcessMemory", _ "handle", $ahHandle[1], _ "ptr", $ivAddress, _ "ptr", DllStructGetPtr($tStruct), _ "ulong_ptr", DllStructGetSize($tStruct), _ "ptr", DllStructGetPtr($vNumberOfBytesWritten)) If @error Then SetError(2, 0, False) Return False EndIf ; Trả về True nếu số byte ghi được bằng đúng kích thước của cái Struct Return ($ahCall[0] And (DllStructGetData($vNumberOfBytesWritten, "lpNumberOfBytesWritten") = DllStructGetSize($tStruct))) EndFunc ; Local $stream = WinCapture_cs01($control01,3,$game_cap_x02,$game_cap_y02,$view_screen01,$game_cap_x01,$game_cap_y01,$g_x,$g_y) ; chay only show gui image Func WinCapture_cs05($hWnd,$nFlags, $iWidth = -1, $iHeight = -1, $del_hBMP=0, $x0=0, $y0=0, $g_x0=0, $g_y0=0,$copy_view01=1,$image_array0="IMAGE_ARRAY" ) ; chay only show gui image ;Local $hTimer = TimerInit() ;$copy_view01 = 1 $gdi_plus01 = 1 _GDIPlus_Startup() ; Lay image game vao memory Local $iH, $iW, $hDDC, $hCDC, $hBMP ; If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) ; If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) ; $iWidth5 = _WinAPI_GetWindowWidth($hWnd) ; $iHeight5 = _WinAPI_GetWindowHeight($hWnd) ;MsgBox("","check","$iWidth = "&$iWidth&" $iHeight = "&$iHeight&" $iWidth5 = "&$iWidth5&" $iHeight5 = "&$iHeight5,0) $iIW = Int($iWidth/$scale0) $iIH = Int($iHeight/$scale0) ; > Dim $aArray[$height][$width] $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) _WinAPI_DeleteObject($hBMP) ; xoa ko hien thi hinh gui nhung van co trong memory DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", $nFlags) ; bit map lockbits nhanh hon Local $BMP = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ;_WinAPI_DeleteObject($hClone01) ; _GDIPlus_BitmapDispose($hClone01) If $gdi_plus01=1 Then ;_WinAPI_CreateColorAdjustment ( [$iFlags = 0 [, $iIlluminant = 0 [, $iGammaR = 10000 [, $iGammaG = 10000 [, $iGammaB = 10000 [, $iBlack = 0 [, $iWhite = 10000 [, $iContrast = 0 [, $iBrightness = 0 [, $iColorfulness = 0 [, $iTint = 0]]]]]]]]]]] ) ;Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 100, 0, 0, 0, 0, 0] ;set Tint to 100 ;Global $g_aDefault[11] = [10000, 10000, 10000, 1540, 6000, 100, -39, 0, 0, 0, 0] ;set Tint to 100 ;Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 50, -25, 0, 0, 0, 0] ;set Tint to 100 ;$g_aDefault[9] = BitOR($g_aDefault[9], $CA_NEGATIVE) ; invert color ;$g_aDefault[9] = BitAND($g_aDefault[9], BitNOT($CA_NEGATIVE)) $g_aDefault[9] = BitOR($g_aDefault[9], $CA_LOG_FILTER) ; sang hon ; $g_aDefault[9] = BitAND($g_aDefault[9], BitNOT($CA_LOG_FILTER)) ; $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hObj) $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($BMP) ; $hSrc=_ScreenCapture_Capture("",0,0, 500,300) _GDIPlus_BitmapDispose($BMP) ; bi loi tang memory size Local $tAdjust = 0 If IsArray($g_aDefault) Then $tAdjust = _WinAPI_CreateColorAdjustment($g_aDefault[9], $g_aDefault[10], $g_aDefault[0], $g_aDefault[1], $g_aDefault[2], $g_aDefault[3], $g_aDefault[4], $g_aDefault[5], $g_aDefault[6], $g_aDefault[7], $g_aDefault[8]) EndIf $hBitmap = _WinAPI_AdjustBitmap($hSrc, -1, -1, $HALFTONE, $tAdjust) If @error Then Return 0 EndIf $g_hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) ; xai $scale0 $g_hBitmap02 = _GDIPlus_ImageResize($g_hBitmap, $iIW, $iIH) ;resize image EndIf ;------------------------------------------------------------------------------------------- If $copy_view01 = 1 Then ; clone handle hinh anh $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle ;$g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics) ;$g_hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ;_GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_1.jpg") ; _WinAPI_DeleteObject($hBitmap) ko save duoc _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $g_hBitmap02, 0, 0) ;draw bitmap to backbuffer _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap02, 0, 0, $iIW, $iIH) ;copy drawn bitmap to graphics handle (GUI) _GDIPlus_GraphicsDispose($g_hGfxCtxt) _GDIPlus_GraphicsDispose($g_hGraphics) ;_WinAPI_DeleteObject($g_hBitmap) ;_WinAPI_DeleteObject($BMP) EndIf ; _GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_A_STAR_ALL01.jpg") ; test save bitmap ; _GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_A_STAR_ALL02.jpg") ; test save bitmap ;_GDIPlus_ImageSaveToFile($hClone01, "c:\acc\"&$file0) ; test save bitmap If $gdi_plus01=1 Then _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hSrc) EndIf ; trancexx ;Local $aArray[$iHeight][$iWidth] ;Local $tBitmapData = _GDIPlus_BitmapLockBits($pBitmap, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;Local $tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", DllStructGetData($tBitmapData, "Scan0")) ;For $iX = 0 To $iWidth - 1 ; For $iY = 0 To $iHeight - 1 ; $aArray[$iY][$iX] = BitAND(DllStructGetData($tPixel, 1, $iY * $iWidth + $iX + 1), 0xFFFFFF) ; Next ;Next ;_GDIPlus_BitmapUnlockBits($pBitmap, $tBitmapData) ; end trance ; Local $tBitmapData = _GDIPlus_BitmapLockBits($BMP, $x0, $y0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;locks a portion of a bitmap for reading and writing. More infor at http://msdn.microsoft.com/en-us/library/windows/desktop/ms536298(v=vs.85).aspx ; Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap ; Local $iSearchPixel = Int(0xFF000080), $iReplaceColor = 0x00000000 ;color format 0xAARRGGBB ; Local $tPixel = DllStructCreate("int[" & $iWidth * $iHeight & "];", $iScan0) ; > int dec ;Local $tPixel = DllStructCreate("byte[" & $iHeight * $iWidth* 4 & "]", $iScan0) ; > array bytes flip ; IMAGE > ARRAY If $image_array0="IMAGE_ARRAY" Then Local $v_Buffer EndIf ; END IMAGE > ARRAY ; Locks a portion of a bitmap for reading or writing Local $tBitmapData = _GDIPlus_BitmapLockBits($g_hBitmap02, $x0, $y0, $iIW, $iIH, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () Local $width = DllStructGetData($tBitmapData, "width") Local $height = DllStructGetData($tBitmapData, "height") Local $stride = DllStructGetData($tBitmapData, "stride") Local $format = DllStructGetData($tBitmapData, "format") Local $Scan0 = DllStructGetData($tBitmapData, "Scan0") Local $tPixel = DllStructCreate("byte[" & ($iIH) * ($iIW) * 4 & "]", $Scan0) ; Create DLL structure for all pixels Local $iPixel, $iRowOffset ; end Lay image game vao memory Local $aArray[$iIH][$iIW] $mini_min02x = $mini_min01x $mini_min02y = $mini_min01y If $mini_min01x > $iIW - 1 Then $mini_min02x = $iIW - 1 If $mini_min01y > $iIH - 1 Then $mini_min02y = $iIH - 1 ;MsgBox($MB_SYSTEMMODAL, "Title", "$width="&$width& " $height="&$height& " $stride="&$stride& " $format="&$format&" $Scan0="&$Scan0&" $tPixel="&$tPixel , 0) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsClear($hGraphic) $view_gdi01on = 0 If _IsChecked( ($button_auto03[4])[7-1] ) = True Then $view_gdi01on = 1 Dim $data_map[$rows_scale][$col_scale] $map_min01x = $map_c01x $map_max01x = $map_c01x $map_min01y = $map_c01y $map_max01y = $map_c01y $iY_max = UBound($aArray, $UBOUND_ROWS)-1 $iX_max = UBound($aArray, $UBOUND_COLUMNS)-1 ;MsgBox($MB_SYSTEMMODAL, "Title", "$col_scale+1="&$col_scale+1 & "$rows_scale+1="&$rows_scale+1&" $iX_max="&$iX_max & "$iY_max="&$iY_max , 0) $MAP_LEFT_UP = 0 $MAP_RIGHT_UP = 0 $MAP_LEFT_DOWN = 0 $MAP_RIGHT_DOWN = 0 $MAP_CENTER_MAX = 5 ;MsgBox($MB_SYSTEMMODAL, "Title", "$width="&$width& " $height="&$height& " $stride="&$stride& " $format="&$format&" $Scan0="&$Scan0&" $tPixel="&$tPixel , 0) If $width <> 0 and $height <> 0 and $Scan0 <> 0 and $hWnd <> 0 Then ; da exit game ------------------------------------------------------------------- ; ========================================================================= ; SỬ DỤNG CHUNG HOẶC KHỞI TẠO LẠI STRUCT LỚN (NẾU ĐOẠN NÀY CHẠY ĐỘC LẬP) ; ========================================================================= Local $iStrideDwords = Int($stride / 4) Local $iTotalDwords = Int($iStrideDwords * ($iY_max + 1)) Local $v_LargeBuffer = DllStructCreate("dword[" & $iTotalDwords & "]", $Scan0) Local $iRawColor = 0 ; --- 1. CHECK GÓC TRÊN TRÁI (LEFT UP) --- For $j = $mini_min01y To $MAP_CENTER_MAX Local $iCurrentRowOffset = $j * $iStrideDwords For $i = $mini_min01x To $MAP_CENTER_MAX ; CHÊU TRÒ SIÊU TỐC: Đọc giá trị Dword thô (Integer), không qua hàm Hex() nữa $iRawColor = DllStructGetData($v_LargeBuffer, 1, $iCurrentRowOffset + $i + 1) ; Đổi màu thô sang chuỗi Hex chỉ duy nhất khi cần truyền vào hàm TestTrans05 $aArray[$j][$i] = Hex($iRawColor, 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_LEFT_UP = 1 ExitLoop ; TRẢ LẠI NGUYÊN BẢN: Chỉ thoát vòng lặp $i, tiếp tục quét dòng $j tiếp theo EndIf Next Next ; --- 2. CHECK GÓC TRÊN PHẢI (RIGHT UP) --- For $j = $mini_min01y To $MAP_CENTER_MAX Local $iCurrentRowOffset = $j * $iStrideDwords For $i = $mini_max01x - $MAP_CENTER_MAX To $iX_max $iRawColor = DllStructGetData($v_LargeBuffer, 1, $iCurrentRowOffset + $i + 1) $aArray[$j][$i] = Hex($iRawColor, 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_RIGHT_UP = 1 ExitLoop EndIf Next Next ; --- 3. CHECK GÓC DƯỚI TRÁI (LEFT DOWN) --- For $j = $mini_max01y - $MAP_CENTER_MAX To $iY_max Local $iCurrentRowOffset = $j * $iStrideDwords For $i = $mini_min01x To $MAP_CENTER_MAX $iRawColor = DllStructGetData($v_LargeBuffer, 1, $iCurrentRowOffset + $i + 1) $aArray[$j][$i] = Hex($iRawColor, 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_LEFT_DOWN = 1 ExitLoop EndIf Next Next ; --- 4. CHECK GÓC DƯỚI PHẢI (RIGHT DOWN) --- For $j = $mini_max01y - $MAP_CENTER_MAX To $iY_max Local $iCurrentRowOffset = $j * $iStrideDwords For $i = $mini_max01x - $MAP_CENTER_MAX To $iX_max $iRawColor = DllStructGetData($v_LargeBuffer, 1, $iCurrentRowOffset + $i + 1) $aArray[$j][$i] = Hex($iRawColor, 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_RIGHT_DOWN = 1 ExitLoop EndIf Next Next If $MAP_LEFT_UP = 1 and $MAP_RIGHT_UP = 1 and $MAP_LEFT_DOWN = 1 and $MAP_RIGHT_DOWN = 1 Then ; CHECK FALSE LARGE MAP $map_min01x = $mini_min01x $map_max01x = $mini_max01x $map_min01y = $mini_min01y $map_max01y = $mini_max01y GUICtrlSetData($button_submit02, " N="&$loopacc&" _check_map03="&"FALSE LARGE MAP") Else GUICtrlSetData($button_submit02, " N="&$loopacc&" _check_map03="&"TRUE LARGE MAP") ; MsgBox($MB_SYSTEMMODAL, "Title", "$mini_min01x="&$mini_min01x& " $mini_max01x="&$mini_max01x& " $mini_min01y="&$mini_min01y& " $mini_max01y="&$mini_max01y&" $iY_max="&$iY_max&" $iX_max="&$iX_max , 0) ;_ArrayDisplay($data_map) $switch_map = 2 $fog_green01on = 1 $mini_array = 10+1 Dim $a_fog_green02xy[$mini_array][2] $mini_c01x = $mini_min01x + $start_cols01 $mini_c01y = $mini_min01y + $start_rows01 $mini_max = 10 $a_fog_green02num = 1 $a_fog_green02min = 20 $a_fog_green02max = 25 ; Tạo khuôn chứa map 50x34 (ví dụ), giá trị mặc định là 0 (đường trống) Local $total_bytes = $col_bfs01 * $row_bfs01 Local $tMapBuffer = DllStructCreate("char[" & $total_bytes & "]") ; Mặc định điền 0 vào toàn bộ khuôn DllStructSetData($tMapBuffer, 1, 0) ; $time_start01 = TimerInit() ; ========================================================================= ; BƯỚC SIÊU TỐI ƯU 1: TẠO 1 STRUCT DUY NHẤT BAO PHỦ TOÀN BỘ VÙNG SCAN ĐỒ HỌA ; ========================================================================= ; Tính toán tổng số dwords của vùng nhớ và hệ số dịch dòng trước khi vào vòng lặp Local $iTotalDwords = Int(($stride / 4) * ($mini_max01y + 1)) Local $v_LargeBuffer = DllStructCreate("dword[" & $iTotalDwords & "]", $Scan0) Local $iStrideDwords = Int($stride / 4) For $j = $mini_min02y To $mini_max01y ; Tính sẵn vị trí offset dòng trong mảng dword để triệt tiêu phép nhân ở vòng lặp trong Local $iCurrentRowOffset = $j * $iStrideDwords ; Tính toán sẵn $y_idx cho vòng lặp hàng hiện tại Local $y_idx = $j - $mini_min01y For $i = $mini_min02x To $mini_max01x - 10 ; Đọc thẳng màu pixel từ mảng dword bằng chỉ số Index (Mảng trong struct bắt đầu từ 1 nên + 1) Local $iPixelIndex = $iCurrentRowOffset + $i + 1 $aArray[$j][$i] = Hex(DllStructGetData($v_LargeBuffer, 1, $iPixelIndex), 6) If $switch_map = 2 Then ; _check_map03 $a_fog_green01dis = 0 If $i > $mini_c01x - $mini_max And $i < $mini_c01x + $mini_max And $j > $mini_c01y - $mini_max And $mini_c01y < $mini_c01y + $mini_max Then $a_fog_green01dis = 1 ; TÍNH OFFSET CHUẨN ĐỂ GHI VÀO KHUÔN (Giữ nguyên thuật toán của bạn) Local $x_idx = $i - $mini_min01x Local $offset = ($x_idx * $row_bfs01) + $y_idx + 1 If $aArray[$j][$i] = "FFFFFF" Then $data_map[$y_idx][$x_idx] = "x" DllStructSetData($tMapBuffer, 1, 120, $offset) ; Ghi 'x' (120) vào khuôn ElseIf $a_fog_green02num < $mini_array - 1 And $a_fog_green02min > $a_fog_green02max And $a_fog_green01dis = 0 And $aArray[$j][$i] = "00FF00" Then $count_green01 = 1 ; Đọc mảng xung quanh từ mảng đồ họa đã tối ưu If $aArray[$j + 1][$i + 1] = "00FF00" Then $count_green01 += 1 If $aArray[$j + 1][$i + 0] = "00FF00" Then $count_green01 += 1 If $aArray[$j + 0][$i + 1] = "00FF00" Then $count_green01 += 1 If $count_green01 > 1 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $i * $title_size01x - 270, $j * $title_size01y + 210, $tileWidth, $tileHeight, $Brush_green) GUICtrlSetData($button_submit02, " N=" & $loopacc0 & " [$a_fog_green02num]=" & $a_fog_green02num & " $i=" & $i & " $j=" & $j) EndIf $a_fog_green02xy[$a_fog_green02num][0] = $i $a_fog_green02xy[$a_fog_green02num][1] = $j $a_fog_green02num += 1 $a_fog_green02min = 0 EndIf Else If $view_gdi01on = 1 And $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $i * $title_size01x - 270, $j * $title_size01y + 210, $tileWidth, $tileHeight, $Brush_gray) $data_map[$y_idx][$x_idx] = "0" DllStructSetData($tMapBuffer, 1, 48, $offset) ; Ghi '0' (48) vào khuôn EndIf $a_fog_green02min += 1 EndIf ; end _check_map03 Next Next ; Bạn đã có $tMapBuffer hoàn chỉnh, giờ chỉ cần ném nó vào ASM _MemoryWrite64struct($mapBase, $procHwnd_autoit01, $tMapBuffer) ; $time_stop01 = int(TimerDiff($time_start01)) ;ToolTip("N="&$loopacc&" $time_stop01="&$time_stop01, 0, 0) ;EndIf ;_ArrayDisplay($aArray) ; END IMAGE > ARRAY ;_ArrayDisplay($a_fog_green02xy) ; WALL MAP For $y_wall = $mini_min01y to $mini_max01y+0 $data_map[$y_wall-$mini_min01y][$mini_min01x-$mini_min01x] = "x" $data_map[$y_wall-$mini_min01y][$mini_max01x-$mini_min01x] = "x" $data_map[$y_wall-$mini_min01y][$mini_max01x-$mini_min01x-9] = "x" If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $mini_min01x*$title_size01x-270, $y_wall*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $mini_max01x*$title_size01x-270, $y_wall*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) ; Ghi trực tiếp vào RAM basemap (Mã ASCII 120 = 'x') _MemoryWrite64($mapBase + (($mini_min01x - $mini_min01x) * $row_bfs01) + ($y_wall - $mini_min01y), $procHwnd_autoit01, Ptr(120), 'byte[1]') _MemoryWrite64($mapBase + (($mini_max01x - $mini_min01x) * $row_bfs01) + ($y_wall - $mini_min01y), $procHwnd_autoit01, Ptr(120), 'byte[1]') _MemoryWrite64($mapBase + ((($mini_max01x - $mini_min01x - 9)) * $row_bfs01) + ($y_wall - $mini_min01y), $procHwnd_autoit01, Ptr(120), 'byte[1]') Next For $x_wall = $mini_min01x to $mini_max01x+0 $data_map[$mini_min01y-$mini_min01y][$x_wall-$mini_min01x] = "x" $data_map[$mini_max01y-$mini_min01y][$x_wall-$mini_min01x] = "x" If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x_wall*$title_size01x-270 , ($mini_min01y-$mini_min01y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x_wall*$title_size01x-270 , ($mini_max01y+$mini_min01y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) ; Ghi trực tiếp vào RAM basemap (Mã ASCII 120 = 'x') _MemoryWrite64($mapBase + (($x_wall - $mini_min01x) * $row_bfs01) + ($mini_min01y - $mini_min01y), $procHwnd_autoit01, Ptr(120), 'byte[1]') _MemoryWrite64($mapBase + (($x_wall - $mini_min01x) * $row_bfs01) + ($mini_max01y - $mini_min01y), $procHwnd_autoit01, Ptr(120), 'byte[1]') Next For $lp_y = $start_rows01-3 to $start_rows01+3 For $lp_x = $start_cols01-3 to $start_cols01+3 ; 1. Xử lý mảng ảo và vẽ giao diện hiển thị của bạn $data_map[$lp_y][$lp_x] = "0" _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$lp_x)*$title_size01x-270 , ($mini_max01y-$lp_y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_gray) ; 2. Tính toán tịnh tiến đưa về chỉ số gốc (0,0) dựa trên mốc tọa độ nhỏ nhất của map Local $y_idx = $lp_y - $mini_min01y Local $x_idx = $lp_x - $mini_min01x ; 3. Tính toán offset tuyến tính trong RAM (Bỏ "+ 1" vì ghi thẳng vào địa chỉ nhớ) Local $offset = ($x_idx * $row_bfs01) + $y_idx ; 4. Ghi đè ký tự '0' (mã ASCII là 48) trực tiếp vào RAM game để xóa ô kẹt _MemoryWrite64($mapBase + $offset, $procHwnd_autoit01, Ptr(48), 'byte[1]') Next Next If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+0)*$title_size01x-270 , ($mini_max01y-$start_rows01+1)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+1)*$title_size01x-270 , ($mini_max01y-$start_rows01+0)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+0)*$title_size01x-270 , ($mini_max01y-$start_rows01+0)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+1)*$title_size01x-270 , ($mini_max01y-$start_rows01+1)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) $data_map[$start_rows01][$start_cols01] = "s" Global $start_red = ($start_rows01 - 0) * $cols + ($start_rows01 - 0) $data = $data_map ;_ArrayDisplay($data_map) ;MsgBox($MB_SYSTEMMODAL, "Title", "x="&UBound($stream02[12], $UBOUND_COLUMNS)-0-40 & "y="&UBound($stream02[12], $UBOUND_ROWS)-0-24 , 0) ; END WALL MAP EndIf ; END CHECK FALSE LARGE MAP $a_map_min00x[$loopacc] = $mini_min01x $a_map_max00x[$loopacc] = $mini_max01x $a_map_min00y[$loopacc] = $mini_min01y $a_map_max00y[$loopacc] = $mini_max01y GUICtrlSetData($button_submit02, " N="&$loopacc&" $map_min01x="&$map_min01x&" $map_max01x="&$map_max01x&" $map_min01y="&$map_min01y&" $map_max01y="&$map_max01y) EndIf ; end da exit game ------------------------------------------------------------------- ;_WinAPI_DeleteDC($hCDC) ;$vtmem_autoitX = _MemVirtualAlloc(0x0, 0x2B0000, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; khoi tao 1 lan duy nhat khong se bi error memory ;$tCodeBuffer = ASM64_opcode01vtmem() ; khoi tao 1 lan duy nhat khong se bi error memory ;$vtmem_autoit_screenX = $vtmem_autoitX+0x100000 ; 0x1000 ;_WinAPI_MoveMemory($vtmem_autoit_screenX, $tPixel, ($height/$scale0) * ($width/$scale0) * 4) ; đã bỏ không dùng nữa REMOVE ;ClipPut($vtmem_autoit_screenX&@CRLF&$iScan0) ;MsgBox("","check","$iScan0 = "&$iScan0&" $tBitmapData = "&$tBitmapData,0) ;$AllPixels = DllStructGetData($v_BufferA, 1) ;ConsoleWrite("$AllPixels, raw data, first 9 colours = " & StringRegExpReplace($AllPixels, "(.{98})(.*)", "\1") & @CRLF) ;#CS ;$Stride = DllStructGetData($tBitmapData, "Stride") ;ConsoleWrite("Bitmap Stride: " & $Stride & @CRLF) ;$Width = DllStructGetData($tBitmapData, "Width") ;ConsoleWrite("Bitmap Width: " & $Width & @CRLF) ;$Height = DllStructGetData($tBitmapData, "Height") ;ConsoleWrite("Bitmap Height: " & $Height & @CRLF) ;$PixelFormat = DllStructGetData($tBitmapData, "PixelFormat") ;ConsoleWrite("Bitmap PixelFormat: " & $PixelFormat & @CRLF) ;$Scan0 = DllStructGetData($tBitmapData, "Scan0") ;ConsoleWrite("Bitmap Scan0: " & $Scan0 & @CRLF) ;$pPixels = $Scan0 ;If $pPixels <> 0x000000 Then ;$x0 = 670 ;$x1 = 689 ;$y0 = 56 ;$y1 = 75 ;For $row = $y0 To $y1 - 1 ; For $col = $x0 To $x1 - 1 ; $pixel = DllStructCreate("dword", $Scan0 + $row * $Stride + $col*4) ; $h_color0 = Hex(DllStructGetData($pixel, 1),8) ; ConsoleWrite(" x ="&$col&" y = "&$row&" color_hex = "&$h_color0 & @CRLF) ; Next ; ConsoleWrite("-------" & @CRLF) ;Next ;EndIf ;#CE ;Sleep(50000) ; change color = memory ; change color = StringRegExpReplace($hImage, $iColSrch, $iColNew, $iCount) $change_color01 = 0 $change_color02 = 0 $iCount = 0 If $change_color01 <> 0 or $change_color02 <> 0 Then $color_hex01 = DllStructGetData($tPixel, 1 ) ;get pixel color array bytes $sREResult1 = StringRegExpReplace(StringTrimLeft($color_hex01, 2), "(.{8})", "\1 ") ; ConsoleWrite("$sREResult1 first 9 colours = " & StringRegExpReplace($sREResult1, "(.{81})(.*)", "\1") & @CRLF) EndIf If $change_color01 = 1 Then $iColSrch = "(?i)([0-3][0-9A-F]{5}FF)" ; Change near black to black $iColNew = "FFFFFFFF" ;If StringInStr($iColNew, "0x") > 0 Then $iColNew = StringReplace($iColNew, "0x", ""); Remove "0x" not needed ; StringRegExpReplace performed and white spaces removed $sResult = StringStripWS(StringRegExpReplace($sREResult1, $iColSrch, $iColNew, $iCount), 8) EndIf If $change_color02 = 1 Then $iColSrch = "(?i)([0-3][0-9A-F]{5}FF)" ; Change near black to black FFFFFFFF $iColNew = "55FF55FF" ;If StringInStr($iColNew, "0x") > 0 Then $iColNew = StringReplace($iColNew, "0x", ""); Remove "0x" not needed ; StringRegExpReplace performed and white spaces removed If $change_color01 = 1 Then $sResult = StringStripWS(StringRegExpReplace($sResult, $iColSrch, $iColNew, $iCount), 8) If $change_color01 = 0 Then $sResult = StringStripWS(StringRegExpReplace($sREResult1, $iColSrch, $iColNew, $iCount), 8) EndIf If $change_color01 <> 0 and $change_color02 <> 0 Then ; Replace "0x" prefix and set modified data back to DLL structure, $v_BufferA=$tPixel DllStructSetData($tPixel, 1, "0x" & $sResult) EndIf _GDIPlus_BitmapUnlockBits($g_hBitmap02, $tBitmapData) ; xoa truoc Dispose _GDIPlus_BitmapDispose($g_hBitmap02) ; bi loi tang memory size ;_GDIPlus_ImageDispose($g_hBitmap02) $wincapture00on = 1 If $width = 0 and $height = 0 and $Scan0 = 0 Then $a_fog_green02xy = "" $wincapture00on = 0 ; done = 1 error = 0 ElseIf $hWnd = "" Then $a_fog_green02xy = "" $wincapture00on = 0 ; done = 1 error = 0 EndIf ;_GDIPlus_BitmapUnlockBits($g_hBitmap, $tBitmapData) ; xoa truoc Dispose ;_GDIPlus_BitmapDispose($g_hBitmap) ; bi loi tang memory size ;FileDelete("c:\acc\0_MEO_D01_2.jpg") ;_GDIPlus_ImageSaveToFile($BMP, "c:\acc\0_MEO_D01_2.jpg") ; _WinAPI_DeleteObject($hBitmap) ko save duoc ; end change color = StringRegExpReplace($hImage, $iColSrch, $iColNew, $iCount) ;ClipGet($iScan0) ;MsgBox(0, "Time Elapsed: " & $tPixel, $iScan0) ; --- Đoạn code chèn vào cuối hàm WinCapture_cs03 --- ; Giả định $data_map là mảng 2 chiều chứa thông tin map ; Local $rows = UBound($data_map, 1) ; Local $cols = UBound($data_map, 2) ;Local $tMapData = DllStructCreate("byte[" & ($rows * $cols) & "]") ; Đổi "byte" thành "char" (char trong AutoIt là 1 byte, nhận giá trị 0-255) ; Local $tMapData = DllStructCreate("char[" & ($rows * $cols) & "]") ; For $c = 0 To $cols - 1 ; For $r = 0 To $rows - 1 ; ; Chuyển ký tự 'x' (tường) thành 1, '0' (trống) thành 0 ; Local $val = ($data_map[$c][$r] = "x" ? 120 : 0) ; DllStructSetData($tMapData, 1, $val, ($r * $cols) + $c + 1) ; Next ; Next ; Gọi hàm ghi memory của bạn với địa chỉ $mapBase ; Lưu ý: Đảm bảo $mapBase đã được tính toán đúng địa chỉ trước đó ; _MemoryWrite64struct($mapBase, $procHwnd_autoit01, $tMapData) ;ClipPut($mapBase) ; Giải phóng bộ nhớ tạm ; $tMapData = 0 Local $stream_var[18] = [$hBMP, $Scan0, $tPixel, $g_hBitmap, $tBitmapData, $hWnd, $hDDC, $hCDC, $iWidth, $iHeight, $g_x0, $g_y0, $a_fog_green02xy,$g_hBitmap02,$wincapture00on &@CRLF& _ ""] ;$x01 = 555 ;$y01 = 394 ;$iRowOffset = $y01 * $iWidth+1 ; $iRowOffset = $iY * $iWidth + 1 ;$acolor01 = Hex(DllStructGetData($stream_var[2], 1, $iRowOffset + $x01),6) ;get pixel color ;MsgBox("","check","01 = "&$acolor01&" 02 = "&$acolor01,0) ; Local $stream_var[0] = $hBMP ; Local $stream_var[1] = $iScan0 ; Local $stream_var[2] = $tPixel ; Local $stream_var[3] = $BMP > $g_hBitmap ; Local $stream_var[4] = $tBitmapData ; Local $stream_var[5] = $WinHandle ; Local $stream_var[6] = $hDDC ; Local $stream_var[7] = $hCDC ; Local $stream_var[8] = $iWidth ; Local $stream_var[9] = $iHeight ; Local $stream_var[10] = $g_x0 ; Local $stream_var[11] = $g_y0 ; Local $stream_var[12] = $aArray ; IMGAGE > ARRAY > $a_fog_green02xy ; Local $stream_var[13] = $g_hBitmap02 ; Local $stream_var[14] = $wincapture00on = 0 ; done = 1 error = 0 ;MsgBox("","check cs03","$tBitmapData = "&$tBitmapData&" $g_hBitmap02 = "&$g_hBitmap02,0) Return $stream_var EndFunc ;==>_WinCapture01 ; Local $stream = WinCapture_cs01($control01,3,$game_cap_x02,$game_cap_y02,$view_screen01,$game_cap_x01,$game_cap_y01,$g_x,$g_y) ; chay only show gui image Func WinCapture_cs04($hWnd,$nFlags, $iWidth = -1, $iHeight = -1, $del_hBMP=0, $x0=0, $y0=0, $g_x0=0, $g_y0=0,$copy_view01=1,$image_array0="IMAGE_ARRAY" ) ; chay only show gui image ;Local $hTimer = TimerInit() ;$copy_view01 = 1 $gdi_plus01 = 1 _GDIPlus_Startup() ; Lay image game vao memory Local $iH, $iW, $hDDC, $hCDC, $hBMP ; If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) ; If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) ; $iWidth5 = _WinAPI_GetWindowWidth($hWnd) ; $iHeight5 = _WinAPI_GetWindowHeight($hWnd) ;MsgBox("","check","$iWidth = "&$iWidth&" $iHeight = "&$iHeight&" $iWidth5 = "&$iWidth5&" $iHeight5 = "&$iHeight5,0) $iIW = Int($iWidth/$scale0) $iIH = Int($iHeight/$scale0) ; > Dim $aArray[$height][$width] $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) _WinAPI_DeleteObject($hBMP) ; xoa ko hien thi hinh gui nhung van co trong memory DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", $nFlags) ; bit map lockbits nhanh hon Local $BMP = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ;_WinAPI_DeleteObject($hClone01) ; _GDIPlus_BitmapDispose($hClone01) If $gdi_plus01=1 Then ;_WinAPI_CreateColorAdjustment ( [$iFlags = 0 [, $iIlluminant = 0 [, $iGammaR = 10000 [, $iGammaG = 10000 [, $iGammaB = 10000 [, $iBlack = 0 [, $iWhite = 10000 [, $iContrast = 0 [, $iBrightness = 0 [, $iColorfulness = 0 [, $iTint = 0]]]]]]]]]]] ) ;Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 100, 0, 0, 0, 0, 0] ;set Tint to 100 ;Global $g_aDefault[11] = [10000, 10000, 10000, 1540, 6000, 100, -39, 0, 0, 0, 0] ;set Tint to 100 ;Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 50, -25, 0, 0, 0, 0] ;set Tint to 100 ;$g_aDefault[9] = BitOR($g_aDefault[9], $CA_NEGATIVE) ; invert color ;$g_aDefault[9] = BitAND($g_aDefault[9], BitNOT($CA_NEGATIVE)) $g_aDefault[9] = BitOR($g_aDefault[9], $CA_LOG_FILTER) ; sang hon ; $g_aDefault[9] = BitAND($g_aDefault[9], BitNOT($CA_LOG_FILTER)) ; $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hObj) $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($BMP) ; $hSrc=_ScreenCapture_Capture("",0,0, 500,300) _GDIPlus_BitmapDispose($BMP) ; bi loi tang memory size Local $tAdjust = 0 If IsArray($g_aDefault) Then $tAdjust = _WinAPI_CreateColorAdjustment($g_aDefault[9], $g_aDefault[10], $g_aDefault[0], $g_aDefault[1], $g_aDefault[2], $g_aDefault[3], $g_aDefault[4], $g_aDefault[5], $g_aDefault[6], $g_aDefault[7], $g_aDefault[8]) EndIf $hBitmap = _WinAPI_AdjustBitmap($hSrc, -1, -1, $HALFTONE, $tAdjust) If @error Then Return 0 EndIf $g_hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) ; xai $scale0 $g_hBitmap02 = _GDIPlus_ImageResize($g_hBitmap, $iIW, $iIH) ;resize image EndIf ;------------------------------------------------------------------------------------------- If $copy_view01 = 1 Then ; clone handle hinh anh $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle ;$g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics) ;$g_hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ;_GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_1.jpg") ; _WinAPI_DeleteObject($hBitmap) ko save duoc _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $g_hBitmap02, 0, 0) ;draw bitmap to backbuffer _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap02, 0, 0, $iIW, $iIH) ;copy drawn bitmap to graphics handle (GUI) _GDIPlus_GraphicsDispose($g_hGfxCtxt) _GDIPlus_GraphicsDispose($g_hGraphics) ;_WinAPI_DeleteObject($g_hBitmap) ;_WinAPI_DeleteObject($BMP) EndIf ; _GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_A_STAR_ALL01.jpg") ; test save bitmap ; _GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_A_STAR_ALL02.jpg") ; test save bitmap ;_GDIPlus_ImageSaveToFile($hClone01, "c:\acc\"&$file0) ; test save bitmap If $gdi_plus01=1 Then _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hSrc) EndIf ; trancexx ;Local $aArray[$iHeight][$iWidth] ;Local $tBitmapData = _GDIPlus_BitmapLockBits($pBitmap, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;Local $tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", DllStructGetData($tBitmapData, "Scan0")) ;For $iX = 0 To $iWidth - 1 ; For $iY = 0 To $iHeight - 1 ; $aArray[$iY][$iX] = BitAND(DllStructGetData($tPixel, 1, $iY * $iWidth + $iX + 1), 0xFFFFFF) ; Next ;Next ;_GDIPlus_BitmapUnlockBits($pBitmap, $tBitmapData) ; end trance ; Local $tBitmapData = _GDIPlus_BitmapLockBits($BMP, $x0, $y0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;locks a portion of a bitmap for reading and writing. More infor at http://msdn.microsoft.com/en-us/library/windows/desktop/ms536298(v=vs.85).aspx ; Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap ; Local $iSearchPixel = Int(0xFF000080), $iReplaceColor = 0x00000000 ;color format 0xAARRGGBB ; Local $tPixel = DllStructCreate("int[" & $iWidth * $iHeight & "];", $iScan0) ; > int dec ;Local $tPixel = DllStructCreate("byte[" & $iHeight * $iWidth* 4 & "]", $iScan0) ; > array bytes flip ; IMAGE > ARRAY If $image_array0="IMAGE_ARRAY" Then Local $v_Buffer EndIf ; END IMAGE > ARRAY ; Locks a portion of a bitmap for reading or writing Local $tBitmapData = _GDIPlus_BitmapLockBits($g_hBitmap02, $x0, $y0, $iIW, $iIH, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () Local $width = DllStructGetData($tBitmapData, "width") Local $height = DllStructGetData($tBitmapData, "height") Local $stride = DllStructGetData($tBitmapData, "stride") Local $format = DllStructGetData($tBitmapData, "format") Local $Scan0 = DllStructGetData($tBitmapData, "Scan0") Local $tPixel = DllStructCreate("byte[" & ($iIH) * ($iIW) * 4 & "]", $Scan0) ; Create DLL structure for all pixels Local $iPixel, $iRowOffset ; end Lay image game vao memory Local $aArray[$iIH][$iIW] $mini_min02x = $mini_min01x $mini_min02y = $mini_min01y If $mini_min01x > $iIW - 1 Then $mini_min02x = $iIW - 1 If $mini_min01y > $iIH - 1 Then $mini_min02y = $iIH - 1 ;MsgBox($MB_SYSTEMMODAL, "Title", "$width="&$width& " $height="&$height& " $stride="&$stride& " $format="&$format&" $Scan0="&$Scan0&" $tPixel="&$tPixel , 0) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsClear($hGraphic) $view_gdi01on = 0 If _IsChecked( ($button_auto03[4])[7-1] ) = True Then $view_gdi01on = 1 Dim $data_map[$rows_scale][$col_scale] $map_min01x = $map_c01x $map_max01x = $map_c01x $map_min01y = $map_c01y $map_max01y = $map_c01y $iY_max = UBound($aArray, $UBOUND_ROWS)-1 $iX_max = UBound($aArray, $UBOUND_COLUMNS)-1 ;MsgBox($MB_SYSTEMMODAL, "Title", "$col_scale+1="&$col_scale+1 & "$rows_scale+1="&$rows_scale+1&" $iX_max="&$iX_max & "$iY_max="&$iY_max , 0) $MAP_LEFT_UP = 0 $MAP_RIGHT_UP = 0 $MAP_LEFT_DOWN = 0 $MAP_RIGHT_DOWN = 0 $MAP_CENTER_MAX = 5 ;MsgBox($MB_SYSTEMMODAL, "Title", "$width="&$width& " $height="&$height& " $stride="&$stride& " $format="&$format&" $Scan0="&$Scan0&" $tPixel="&$tPixel , 0) If $width <> 0 and $height <> 0 and $Scan0 <> 0 and $hWnd <> 0 Then ; da exit game ------------------------------------------------------------------- For $j = $mini_min01y To $MAP_CENTER_MAX For $i = $mini_min01x To $MAP_CENTER_MAX $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_LEFT_UP = 1 ExitLoop EndIf Next Next For $j = $mini_min01y To $MAP_CENTER_MAX For $i = $mini_max01x-$MAP_CENTER_MAX To $iX_max $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_RIGHT_UP = 1 ExitLoop EndIf Next Next For $j = $mini_max01y-$MAP_CENTER_MAX To $iY_max For $i = $mini_min01x To $MAP_CENTER_MAX $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_LEFT_DOWN = 1 ExitLoop EndIf Next Next For $j = $mini_max01y-$MAP_CENTER_MAX To $iY_max For $i = $mini_max01x-$MAP_CENTER_MAX To $iX_max $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_RIGHT_DOWN = 1 ExitLoop EndIf Next Next If $MAP_LEFT_UP = 1 and $MAP_RIGHT_UP = 1 and $MAP_LEFT_DOWN = 1 and $MAP_RIGHT_DOWN = 1 Then ; CHECK FALSE LARGE MAP $map_min01x = $mini_min01x $map_max01x = $mini_max01x $map_min01y = $mini_min01y $map_max01y = $mini_max01y GUICtrlSetData($button_submit02, " N="&$loopacc&" _check_map03="&"FALSE LARGE MAP") Else GUICtrlSetData($button_submit02, " N="&$loopacc&" _check_map03="&"TRUE LARGE MAP") ; MsgBox($MB_SYSTEMMODAL, "Title", "$mini_min01x="&$mini_min01x& " $mini_max01x="&$mini_max01x& " $mini_min01y="&$mini_min01y& " $mini_max01y="&$mini_max01y&" $iY_max="&$iY_max&" $iX_max="&$iX_max , 0) ;_ArrayDisplay($data_map) $switch_map = 2 $fog_green01on = 1 $mini_array = 10+1 Dim $a_fog_green02xy[$mini_array][2] $mini_c01x = $mini_min01x + $start_cols01 $mini_c01y = $mini_min01y + $start_rows01 $mini_max = 10 $a_fog_green02num = 1 $a_fog_green02min = 20 $a_fog_green02max = 25 ; Tạo khuôn chứa map 50x34 (ví dụ), giá trị mặc định là 0 (đường trống) Local $total_bytes = $col_bfs01 * $row_bfs01 Local $tMapBuffer = DllStructCreate("char[" & $total_bytes & "]") ; Mặc định điền 0 vào toàn bộ khuôn DllStructSetData($tMapBuffer, 1, 0) ; $time_start01 = TimerInit() ; ========================================================================= ; BƯỚC SIÊU TỐI ƯU 1: TẠO 1 STRUCT DUY NHẤT BAO PHỦ TOÀN BỘ VÙNG SCAN ĐỒ HỌA ; ========================================================================= ; Tính toán tổng số dwords của vùng nhớ và hệ số dịch dòng trước khi vào vòng lặp Local $iTotalDwords = Int(($stride / 4) * ($mini_max01y + 1)) Local $v_LargeBuffer = DllStructCreate("dword[" & $iTotalDwords & "]", $Scan0) Local $iStrideDwords = Int($stride / 4) For $j = $mini_min02y To $mini_max01y ; Tính sẵn vị trí offset dòng trong mảng dword để triệt tiêu phép nhân ở vòng lặp trong Local $iCurrentRowOffset = $j * $iStrideDwords ; Tính toán sẵn $y_idx cho vòng lặp hàng hiện tại Local $y_idx = $j - $mini_min01y For $i = $mini_min02x To $mini_max01x - 10 ; Đọc thẳng màu pixel từ mảng dword bằng chỉ số Index (Mảng trong struct bắt đầu từ 1 nên + 1) Local $iPixelIndex = $iCurrentRowOffset + $i + 1 $aArray[$j][$i] = Hex(DllStructGetData($v_LargeBuffer, 1, $iPixelIndex), 6) If $switch_map = 2 Then ; _check_map03 $a_fog_green01dis = 0 If $i > $mini_c01x - $mini_max And $i < $mini_c01x + $mini_max And $j > $mini_c01y - $mini_max And $mini_c01y < $mini_c01y + $mini_max Then $a_fog_green01dis = 1 ; TÍNH OFFSET CHUẨN ĐỂ GHI VÀO KHUÔN (Giữ nguyên thuật toán của bạn) Local $x_idx = $i - $mini_min01x Local $offset = ($x_idx * $row_bfs01) + $y_idx + 1 If $aArray[$j][$i] = "FFFFFF" Then $data_map[$y_idx][$x_idx] = "x" DllStructSetData($tMapBuffer, 1, 120, $offset) ; Ghi 'x' (120) vào khuôn ElseIf $a_fog_green02num < $mini_array - 1 And $a_fog_green02min > $a_fog_green02max And $a_fog_green01dis = 0 And $aArray[$j][$i] = "00FF00" Then $count_green01 = 1 ; Đọc mảng xung quanh từ mảng đồ họa đã tối ưu If $aArray[$j + 1][$i + 1] = "00FF00" Then $count_green01 += 1 If $aArray[$j + 1][$i + 0] = "00FF00" Then $count_green01 += 1 If $aArray[$j + 0][$i + 1] = "00FF00" Then $count_green01 += 1 If $count_green01 > 1 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $i * $title_size01x - 270, $j * $title_size01y + 210, $tileWidth, $tileHeight, $Brush_green) GUICtrlSetData($button_submit02, " N=" & $loopacc0 & " [$a_fog_green02num]=" & $a_fog_green02num & " $i=" & $i & " $j=" & $j) EndIf $a_fog_green02xy[$a_fog_green02num][0] = $i $a_fog_green02xy[$a_fog_green02num][1] = $j $a_fog_green02num += 1 $a_fog_green02min = 0 EndIf Else If $view_gdi01on = 1 And $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $i * $title_size01x - 270, $j * $title_size01y + 210, $tileWidth, $tileHeight, $Brush_gray) $data_map[$y_idx][$x_idx] = "0" DllStructSetData($tMapBuffer, 1, 48, $offset) ; Ghi '0' (48) vào khuôn EndIf $a_fog_green02min += 1 EndIf ; end _check_map03 Next Next ; Bạn đã có $tMapBuffer hoàn chỉnh, giờ chỉ cần ném nó vào ASM _MemoryWrite64struct($mapBase, $procHwnd_autoit01, $tMapBuffer) ; $time_stop01 = int(TimerDiff($time_start01)) ;ToolTip("N="&$loopacc&" $time_stop01="&$time_stop01, 0, 0) ;EndIf ;_ArrayDisplay($aArray) ; END IMAGE > ARRAY ;_ArrayDisplay($a_fog_green02xy) ; WALL MAP For $y_wall = $mini_min01y to $mini_max01y+0 $data_map[$y_wall-$mini_min01y][$mini_min01x-$mini_min01x] = "x" $data_map[$y_wall-$mini_min01y][$mini_max01x-$mini_min01x] = "x" $data_map[$y_wall-$mini_min01y][$mini_max01x-$mini_min01x-9] = "x" If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $mini_min01x*$title_size01x-270, $y_wall*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $mini_max01x*$title_size01x-270, $y_wall*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) Next For $x_wall = $mini_min01x to $mini_max01x+0 $data_map[$mini_min01y-$mini_min01y][$x_wall-$mini_min01x] = "x" $data_map[$mini_max01y-$mini_min01y][$x_wall-$mini_min01x] = "x" If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x_wall*$title_size01x-270 , ($mini_min01y-$mini_min01y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x_wall*$title_size01x-270 , ($mini_max01y+$mini_min01y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) Next For $lp_y = $start_rows01-3 to $start_rows01+3 For $lp_x = $start_cols01-3 to $start_cols01+3 ; 1. Xử lý mảng ảo và vẽ giao diện hiển thị của bạn $data_map[$lp_y][$lp_x] = "0" _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$lp_x)*$title_size01x-270 , ($mini_max01y-$lp_y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_gray) ; 2. Tính toán tịnh tiến đưa về chỉ số gốc (0,0) dựa trên mốc tọa độ nhỏ nhất của map Local $y_idx = $lp_y - $mini_min01y Local $x_idx = $lp_x - $mini_min01x ; 3. Tính toán offset tuyến tính trong RAM (Bỏ "+ 1" vì ghi thẳng vào địa chỉ nhớ) Local $offset = ($x_idx * $row_bfs01) + $y_idx ; 4. Ghi đè ký tự '0' (mã ASCII là 48) trực tiếp vào RAM game để xóa ô kẹt _MemoryWrite64($mapBase + $offset, $procHwnd_autoit01, Ptr(48), 'byte[1]') Next Next If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+0)*$title_size01x-270 , ($mini_max01y-$start_rows01+1)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+1)*$title_size01x-270 , ($mini_max01y-$start_rows01+0)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+0)*$title_size01x-270 , ($mini_max01y-$start_rows01+0)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+1)*$title_size01x-270 , ($mini_max01y-$start_rows01+1)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) $data_map[$start_rows01][$start_cols01] = "s" Global $start_red = ($start_rows01 - 0) * $cols + ($start_rows01 - 0) $data = $data_map ;_ArrayDisplay($data_map) ;MsgBox($MB_SYSTEMMODAL, "Title", "x="&UBound($stream02[12], $UBOUND_COLUMNS)-0-40 & "y="&UBound($stream02[12], $UBOUND_ROWS)-0-24 , 0) ; END WALL MAP EndIf ; END CHECK FALSE LARGE MAP $a_map_min00x[$loopacc] = $mini_min01x $a_map_max00x[$loopacc] = $mini_max01x $a_map_min00y[$loopacc] = $mini_min01y $a_map_max00y[$loopacc] = $mini_max01y GUICtrlSetData($button_submit02, " N="&$loopacc&" $map_min01x="&$map_min01x&" $map_max01x="&$map_max01x&" $map_min01y="&$map_min01y&" $map_max01y="&$map_max01y) EndIf ; end da exit game ------------------------------------------------------------------- ;_WinAPI_DeleteDC($hCDC) ;$vtmem_autoitX = _MemVirtualAlloc(0x0, 0x2B0000, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; khoi tao 1 lan duy nhat khong se bi error memory ;$tCodeBuffer = ASM64_opcode01vtmem() ; khoi tao 1 lan duy nhat khong se bi error memory ;$vtmem_autoit_screenX = $vtmem_autoitX+0x100000 ; 0x1000 _WinAPI_MoveMemory($vtmem_autoit_screenX, $tPixel, ($height/$scale0) * ($width/$scale0) * 4) ;ClipPut($vtmem_autoit_screenX&@CRLF&$iScan0) ;MsgBox("","check","$iScan0 = "&$iScan0&" $tBitmapData = "&$tBitmapData,0) ;$AllPixels = DllStructGetData($v_BufferA, 1) ;ConsoleWrite("$AllPixels, raw data, first 9 colours = " & StringRegExpReplace($AllPixels, "(.{98})(.*)", "\1") & @CRLF) ;#CS ;$Stride = DllStructGetData($tBitmapData, "Stride") ;ConsoleWrite("Bitmap Stride: " & $Stride & @CRLF) ;$Width = DllStructGetData($tBitmapData, "Width") ;ConsoleWrite("Bitmap Width: " & $Width & @CRLF) ;$Height = DllStructGetData($tBitmapData, "Height") ;ConsoleWrite("Bitmap Height: " & $Height & @CRLF) ;$PixelFormat = DllStructGetData($tBitmapData, "PixelFormat") ;ConsoleWrite("Bitmap PixelFormat: " & $PixelFormat & @CRLF) ;$Scan0 = DllStructGetData($tBitmapData, "Scan0") ;ConsoleWrite("Bitmap Scan0: " & $Scan0 & @CRLF) ;$pPixels = $Scan0 ;If $pPixels <> 0x000000 Then ;$x0 = 670 ;$x1 = 689 ;$y0 = 56 ;$y1 = 75 ;For $row = $y0 To $y1 - 1 ; For $col = $x0 To $x1 - 1 ; $pixel = DllStructCreate("dword", $Scan0 + $row * $Stride + $col*4) ; $h_color0 = Hex(DllStructGetData($pixel, 1),8) ; ConsoleWrite(" x ="&$col&" y = "&$row&" color_hex = "&$h_color0 & @CRLF) ; Next ; ConsoleWrite("-------" & @CRLF) ;Next ;EndIf ;#CE ;Sleep(50000) ; change color = memory ; change color = StringRegExpReplace($hImage, $iColSrch, $iColNew, $iCount) $change_color01 = 0 $change_color02 = 0 $iCount = 0 If $change_color01 <> 0 or $change_color02 <> 0 Then $color_hex01 = DllStructGetData($tPixel, 1 ) ;get pixel color array bytes $sREResult1 = StringRegExpReplace(StringTrimLeft($color_hex01, 2), "(.{8})", "\1 ") ; ConsoleWrite("$sREResult1 first 9 colours = " & StringRegExpReplace($sREResult1, "(.{81})(.*)", "\1") & @CRLF) EndIf If $change_color01 = 1 Then $iColSrch = "(?i)([0-3][0-9A-F]{5}FF)" ; Change near black to black $iColNew = "FFFFFFFF" ;If StringInStr($iColNew, "0x") > 0 Then $iColNew = StringReplace($iColNew, "0x", ""); Remove "0x" not needed ; StringRegExpReplace performed and white spaces removed $sResult = StringStripWS(StringRegExpReplace($sREResult1, $iColSrch, $iColNew, $iCount), 8) EndIf If $change_color02 = 1 Then $iColSrch = "(?i)([0-3][0-9A-F]{5}FF)" ; Change near black to black FFFFFFFF $iColNew = "55FF55FF" ;If StringInStr($iColNew, "0x") > 0 Then $iColNew = StringReplace($iColNew, "0x", ""); Remove "0x" not needed ; StringRegExpReplace performed and white spaces removed If $change_color01 = 1 Then $sResult = StringStripWS(StringRegExpReplace($sResult, $iColSrch, $iColNew, $iCount), 8) If $change_color01 = 0 Then $sResult = StringStripWS(StringRegExpReplace($sREResult1, $iColSrch, $iColNew, $iCount), 8) EndIf If $change_color01 <> 0 and $change_color02 <> 0 Then ; Replace "0x" prefix and set modified data back to DLL structure, $v_BufferA=$tPixel DllStructSetData($tPixel, 1, "0x" & $sResult) EndIf _GDIPlus_BitmapUnlockBits($g_hBitmap02, $tBitmapData) ; xoa truoc Dispose _GDIPlus_BitmapDispose($g_hBitmap02) ; bi loi tang memory size ;_GDIPlus_ImageDispose($g_hBitmap02) $wincapture00on = 1 If $width = 0 and $height = 0 and $Scan0 = 0 Then $a_fog_green02xy = "" $wincapture00on = 0 ; done = 1 error = 0 ElseIf $hWnd = "" Then $a_fog_green02xy = "" $wincapture00on = 0 ; done = 1 error = 0 EndIf ;_GDIPlus_BitmapUnlockBits($g_hBitmap, $tBitmapData) ; xoa truoc Dispose ;_GDIPlus_BitmapDispose($g_hBitmap) ; bi loi tang memory size ;FileDelete("c:\acc\0_MEO_D01_2.jpg") ;_GDIPlus_ImageSaveToFile($BMP, "c:\acc\0_MEO_D01_2.jpg") ; _WinAPI_DeleteObject($hBitmap) ko save duoc ; end change color = StringRegExpReplace($hImage, $iColSrch, $iColNew, $iCount) ;ClipGet($iScan0) ;MsgBox(0, "Time Elapsed: " & $tPixel, $iScan0) ; --- Đoạn code chèn vào cuối hàm WinCapture_cs03 --- ; Giả định $data_map là mảng 2 chiều chứa thông tin map ; Local $rows = UBound($data_map, 1) ; Local $cols = UBound($data_map, 2) ;Local $tMapData = DllStructCreate("byte[" & ($rows * $cols) & "]") ; Đổi "byte" thành "char" (char trong AutoIt là 1 byte, nhận giá trị 0-255) ; Local $tMapData = DllStructCreate("char[" & ($rows * $cols) & "]") ; For $c = 0 To $cols - 1 ; For $r = 0 To $rows - 1 ; ; Chuyển ký tự 'x' (tường) thành 1, '0' (trống) thành 0 ; Local $val = ($data_map[$c][$r] = "x" ? 120 : 0) ; DllStructSetData($tMapData, 1, $val, ($r * $cols) + $c + 1) ; Next ; Next ; Gọi hàm ghi memory của bạn với địa chỉ $mapBase ; Lưu ý: Đảm bảo $mapBase đã được tính toán đúng địa chỉ trước đó ; _MemoryWrite64struct($mapBase, $procHwnd_autoit01, $tMapData) ;ClipPut($mapBase) ; Giải phóng bộ nhớ tạm ; $tMapData = 0 Local $stream_var[18] = [$hBMP, $Scan0, $tPixel, $g_hBitmap, $tBitmapData, $hWnd, $hDDC, $hCDC, $iWidth, $iHeight, $g_x0, $g_y0, $a_fog_green02xy,$g_hBitmap02,$wincapture00on &@CRLF& _ ""] ;$x01 = 555 ;$y01 = 394 ;$iRowOffset = $y01 * $iWidth+1 ; $iRowOffset = $iY * $iWidth + 1 ;$acolor01 = Hex(DllStructGetData($stream_var[2], 1, $iRowOffset + $x01),6) ;get pixel color ;MsgBox("","check","01 = "&$acolor01&" 02 = "&$acolor01,0) ; Local $stream_var[0] = $hBMP ; Local $stream_var[1] = $iScan0 ; Local $stream_var[2] = $tPixel ; Local $stream_var[3] = $BMP > $g_hBitmap ; Local $stream_var[4] = $tBitmapData ; Local $stream_var[5] = $WinHandle ; Local $stream_var[6] = $hDDC ; Local $stream_var[7] = $hCDC ; Local $stream_var[8] = $iWidth ; Local $stream_var[9] = $iHeight ; Local $stream_var[10] = $g_x0 ; Local $stream_var[11] = $g_y0 ; Local $stream_var[12] = $aArray ; IMGAGE > ARRAY > $a_fog_green02xy ; Local $stream_var[13] = $g_hBitmap02 ; Local $stream_var[14] = $wincapture00on = 0 ; done = 1 error = 0 ;MsgBox("","check cs03","$tBitmapData = "&$tBitmapData&" $g_hBitmap02 = "&$g_hBitmap02,0) Return $stream_var EndFunc ;==>_WinCapture01 ; Local $stream = WinCapture_cs01($control01,3,$game_cap_x02,$game_cap_y02,$view_screen01,$game_cap_x01,$game_cap_y01,$g_x,$g_y) ; chay only show gui image Func WinCapture_cs03($hWnd,$nFlags, $iWidth = -1, $iHeight = -1, $del_hBMP=0, $x0=0, $y0=0, $g_x0=0, $g_y0=0,$copy_view01=1,$image_array0="IMAGE_ARRAY" ) ; chay only show gui image ;Local $hTimer = TimerInit() ;$copy_view01 = 1 $gdi_plus01 = 1 _GDIPlus_Startup() ; Lay image game vao memory Local $iH, $iW, $hDDC, $hCDC, $hBMP ; If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) ; If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) ; $iWidth5 = _WinAPI_GetWindowWidth($hWnd) ; $iHeight5 = _WinAPI_GetWindowHeight($hWnd) ;MsgBox("","check","$iWidth = "&$iWidth&" $iHeight = "&$iHeight&" $iWidth5 = "&$iWidth5&" $iHeight5 = "&$iHeight5,0) $iIW = Int($iWidth/$scale0) $iIH = Int($iHeight/$scale0) ; > Dim $aArray[$height][$width] $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) _WinAPI_DeleteObject($hBMP) ; xoa ko hien thi hinh gui nhung van co trong memory DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", $nFlags) ; bit map lockbits nhanh hon Local $BMP = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ;_WinAPI_DeleteObject($hClone01) ; _GDIPlus_BitmapDispose($hClone01) If $gdi_plus01=1 Then ;_WinAPI_CreateColorAdjustment ( [$iFlags = 0 [, $iIlluminant = 0 [, $iGammaR = 10000 [, $iGammaG = 10000 [, $iGammaB = 10000 [, $iBlack = 0 [, $iWhite = 10000 [, $iContrast = 0 [, $iBrightness = 0 [, $iColorfulness = 0 [, $iTint = 0]]]]]]]]]]] ) ;Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 100, 0, 0, 0, 0, 0] ;set Tint to 100 ;Global $g_aDefault[11] = [10000, 10000, 10000, 1540, 6000, 100, -39, 0, 0, 0, 0] ;set Tint to 100 ;Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 50, -25, 0, 0, 0, 0] ;set Tint to 100 ;$g_aDefault[9] = BitOR($g_aDefault[9], $CA_NEGATIVE) ; invert color ;$g_aDefault[9] = BitAND($g_aDefault[9], BitNOT($CA_NEGATIVE)) $g_aDefault[9] = BitOR($g_aDefault[9], $CA_LOG_FILTER) ; sang hon ; $g_aDefault[9] = BitAND($g_aDefault[9], BitNOT($CA_LOG_FILTER)) ; $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hObj) $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($BMP) ; $hSrc=_ScreenCapture_Capture("",0,0, 500,300) _GDIPlus_BitmapDispose($BMP) ; bi loi tang memory size Local $tAdjust = 0 If IsArray($g_aDefault) Then $tAdjust = _WinAPI_CreateColorAdjustment($g_aDefault[9], $g_aDefault[10], $g_aDefault[0], $g_aDefault[1], $g_aDefault[2], $g_aDefault[3], $g_aDefault[4], $g_aDefault[5], $g_aDefault[6], $g_aDefault[7], $g_aDefault[8]) EndIf $hBitmap = _WinAPI_AdjustBitmap($hSrc, -1, -1, $HALFTONE, $tAdjust) If @error Then Return 0 EndIf $g_hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) ; xai $scale0 $g_hBitmap02 = _GDIPlus_ImageResize($g_hBitmap, $iIW, $iIH) ;resize image EndIf ;------------------------------------------------------------------------------------------- If $copy_view01 = 1 Then ; clone handle hinh anh $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle ;$g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics) ;$g_hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ;_GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_1.jpg") ; _WinAPI_DeleteObject($hBitmap) ko save duoc _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $g_hBitmap02, 0, 0) ;draw bitmap to backbuffer _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap02, 0, 0, $iIW, $iIH) ;copy drawn bitmap to graphics handle (GUI) _GDIPlus_GraphicsDispose($g_hGfxCtxt) _GDIPlus_GraphicsDispose($g_hGraphics) ;_WinAPI_DeleteObject($g_hBitmap) ;_WinAPI_DeleteObject($BMP) EndIf ; _GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_A_STAR_ALL01.jpg") ; test save bitmap ; _GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_A_STAR_ALL02.jpg") ; test save bitmap ;_GDIPlus_ImageSaveToFile($hClone01, "c:\acc\"&$file0) ; test save bitmap If $gdi_plus01=1 Then _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hSrc) EndIf ; trancexx ;Local $aArray[$iHeight][$iWidth] ;Local $tBitmapData = _GDIPlus_BitmapLockBits($pBitmap, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;Local $tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", DllStructGetData($tBitmapData, "Scan0")) ;For $iX = 0 To $iWidth - 1 ; For $iY = 0 To $iHeight - 1 ; $aArray[$iY][$iX] = BitAND(DllStructGetData($tPixel, 1, $iY * $iWidth + $iX + 1), 0xFFFFFF) ; Next ;Next ;_GDIPlus_BitmapUnlockBits($pBitmap, $tBitmapData) ; end trance ; Local $tBitmapData = _GDIPlus_BitmapLockBits($BMP, $x0, $y0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;locks a portion of a bitmap for reading and writing. More infor at http://msdn.microsoft.com/en-us/library/windows/desktop/ms536298(v=vs.85).aspx ; Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap ; Local $iSearchPixel = Int(0xFF000080), $iReplaceColor = 0x00000000 ;color format 0xAARRGGBB ; Local $tPixel = DllStructCreate("int[" & $iWidth * $iHeight & "];", $iScan0) ; > int dec ;Local $tPixel = DllStructCreate("byte[" & $iHeight * $iWidth* 4 & "]", $iScan0) ; > array bytes flip ; IMAGE > ARRAY If $image_array0="IMAGE_ARRAY" Then Local $v_Buffer EndIf ; END IMAGE > ARRAY ; Locks a portion of a bitmap for reading or writing Local $tBitmapData = _GDIPlus_BitmapLockBits($g_hBitmap02, $x0, $y0, $iIW, $iIH, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () Local $width = DllStructGetData($tBitmapData, "width") Local $height = DllStructGetData($tBitmapData, "height") Local $stride = DllStructGetData($tBitmapData, "stride") Local $format = DllStructGetData($tBitmapData, "format") Local $Scan0 = DllStructGetData($tBitmapData, "Scan0") Local $tPixel = DllStructCreate("byte[" & ($iIH) * ($iIW) * 4 & "]", $Scan0) ; Create DLL structure for all pixels Local $iPixel, $iRowOffset ; end Lay image game vao memory Local $aArray[$iIH][$iIW] $mini_min02x = $mini_min01x $mini_min02y = $mini_min01y If $mini_min01x > $iIW - 1 Then $mini_min02x = $iIW - 1 If $mini_min01y > $iIH - 1 Then $mini_min02y = $iIH - 1 ;MsgBox($MB_SYSTEMMODAL, "Title", "$width="&$width& " $height="&$height& " $stride="&$stride& " $format="&$format&" $Scan0="&$Scan0&" $tPixel="&$tPixel , 0) If $loopacc = $loop_view01 Then _GDIPlus_GraphicsClear($hGraphic) $view_gdi01on = 0 If _IsChecked( ($button_auto03[4])[7-1] ) = True Then $view_gdi01on = 1 Dim $data_map[$rows_scale][$col_scale] $map_min01x = $map_c01x $map_max01x = $map_c01x $map_min01y = $map_c01y $map_max01y = $map_c01y $iY_max = UBound($aArray, $UBOUND_ROWS)-1 $iX_max = UBound($aArray, $UBOUND_COLUMNS)-1 ;MsgBox($MB_SYSTEMMODAL, "Title", "$col_scale+1="&$col_scale+1 & "$rows_scale+1="&$rows_scale+1&" $iX_max="&$iX_max & "$iY_max="&$iY_max , 0) $MAP_LEFT_UP = 0 $MAP_RIGHT_UP = 0 $MAP_LEFT_DOWN = 0 $MAP_RIGHT_DOWN = 0 $MAP_CENTER_MAX = 5 ;MsgBox($MB_SYSTEMMODAL, "Title", "$width="&$width& " $height="&$height& " $stride="&$stride& " $format="&$format&" $Scan0="&$Scan0&" $tPixel="&$tPixel , 0) If $width <> 0 and $height <> 0 and $Scan0 <> 0 and $hWnd <> 0 Then ; da exit game ------------------------------------------------------------------- For $j = $mini_min01y To $MAP_CENTER_MAX For $i = $mini_min01x To $MAP_CENTER_MAX $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_LEFT_UP = 1 ExitLoop EndIf Next Next For $j = $mini_min01y To $MAP_CENTER_MAX For $i = $mini_max01x-$MAP_CENTER_MAX To $iX_max $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_RIGHT_UP = 1 ExitLoop EndIf Next Next For $j = $mini_max01y-$MAP_CENTER_MAX To $iY_max For $i = $mini_min01x To $MAP_CENTER_MAX $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_LEFT_DOWN = 1 ExitLoop EndIf Next Next For $j = $mini_max01y-$MAP_CENTER_MAX To $iY_max For $i = $mini_max01x-$MAP_CENTER_MAX To $iX_max $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) If TestTrans05("000000", $aArray[$j][$i], 70) = 1 Then $MAP_RIGHT_DOWN = 1 ExitLoop EndIf Next Next If $MAP_LEFT_UP = 1 and $MAP_RIGHT_UP = 1 and $MAP_LEFT_DOWN = 1 and $MAP_RIGHT_DOWN = 1 Then ; CHECK FALSE LARGE MAP $map_min01x = $mini_min01x $map_max01x = $mini_max01x $map_min01y = $mini_min01y $map_max01y = $mini_max01y GUICtrlSetData($button_submit02, " N="&$loopacc&" _check_map03="&"FALSE LARGE MAP") Else GUICtrlSetData($button_submit02, " N="&$loopacc&" _check_map03="&"TRUE LARGE MAP") ; MsgBox($MB_SYSTEMMODAL, "Title", "$mini_min01x="&$mini_min01x& " $mini_max01x="&$mini_max01x& " $mini_min01y="&$mini_min01y& " $mini_max01y="&$mini_max01y&" $iY_max="&$iY_max&" $iX_max="&$iX_max , 0) ;_ArrayDisplay($data_map) $switch_map = 2 $fog_green01on = 1 $mini_array = 10+1 Dim $a_fog_green02xy[$mini_array][2] $mini_c01x = $mini_min01x + $start_cols01 $mini_c01y = $mini_min01y + $start_rows01 $mini_max = 10 $a_fog_green02num = 1 $a_fog_green02min = 20 $a_fog_green02max = 25 For $j = $mini_min02y To $mini_max01y For $i = $mini_min02x To $mini_max01x-10 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = Hex(DllStructGetData($v_Buffer, 1), 6) ; MsgBox($MB_SYSTEMMODAL, "Title", "$mini_min01x="&$mini_min01x& " $mini_max01x="&$mini_max01x& " $mini_min01y="&$mini_min01y& " $mini_max01y="&$mini_max01y&" $j-$mini_min01y="&$j-$mini_min01y&" $i-$mini_min01x="&$i-$mini_min01x , 0) If $switch_map = 2 Then ; _check_map03 ;_GDIPlus_BrushSetSolidColor($hBrush, $stream02[12][$j][$i]) $a_fog_green01dis = 0 If $i > $mini_c01x-$mini_max and $i < $mini_c01x+$mini_max and $j > $mini_c01y-$mini_max and $mini_c01y < $mini_c01y+$mini_max Then $a_fog_green01dis = 1 ;If TestTrans05("000000", ($stream02[12])[$j][$i], 1) = 1 Then If $aArray[$j][$i] = "FFFFFF" Then ;If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $i * ($tileWidth + $distance) + $distance, $j * ($tileHeight + $distance) + $distance, $tileWidth, $tileHeight, $Brush_gray) $data_map[$j-$mini_min01y][$i-$mini_min01x] = "x" ElseIf $a_fog_green02num < $mini_array-1 and $a_fog_green02min > $a_fog_green02max and $a_fog_green01dis = 0 and $aArray[$j+0][$i+0] = "00FF00" Then $count_green01 = 1 If $aArray[$j+1][$i+1] = "00FF00" Then $count_green01 += 1 If $aArray[$j+1][$i+0] = "00FF00" Then $count_green01 += 1 If $aArray[$j+0][$i+1] = "00FF00" Then $count_green01 += 1 If $count_green01 > 2-1 Then If $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $i * $title_size01x-270, $j * $title_size01y+210 , $tileWidth, $tileHeight, $Brush_green) GUICtrlSetData($button_submit02, " N="&$loopacc0&" [$a_fog_green02num]="&$a_fog_green02num&" $i="&$i&" $j="&$j) EndIf $a_fog_green02xy[$a_fog_green02num][0] = $i $a_fog_green02xy[$a_fog_green02num][1] = $j $a_fog_green02num += 1 $a_fog_green02min = 0 EndIf Else ;MsgBox($MB_SYSTEMMODAL, "Title", "$j="&$j & "$i="&$i&" $j-$mini_min01y="&$j-$mini_min01y & " $i-$mini_min01x="&$i-$mini_min01x , 0) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $i * $title_size01x-270 , $j * $title_size01y + 210 , $tileWidth, $tileHeight, $Brush_gray) $data_map[$j-$mini_min01y][$i-$mini_min01x] = "0" EndIf $a_fog_green02min += 1 EndIf ; end _check_map03 Next ; ProgressSet(Int(100 * $j / ($iIH)), Int(100 * $j / ($iIH)) & " percent") Next ;EndIf ;_ArrayDisplay($aArray) ; END IMAGE > ARRAY ;_ArrayDisplay($a_fog_green02xy) ; WALL MAP For $y_wall = $mini_min01y to $mini_max01y+0 $data_map[$y_wall-$mini_min01y][$mini_min01x-$mini_min01x] = "x" $data_map[$y_wall-$mini_min01y][$mini_max01x-$mini_min01x] = "x" $data_map[$y_wall-$mini_min01y][$mini_max01x-$mini_min01x-9] = "x" If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $mini_min01x*$title_size01x-270, $y_wall*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $mini_max01x*$title_size01x-270, $y_wall*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) Next For $x_wall = $mini_min01x to $mini_max01x+0 $data_map[$mini_min01y-$mini_min01y][$x_wall-$mini_min01x] = "x" $data_map[$mini_max01y-$mini_min01y][$x_wall-$mini_min01x] = "x" If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x_wall*$title_size01x-270 , ($mini_min01y-$mini_min01y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, $x_wall*$title_size01x-270 , ($mini_max01y+$mini_min01y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_blue) Next For $lp_y = $start_rows01-3 to $start_rows01+3 For $lp_x = $start_cols01-3 to $start_cols01+3 $data_map[$lp_y][$lp_x] = "0" _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$lp_x)*$title_size01x-270 , ($mini_max01y-$lp_y)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_gray) Next Next If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+0)*$title_size01x-270 , ($mini_max01y-$start_rows01+1)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+1)*$title_size01x-270 , ($mini_max01y-$start_rows01+0)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+0)*$title_size01x-270 , ($mini_max01y-$start_rows01+0)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) If $view_gdi01on = 1 and $loopacc = $loop_view01 Then _GDIPlus_GraphicsFillRect($hGraphic, ($mini_max01x-$start_cols01+1)*$title_size01x-270 , ($mini_max01y-$start_rows01+1)*$title_size01y+210 , $tileWidth, $tileHeight, $Brush_red) $data_map[$start_rows01][$start_cols01] = "s" Global $start_red = ($start_rows01 - 0) * $cols + ($start_rows01 - 0) $data = $data_map ;_ArrayDisplay($data_map) ;MsgBox($MB_SYSTEMMODAL, "Title", "x="&UBound($stream02[12], $UBOUND_COLUMNS)-0-40 & "y="&UBound($stream02[12], $UBOUND_ROWS)-0-24 , 0) ; END WALL MAP EndIf ; END CHECK FALSE LARGE MAP $a_map_min00x[$loopacc] = $mini_min01x $a_map_max00x[$loopacc] = $mini_max01x $a_map_min00y[$loopacc] = $mini_min01y $a_map_max00y[$loopacc] = $mini_max01y GUICtrlSetData($button_submit02, " N="&$loopacc&" $map_min01x="&$map_min01x&" $map_max01x="&$map_max01x&" $map_min01y="&$map_min01y&" $map_max01y="&$map_max01y) EndIf ; end da exit game ------------------------------------------------------------------- ;_WinAPI_DeleteDC($hCDC) ;$vtmem_autoitX = _MemVirtualAlloc(0x0, 0x2B0000, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; khoi tao 1 lan duy nhat khong se bi error memory ;$tCodeBuffer = ASM64_opcode01vtmem() ; khoi tao 1 lan duy nhat khong se bi error memory ;$vtmem_autoit_screenX = $vtmem_autoitX+0x100000 ; 0x1000 _WinAPI_MoveMemory($vtmem_autoit_screenX, $tPixel, ($height/$scale0) * ($width/$scale0) * 4) ;ClipPut($vtmem_autoit_screenX&@CRLF&$iScan0) ;MsgBox("","check","$iScan0 = "&$iScan0&" $tBitmapData = "&$tBitmapData,0) ;$AllPixels = DllStructGetData($v_BufferA, 1) ;ConsoleWrite("$AllPixels, raw data, first 9 colours = " & StringRegExpReplace($AllPixels, "(.{98})(.*)", "\1") & @CRLF) ;#CS ;$Stride = DllStructGetData($tBitmapData, "Stride") ;ConsoleWrite("Bitmap Stride: " & $Stride & @CRLF) ;$Width = DllStructGetData($tBitmapData, "Width") ;ConsoleWrite("Bitmap Width: " & $Width & @CRLF) ;$Height = DllStructGetData($tBitmapData, "Height") ;ConsoleWrite("Bitmap Height: " & $Height & @CRLF) ;$PixelFormat = DllStructGetData($tBitmapData, "PixelFormat") ;ConsoleWrite("Bitmap PixelFormat: " & $PixelFormat & @CRLF) ;$Scan0 = DllStructGetData($tBitmapData, "Scan0") ;ConsoleWrite("Bitmap Scan0: " & $Scan0 & @CRLF) ;$pPixels = $Scan0 ;If $pPixels <> 0x000000 Then ;$x0 = 670 ;$x1 = 689 ;$y0 = 56 ;$y1 = 75 ;For $row = $y0 To $y1 - 1 ; For $col = $x0 To $x1 - 1 ; $pixel = DllStructCreate("dword", $Scan0 + $row * $Stride + $col*4) ; $h_color0 = Hex(DllStructGetData($pixel, 1),8) ; ConsoleWrite(" x ="&$col&" y = "&$row&" color_hex = "&$h_color0 & @CRLF) ; Next ; ConsoleWrite("-------" & @CRLF) ;Next ;EndIf ;#CE ;Sleep(50000) ; change color = memory ; change color = StringRegExpReplace($hImage, $iColSrch, $iColNew, $iCount) $change_color01 = 0 $change_color02 = 0 $iCount = 0 If $change_color01 <> 0 or $change_color02 <> 0 Then $color_hex01 = DllStructGetData($tPixel, 1 ) ;get pixel color array bytes $sREResult1 = StringRegExpReplace(StringTrimLeft($color_hex01, 2), "(.{8})", "\1 ") ; ConsoleWrite("$sREResult1 first 9 colours = " & StringRegExpReplace($sREResult1, "(.{81})(.*)", "\1") & @CRLF) EndIf If $change_color01 = 1 Then $iColSrch = "(?i)([0-3][0-9A-F]{5}FF)" ; Change near black to black $iColNew = "FFFFFFFF" ;If StringInStr($iColNew, "0x") > 0 Then $iColNew = StringReplace($iColNew, "0x", ""); Remove "0x" not needed ; StringRegExpReplace performed and white spaces removed $sResult = StringStripWS(StringRegExpReplace($sREResult1, $iColSrch, $iColNew, $iCount), 8) EndIf If $change_color02 = 1 Then $iColSrch = "(?i)([0-3][0-9A-F]{5}FF)" ; Change near black to black FFFFFFFF $iColNew = "55FF55FF" ;If StringInStr($iColNew, "0x") > 0 Then $iColNew = StringReplace($iColNew, "0x", ""); Remove "0x" not needed ; StringRegExpReplace performed and white spaces removed If $change_color01 = 1 Then $sResult = StringStripWS(StringRegExpReplace($sResult, $iColSrch, $iColNew, $iCount), 8) If $change_color01 = 0 Then $sResult = StringStripWS(StringRegExpReplace($sREResult1, $iColSrch, $iColNew, $iCount), 8) EndIf If $change_color01 <> 0 and $change_color02 <> 0 Then ; Replace "0x" prefix and set modified data back to DLL structure, $v_BufferA=$tPixel DllStructSetData($tPixel, 1, "0x" & $sResult) EndIf _GDIPlus_BitmapUnlockBits($g_hBitmap02, $tBitmapData) ; xoa truoc Dispose _GDIPlus_BitmapDispose($g_hBitmap02) ; bi loi tang memory size ;_GDIPlus_ImageDispose($g_hBitmap02) $wincapture00on = 1 If $width = 0 and $height = 0 and $Scan0 = 0 Then $a_fog_green02xy = "" $wincapture00on = 0 ; done = 1 error = 0 ElseIf $hWnd = "" Then $a_fog_green02xy = "" $wincapture00on = 0 ; done = 1 error = 0 EndIf ;_GDIPlus_BitmapUnlockBits($g_hBitmap, $tBitmapData) ; xoa truoc Dispose ;_GDIPlus_BitmapDispose($g_hBitmap) ; bi loi tang memory size ;FileDelete("c:\acc\0_MEO_D01_2.jpg") ;_GDIPlus_ImageSaveToFile($BMP, "c:\acc\0_MEO_D01_2.jpg") ; _WinAPI_DeleteObject($hBitmap) ko save duoc ; end change color = StringRegExpReplace($hImage, $iColSrch, $iColNew, $iCount) ;ClipGet($iScan0) ;MsgBox(0, "Time Elapsed: " & $tPixel, $iScan0) Local $stream_var[18] = [$hBMP, $Scan0, $tPixel, $g_hBitmap, $tBitmapData, $hWnd, $hDDC, $hCDC, $iWidth, $iHeight, $g_x0, $g_y0, $a_fog_green02xy,$g_hBitmap02,$wincapture00on &@CRLF& _ ""] ;$x01 = 555 ;$y01 = 394 ;$iRowOffset = $y01 * $iWidth+1 ; $iRowOffset = $iY * $iWidth + 1 ;$acolor01 = Hex(DllStructGetData($stream_var[2], 1, $iRowOffset + $x01),6) ;get pixel color ;MsgBox("","check","01 = "&$acolor01&" 02 = "&$acolor01,0) ; Local $stream_var[0] = $hBMP ; Local $stream_var[1] = $iScan0 ; Local $stream_var[2] = $tPixel ; Local $stream_var[3] = $BMP > $g_hBitmap ; Local $stream_var[4] = $tBitmapData ; Local $stream_var[5] = $WinHandle ; Local $stream_var[6] = $hDDC ; Local $stream_var[7] = $hCDC ; Local $stream_var[8] = $iWidth ; Local $stream_var[9] = $iHeight ; Local $stream_var[10] = $g_x0 ; Local $stream_var[11] = $g_y0 ; Local $stream_var[12] = $aArray ; IMGAGE > ARRAY > $a_fog_green02xy ; Local $stream_var[13] = $g_hBitmap02 ; Local $stream_var[14] = $wincapture00on = 0 ; done = 1 error = 0 ;MsgBox("","check cs03","$tBitmapData = "&$tBitmapData&" $g_hBitmap02 = "&$g_hBitmap02,0) Return $stream_var EndFunc ;==>_WinCapture01 ; Global $stream02 = WinCapture_cs03($control01,3,$game_cap_x02,$game_cap_y02,$view_screen01,$game_cap_x01,$game_cap_y01,$g_x,$g_y,$copy_view01) ; chay only show gui image ; WinCapture_ce03($stream02[3], $stream02[4], $stream02[5], $stream02[6], $stream02[7], $stream02[0], $stream02[13]) ; remove print image -------------------------- Func WinCapture_ce03($BMP, $tBitmapData, $WinHandle,$hDDC, $hCDC, $hBMP, $g_hBitmap02) _GDIPlus_BitmapUnlockBits($BMP, $tBitmapData) ;unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits all dell image _GDIPlus_ImageDispose($BMP) _WinAPI_ReleaseDC($WinHandle, $hDDC) _WinAPI_DeleteDC($hCDC) _WinAPI_DeleteObject($hBMP) ;cleanup resources ; _GDIPlus_ImageDispose($hImage) ;_GDIPlus_GraphicsDispose($hContext) ;_GDIPlus_BitmapDispose($hBitmap) ; _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>_GetColor ; Local $stream = WinCapture_cs01($control01,3,$game_cap_x02,$game_cap_y02,$view_screen01,$game_cap_x01,$game_cap_y01,$g_x,$g_y) ; chay only show gui image Func WinCapture_cs02($hWnd,$nFlags, $iWidth = -1, $iHeight = -1, $del_hBMP=0, $x0=0, $y0=0, $g_x0=0, $g_y0=0,$copy_view01=1 ) ; chay only show gui image ;Local $hTimer = TimerInit() ;$copy_view01 = 1 $gdi_plus01 = 1 _GDIPlus_Startup() ; Lay image game vao memory Local $iH, $iW, $hDDC, $hCDC, $hBMP If $iWidth = -1 Then $iWidth = _WinAPI_GetWindowWidth($hWnd) If $iHeight = -1 Then $iHeight = _WinAPI_GetWindowHeight($hWnd) $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) _WinAPI_DeleteObject($hBMP) ; xoa ko hien thi hinh gui nhung van co trong memory DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", $nFlags) ; bit map lockbits nhanh hon Local $BMP = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ;_WinAPI_DeleteObject($hClone01) ; _GDIPlus_BitmapDispose($hClone01) If $gdi_plus01=1 Then ;_WinAPI_CreateColorAdjustment ( [$iFlags = 0 [, $iIlluminant = 0 [, $iGammaR = 10000 [, $iGammaG = 10000 [, $iGammaB = 10000 [, $iBlack = 0 [, $iWhite = 10000 [, $iContrast = 0 [, $iBrightness = 0 [, $iColorfulness = 0 [, $iTint = 0]]]]]]]]]]] ) ;Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 100, 0, 0, 0, 0, 0] ;set Tint to 100 ;Global $g_aDefault[11] = [10000, 10000, 10000, 1540, 6000, 100, -39, 0, 0, 0, 0] ;set Tint to 100 ;Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 50, -25, 0, 0, 0, 0] ;set Tint to 100 ;$g_aDefault[9] = BitOR($g_aDefault[9], $CA_NEGATIVE) ; invert color ;$g_aDefault[9] = BitAND($g_aDefault[9], BitNOT($CA_NEGATIVE)) $g_aDefault[9] = BitOR($g_aDefault[9], $CA_LOG_FILTER) ; sang hon ; $g_aDefault[9] = BitAND($g_aDefault[9], BitNOT($CA_LOG_FILTER)) ; $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hObj) $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($BMP) ; $hSrc=_ScreenCapture_Capture("",0,0, 500,300) _GDIPlus_BitmapDispose($BMP) ; bi loi tang memory size Local $tAdjust = 0 If IsArray($g_aDefault) Then $tAdjust = _WinAPI_CreateColorAdjustment($g_aDefault[9], $g_aDefault[10], $g_aDefault[0], $g_aDefault[1], $g_aDefault[2], $g_aDefault[3], $g_aDefault[4], $g_aDefault[5], $g_aDefault[6], $g_aDefault[7], $g_aDefault[8]) EndIf $hBitmap = _WinAPI_AdjustBitmap($hSrc, -1, -1, $HALFTONE, $tAdjust) If @error Then Return 0 EndIf $g_hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) EndIf ;------------------------------------------------------------------------------------------- If $copy_view01 = 1 Then ; clone handle hinh anh $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle ;$g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics) ;$g_hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ;_GDIPlus_ImageSaveToFile($g_hBitmap, "c:\acc\0_MEO_D01_1.jpg") ; _WinAPI_DeleteObject($hBitmap) ko save duoc _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $g_hBitmap, 0, 0) ;draw bitmap to backbuffer _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iWidth, $iHeight) ;copy drawn bitmap to graphics handle (GUI) _GDIPlus_GraphicsDispose($g_hGfxCtxt) _GDIPlus_GraphicsDispose($g_hGraphics) ;_WinAPI_DeleteObject($g_hBitmap) ;_WinAPI_DeleteObject($BMP) EndIf If $gdi_plus01=1 Then _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hSrc) EndIf ; trancexx ;Local $aArray[$iHeight][$iWidth] ;Local $tBitmapData = _GDIPlus_BitmapLockBits($pBitmap, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;Local $tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", DllStructGetData($tBitmapData, "Scan0")) ;For $iX = 0 To $iWidth - 1 ; For $iY = 0 To $iHeight - 1 ; $aArray[$iY][$iX] = BitAND(DllStructGetData($tPixel, 1, $iY * $iWidth + $iX + 1), 0xFFFFFF) ; Next ;Next ;_GDIPlus_BitmapUnlockBits($pBitmap, $tBitmapData) ; end trance ; Local $tBitmapData = _GDIPlus_BitmapLockBits($BMP, $x0, $y0, $iWidth, $iHeight, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;locks a portion of a bitmap for reading and writing. More infor at http://msdn.microsoft.com/en-us/library/windows/desktop/ms536298(v=vs.85).aspx ; Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap ; Local $iSearchPixel = Int(0xFF000080), $iReplaceColor = 0x00000000 ;color format 0xAARRGGBB ; Local $tPixel = DllStructCreate("int[" & $iWidth * $iHeight & "];", $iScan0) ; > int dec ;Local $tPixel = DllStructCreate("byte[" & $iHeight * $iWidth* 4 & "]", $iScan0) ; > array bytes flip ; Locks a portion of a bitmap for reading or writing Local $tBitmapData = _GDIPlus_BitmapLockBits($g_hBitmap, $x0, $y0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () Local $width = DllStructGetData($tBitmapData, "width") Local $height = DllStructGetData($tBitmapData, "height") Local $stride = DllStructGetData($tBitmapData, "stride") Local $format = DllStructGetData($tBitmapData, "format") Local $Scan0 = DllStructGetData($tBitmapData, "Scan0") Local $tPixel = DllStructCreate("byte[" & $height * $width * 4 & "]", $Scan0) ; Create DLL structure for all pixels Local $iPixel, $iRowOffset ; end Lay image game vao memory ;_WinAPI_DeleteDC($hCDC) ;$vtmem_autoitX = _MemVirtualAlloc(0x0, 0x2B0000, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) ; khoi tao 1 lan duy nhat khong se bi error memory ;$tCodeBuffer = ASM64_opcode01vtmem() ; khoi tao 1 lan duy nhat khong se bi error memory ;$vtmem_autoit_screenX = $vtmem_autoitX+0x100000 ; 0x1000 _WinAPI_MoveMemory($vtmem_autoit_screenX, $tPixel, $height * $width * 4) ;ClipPut($vtmem_autoit_screenX&@CRLF&$iScan0) ;MsgBox("","check","$iScan0 = "&$iScan0&" $tBitmapData = "&$tBitmapData,0) ;$AllPixels = DllStructGetData($v_BufferA, 1) ;ConsoleWrite("$AllPixels, raw data, first 9 colours = " & StringRegExpReplace($AllPixels, "(.{98})(.*)", "\1") & @CRLF) ;#CS ;$Stride = DllStructGetData($tBitmapData, "Stride") ;ConsoleWrite("Bitmap Stride: " & $Stride & @CRLF) ;$Width = DllStructGetData($tBitmapData, "Width") ;ConsoleWrite("Bitmap Width: " & $Width & @CRLF) ;$Height = DllStructGetData($tBitmapData, "Height") ;ConsoleWrite("Bitmap Height: " & $Height & @CRLF) ;$PixelFormat = DllStructGetData($tBitmapData, "PixelFormat") ;ConsoleWrite("Bitmap PixelFormat: " & $PixelFormat & @CRLF) ;$Scan0 = DllStructGetData($tBitmapData, "Scan0") ;ConsoleWrite("Bitmap Scan0: " & $Scan0 & @CRLF) ;$pPixels = $Scan0 ;If $pPixels <> 0x000000 Then ;$x0 = 670 ;$x1 = 689 ;$y0 = 56 ;$y1 = 75 ;For $row = $y0 To $y1 - 1 ; For $col = $x0 To $x1 - 1 ; $pixel = DllStructCreate("dword", $Scan0 + $row * $Stride + $col*4) ; $h_color0 = Hex(DllStructGetData($pixel, 1),8) ; ConsoleWrite(" x ="&$col&" y = "&$row&" color_hex = "&$h_color0 & @CRLF) ; Next ; ConsoleWrite("-------" & @CRLF) ;Next ;EndIf ;#CE ;Sleep(50000) ; change color = memory ; change color = StringRegExpReplace($hImage, $iColSrch, $iColNew, $iCount) $change_color01 = 0 $change_color02 = 0 $iCount = 0 If $change_color01 <> 0 or $change_color02 <> 0 Then $color_hex01 = DllStructGetData($tPixel, 1 ) ;get pixel color array bytes $sREResult1 = StringRegExpReplace(StringTrimLeft($color_hex01, 2), "(.{8})", "\1 ") ; ConsoleWrite("$sREResult1 first 9 colours = " & StringRegExpReplace($sREResult1, "(.{81})(.*)", "\1") & @CRLF) EndIf If $change_color01 = 1 Then $iColSrch = "(?i)([0-3][0-9A-F]{5}FF)" ; Change near black to black $iColNew = "FFFFFFFF" ;If StringInStr($iColNew, "0x") > 0 Then $iColNew = StringReplace($iColNew, "0x", ""); Remove "0x" not needed ; StringRegExpReplace performed and white spaces removed $sResult = StringStripWS(StringRegExpReplace($sREResult1, $iColSrch, $iColNew, $iCount), 8) EndIf If $change_color02 = 1 Then $iColSrch = "(?i)([0-3][0-9A-F]{5}FF)" ; Change near black to black FFFFFFFF $iColNew = "55FF55FF" ;If StringInStr($iColNew, "0x") > 0 Then $iColNew = StringReplace($iColNew, "0x", ""); Remove "0x" not needed ; StringRegExpReplace performed and white spaces removed If $change_color01 = 1 Then $sResult = StringStripWS(StringRegExpReplace($sResult, $iColSrch, $iColNew, $iCount), 8) If $change_color01 = 0 Then $sResult = StringStripWS(StringRegExpReplace($sREResult1, $iColSrch, $iColNew, $iCount), 8) EndIf If $change_color01 <> 0 and $change_color02 <> 0 Then ; Replace "0x" prefix and set modified data back to DLL structure, $v_BufferA=$tPixel DllStructSetData($tPixel, 1, "0x" & $sResult) EndIf ;_GDIPlus_BitmapUnlockBits($g_hBitmap, $tBitmapData) ; xia truoc Dispose ;_GDIPlus_BitmapDispose($g_hBitmap) ; bi loi tang memory size ;FileDelete("c:\acc\0_MEO_D01_2.jpg") ;_GDIPlus_ImageSaveToFile($BMP, "c:\acc\0_MEO_D01_2.jpg") ; _WinAPI_DeleteObject($hBitmap) ko save duoc ; end change color = StringRegExpReplace($hImage, $iColSrch, $iColNew, $iCount) ;ClipGet($iScan0) ;MsgBox(0, "Time Elapsed: " & $tPixel, $iScan0) Local $stream_var[18] = [$hBMP, $Scan0, $tPixel, $g_hBitmap, $tBitmapData, $hWnd, $hDDC, $hCDC, $iWidth, $iHeight, $g_x0, $g_y0 &@CRLF& _ ""] ;$x01 = 555 ;$y01 = 394 ;$iRowOffset = $y01 * $iWidth+1 ; $iRowOffset = $iY * $iWidth + 1 ;$acolor01 = Hex(DllStructGetData($stream_var[2], 1, $iRowOffset + $x01),6) ;get pixel color ;MsgBox("","check","01 = "&$acolor01&" 02 = "&$acolor01,0) ; Local $stream_var[0] = $hBMP ; Local $stream_var[1] = $iScan0 ; Local $stream_var[2] = $tPixel ; Local $stream_var[3] = $BMP > $g_hBitmap ; Local $stream_var[4] = $tBitmapData ; Local $stream_var[5] = $WinHandle ; Local $stream_var[6] = $hDDC ; Local $stream_var[7] = $hCDC ; Local $stream_var[8] = $iWidth ; Local $stream_var[9] = $iHeight ; Local $stream_var[10] = $g_x0 ; Local $stream_var[11] = $g_y0 Return $stream_var EndFunc ;==>_WinCapture01 Func WinCapture_ce02($BMP, $tBitmapData, $WinHandle,$hDDC, $hCDC, $hBMP) _GDIPlus_BitmapUnlockBits($BMP, $tBitmapData) ;unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits all dell image _GDIPlus_ImageDispose($BMP) _WinAPI_ReleaseDC($WinHandle, $hDDC) _WinAPI_DeleteDC($hCDC) _WinAPI_DeleteObject($hBMP) ;cleanup resources ; _GDIPlus_ImageDispose($hImage) ;_GDIPlus_GraphicsDispose($hContext) ;_GDIPlus_BitmapDispose($hBitmap) ; _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>_GetColor Func ASM64_pixel05run($tCodeBuffer0="_DllStructCreate64", $address_pixel0=0x0, $address_check0=0x0, $address_loop0=10, $op_code00="90909090", $max0=1) Local $iResult[10] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] $check_color01 = 0 ;$tCodeBuffer = _DllStructCreate64("byte ASM[255]") ;$op_code00 = "57 56 53 55 48 8B F1 48 8B FA 49 8B D8 48 8B 06 C7 07 21 33 21 33 48 89 5F 04 48 83 EB 01 77 F0 5D 5B 5E 5F C3" ;$op_code00 = "57 56 53 55 48 8B F1 48 8B FA 49 8B D8 48 8B 06 80 3E 70 72 1A 90 90 90 90 75 14 90 90 90 90 80 3E 90 77 0B 90 90 90 90 C7 46 08 21 33 21 33 48 83 EB 01 77 DB 5D 5B 5E 5F C3" $op_code00 = StringReplace($op_code00, " ", "") $tCodeBuffer0.ASM = "0x"&$op_code00 _MemoryWrite64($address_check0+0x0, $procHwnd_autoit01, ptr(0),'byte[256]') ; reset value = 0 DllCallAddress("uint:cdecl", DllStructGetPtr($tCodeBuffer0), "ptr", $address_pixel0, "ptr", $address_check0, "int", $address_loop0) ;If $Sleep0on = 1 Then Sleep(1) ;$get_data0 = _MemoryRead64($address_check0+0x10, $procHwnd_autoit01,'byte[4]', "Dec") ; type = ( byte, float, dword, char[], byte[] ... etc ) $get_data0x = _MemoryRead64($address_check0+0x8, $procHwnd_autoit01,'byte[4]', "Dec") ; type = ( byte, float, dword, char[], byte[] ... etc ) $get_data0y = _MemoryRead64($address_check0+0xC, $procHwnd_autoit01,'byte[4]', "Dec") ; type = ( byte, float, dword, char[], byte[] ... etc ) $xy_split01num = 0 $xy_split01 = "" Local $g_all_color01[11] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] For $lp = 1 to $max0 $get_data0 = _MemoryRead64($address_check0+0x0+0x10*$lp, $procHwnd_autoit01,'byte[8]',"dec") ; type = ( byte, float, dword, char[], byte[] ... etc ) If $get_data0 <> 0 Then ;$get_data0 = _MemoryRead64($address_check0+0x0+0x10*$lp, $procHwnd_autoit01,'byte[8]',"dec") ; type = ( byte, float, dword, char[], byte[] ... etc ) ;ConsoleWrite($get_data01x&@CRLF) ;ClipPut($get_data0x) $g_all_color01[$lp] = $get_data0 $xy_split01num += 1 EndIf Next ;If $get_data0 > 0 Then $check_color01 = $get_data0 $iResult[0] = $check_color01 $iResult[1] = $address_loop0 $iResult[2] = DllStructGetPtr($tCodeBuffer0) $iResult[3] = $address_pixel0 $iResult[4] = $address_check0 $iResult[5] = $get_data0x $iResult[6] = $get_data0y Return $g_all_color01 ;push rdi ;push rsi ;push rbx ;push rbp ;mov rsi,rcx // ;pointer to first pixel in memory from the bmp > address check $tPixelData ;mov rdi,rdx // ;pointer to memory from struct > address save $tStruct_ARGB ;mov rbx,r8 // ;amount of pixels > max pixel $iPixels ;mov rax,[rsi] // address pixel memory xy ;//loop1: ;mov [rdi],33213321 ;//sub rbx,02 // for loop -2 ;//ja loop1 ;pop rbp ;pop rbx ;pop rsi ;pop rdi ;ret EndFunc ;==>ASM64_BitmapGetAverageColor Func asm_pixel05($a_opcode_num,$on=1,$iScan0="$stream[1]", $iWidth0=999, $iHeight0=999, $r0=20, $xr0=2, $yr0=2, $count_color0=1, $xr1=0, $yr1=0, $max0=1, $x1=0, $y1=0, $c1="506070", $x2=0, $y2=0, $c2="506070", $x3=0, $y3=0, $c3="506070", $x4=0, $y4=0, $c4="506070", $x5=0, $y5=0, $c5="506070", $x6=0, $y6=0, $c6="506070", $x7=0, $y7=0, $c7="506070", $x8=0, $y8=0, $c8="506070", $x9=0, $y9=0, $c9="506070", $x10=0, $y10=0, $c10="506070") Local $return[11] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] $address01check = _MemoryRead6401_fix($iScan0, $procHwnd_autoit01,'byte[8]') ; type = ( byte, float, dword, char[], byte[] ... etc ) $address01check = Dec(Hex($address01check,16)) ;MsgBox(0, "Test", "N"&$address01check) If $address01check = 0x0 Then $on=0 If $on=1 Then $vtmem_ASM64_pixel01 = $vtmem_autoitX+0x1000 ; 0x1000 $x_min = $x1-$xr1 $y_min = $y1-$yr1 $x_max = $x1+$xr1 $y_max = $y1+$yr1 If $a_op_code[$a_opcode_num] = "" Then If $max0 = 1 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1) If $max0 = 2 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2) If $max0 = 3 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2, $x3,$y3,$c3) If $max0 = 4 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2, $x3,$y3,$c3, $x4,$y4,$c4) If $max0 = 5 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2, $x3,$y3,$c3, $x4,$y4,$c4, $x5,$y5,$c5) If $max0 = 6 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2, $x3,$y3,$c3, $x4,$y4,$c4, $x5,$y5,$c5, $x6,$y6,$c6) If $max0 = 7 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2, $x3,$y3,$c3, $x4,$y4,$c4, $x5,$y5,$c5, $x6,$y6,$c6, $x7,$y7,$c7) If $max0 = 8 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2, $x3,$y3,$c3, $x4,$y4,$c4, $x5,$y5,$c5, $x6,$y6,$c6, $x7,$y7,$c7, $x8,$y8,$c8) If $max0 = 9 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2, $x3,$y3,$c3, $x4,$y4,$c4, $x5,$y5,$c5, $x6,$y6,$c6, $x7,$y7,$c7, $x8,$y8,$c8, $x9,$y9,$c9) If $max0 = 10 Then $op_code00 = ASM64_pixel05($iScan0,$iWidth0,$iHeight0,$r0,$xr0,$yr0,$count_color0,$xr1,$yr1, $x1,$y1,$c1, $x2,$y2,$c2, $x3,$y3,$c3, $x4,$y4,$c4, $x5,$y5,$c5, $x6,$y6,$c6, $x7,$y7,$c7, $x8,$y8,$c8, $x9,$y9,$c9, $x10,$y10,$c10) $a_op_code[$a_opcode_num] = $op_code00 ElseIf $a_op_code[$a_opcode_num] <> "" Then $op_code00 = $a_op_code[$a_opcode_num] EndIf $x_count01 = Int( ($x_max-$x_min)/$xr0 ) $y_count01 = Int( ($y_max-$y_min)/$yr0 ) $iRowOffset = ($y_min+0) * $iWidth0+1 ; $iRowOffset = $iY * $iWidth + 1 $iRowOffset02 = "0x"&Hex(($iRowOffset + $x_min+0)*4) Local $iResult = ASM64_pixel05run($tCodeBuffer, $iScan0+$iRowOffset02, "0x"&Hex($vtmem_ASM64_pixel01,16),$x_count01*$y_count01, $op_code00,$max0) Return $iResult ElseIf $on=0 Then Return $return EndIf EndFunc Func ASM64_pixel05($iScan0="$stream[1]", $iWidth=999, $iHeight=999, $r0=20, $xr0=1, $yr0=1, $count_color0=1, $xr1=0, $yr1=0, $x1=0, $y1=0, $c1="506070", $x2=0, $y2=0, $c2="506070", $x3=0, $y3=0, $c3="506070", $x4=0, $y4=0, $c4="506070", $x5=0, $y5=0, $c5="506070", $x6=0, $y6=0, $c6="506070", $x7=0, $y7=0, $c7="506070", $x8=0, $y8=0, $c8="506070", $x9=0, $y9=0, $c9="506070", $x10=0, $y10=0, $c10="506070") $loop0 = Hex($count_color0-1,2) ; "FCFBE3" ;ConsoleWrite(" ms" & @CRLF&$FF0000min&@CRLF&$FF0000max&@CRLF&$00FF00min&@CRLF&$00FF00max&@CRLF&$0000FFmin&@CRLF&$0000FFmax&@CRLF) ;$iRowOffset = ($y_min) * $iWidth+1 ; $iRowOffset = $iY * $iWidth + 1 ;$iRowOffset02 = _ReadF( ($iRowOffset + $x_min+0)*4 ,0) $op_code00 = "" ;push rdi ;push rsi ;push rbx ;push rbp ;mov rsi,rcx // ;pointer to first pixel in memory from the bmp > address check $tPixelData ;mov rdi,rdx // ;pointer to memory from struct > address save $tStruct_ARGB ;mov rbx,r8 // ;amount of pixels > max pixel $iPixels ;// mov rax,[rsi] // address pixel memory xy $op_code00 &= "57 56 53 55 48 8B F1 48 8B FA 49 8B D8" ;----------------------------------------------------------------------------------------------------------- for loop opcode If $x1 <> 0 Then $lpmax = 1 If $x2 <> 0 Then $lpmax = 2 If $x3 <> 0 Then $lpmax = 3 If $x4 <> 0 Then $lpmax = 4 If $x5 <> 0 Then $lpmax = 5 If $x6 <> 0 Then $lpmax = 6 If $x7 <> 0 Then $lpmax = 7 If $x8 <> 0 Then $lpmax = 8 If $x9 <> 0 Then $lpmax = 9 If $x10 <> 0 Then $lpmax = 10 For $lp1 = 1 to $lpmax If $lp1 = 1 Then $x0=$x1 $y0=$y1 $c0=$c1 ElseIf $lp1 = 2 Then $x0=$x2 $y0=$y2 $c0=$c2 ElseIf $lp1 = 3 Then $x0=$x3 $y0=$y3 $c0=$c3 ElseIf $lp1 = 4 Then $x0=$x4 $y0=$y4 $c0=$c4 ElseIf $lp1 = 5 Then $x0=$x5 $y0=$y5 $c0=$c5 ElseIf $lp1 = 6 Then $x0=$x6 $y0=$y6 $c0=$c6 ElseIf $lp1 = 7 Then $x0=$x7 $y0=$y7 $c0=$c7 ElseIf $lp1 = 8 Then $x0=$x8 $y0=$y8 $c0=$c8 ElseIf $lp1 = 9 Then $x0=$x9 $y0=$y9 $c0=$c9 ElseIf $lp1 = 10 Then $x0=$x10 $y0=$y10 $c0=$c10 EndIf $x0-=1 $y0-=1 ;mov [rdi+0],0 count x y pixel > RESET ;mov [rdi+8],0 count pixex x + 1 > RESET ;mov [rdi+C],0 count pixex y + 1 > RESET $op_code00 &= "C7 07 00 00 00 00 C7 47 08 00 00 00 00 C7 47 0C 00 00 00 00" $x_min = $x0-$xr1 $y_min = $y0-$yr1 $x_max = $x0+$xr1 $y_max = $y0+$yr1 $x_count01 = Int( ($x_max-$x_min)/$xr0 ) $y_count01 = Int( ($y_max-$y_min)/$yr0 ) Local $iRowOffset = ($y0+0) * $iWidth+1 ; $iRowOffset = $iY * $iWidth + 1 Local $iRowOffset02 = "0x"&Hex(($iRowOffset + $x0+0)*4) ;mov rax,1122334455667788 // address pixel memory xy rsi = default or address > ; > mov rsi,1122334455667788 ; mov rbx,25 for 1 to 25 $op_code00 &= "48 BE "& _ReadF( "0x"&Hex( $iScan0+$iRowOffset02 , 16) ,0) & " 48 BB "&Hex($x_count01*$y_count01,2)&" 00 00 00 00 00 00 00" ;// loop1: ;cmp byte ptr [rdi+10],0 // count pixel < 0+1 exit loop ;JA if_pixel01xy ;add [rdi+0],1 // 0 count pixel x y ;add [rdi+8],1 // count pixex x + 1 ;cmp byte ptr [rdi+0],4 // count pixel max x > 4-1 ;JB if_pixel01xy ; add rsi,999*1 // +999*1 = pixel y + 1 ; sub rsi,888*1 // -4*4 = pixel x - 4 > default x > 888*1 de lay 8 bytes ;mov [rdi+0],0 // reset count pixel x y ;add [rdi+C],1 // count pixex y + 1 ;if_pixel01xy: $y_asm = _ReadF( "0x"&Hex( ( ($iWidth+1)*4 )*$yr0 , 8) ,0) $x_asm = _ReadF( "0x"&Hex( ($x_max-$x_min)*4, 8) ,0) $rdi_10 = 0x10*$lp1 ;// [rdi+10] = count pixel color ; loop = 00 x + 1 get x + 1 count pixel max = 04 y + 99 09 00 00 x - 88 08 00 00 get y + 1 $op_code00 &= "80 7F "&Hex($rdi_10,2)&$loop0&" 77 2C 90 90 90 90 83 07 "&Hex($xr0,2)&" 83 47 08 "&Hex($xr0,2)&" 80 3F "&Hex($x_max-$x_min,2)&" 72 1C 90 90 90 90 48 81 C6 "&$y_asm&" 48 81 EE "&$x_asm&" C7 07 00 00 00 00 83 47 0C"&Hex($yr0,2) ;cmp byte ptr [rsi+0],77 // pixel xy Opt1 > Opt2 0xFF0000 0x70 ;JNAE if01 ;cmp byte ptr [rsi+0],99 // pixel xy Opt1 < Opt2 0xFF0000 0xFF ;JNBE if01 ;cmp byte ptr [rsi+1],77 // pixel xy Opt1 > Opt2 0x00FF00 0x70 ;JNAE if01 ;cmp byte ptr [rsi+1],99 // pixel xy Opt1 < Opt2 0x00FF00 0xFF ;JNBE if01 ;cmp byte ptr [rsi+2],77 // pixel xy Opt1 > Opt2 0x0000FF 0x70 ;JNAE if01 ;cmp byte ptr [rsi+2],99 // pixel xy Opt1 < Opt2 0x0000FF 0xFF ;JNBE if01 $return_c0 = ASM64_color01($c0, $r0) $FF0000min = $return_c0[0] $FF0000max = $return_c0[1] $00FF00min = $return_c0[2] $00FF00max = $return_c0[3] $0000FFmin = $return_c0[4] $0000FFmax = $return_c0[5] ; 77-3 99+3 77-3 99+3 77-3 99+3 $op_code00 &= "80 3E "&$FF0000min&" 72 54 90 90 90 90 80 3E "&$FF0000max&" 77 4B 90 90 90 90 80 7E 01 "&$00FF00min&" 72 41 90 90 90 90 80 7E 01 "&$00FF00max&" 77 37 90 90 90 90 80 7E 02 "&$0000FFmin&" 72 2D 90 90 90 90 80 7E 02 "&$0000FFmax&" 77 23 90 90 90 90" ;cmp byte ptr [rdi+10],0 // count pixel < 0+1 exit loop ;JA exit_loop01 ;add [rdi+10],1 // 0 count pixel find ;mov rax,[rsi+0] ;mov [rdi+14],rax // get color ;mov rbx,1 // exit loop ;exit_loop01: ; loop = 00 rbx = 01 exit loop > chinh lai ve 0 ;$op_code00 &= "80 7F 10 "&$loop0&" 77 19 90 90 90 90 83 47 10 01 48 8B 06 48 89 47 14 48 BB 01 00 00 00 00 00 00 00" $op_code00 &= "80 7F "&Hex($rdi_10,2)&$loop0&" 77 19 90 90 90 90 83 47 "&Hex($rdi_10,2)&" 01 80 7F"&Hex($rdi_10,2)&Hex($loop0+1,2)&" 72 0B 90 48 BB 01 00 00 00 00 00 00 00" ;if01: ;add rsi,4*1 // +4*1 = pixel x + 1 ;sub rbx,1 // for loop -1 = 0 exit loop ;JA loop1 ; x + 1 = 4*1 $op_code00 &= "48 83 C6 "&Hex(4*$xr0,2)&" 48 83 EB 01 0F 87 67 FF FF FF" ;// [rdi+8] > x 14 ;// [rdi+C] > y 3 ;// [rdi+0],4 // count pixel max = 4 ;// y3 * max 4 = 12 > x 14-12 > x = 2 y = 3 ;// [rdi+0] = count x y pixel ;// [rdi+8] = count pixex x + 1 ;// [rdi+C] = count pixex y + 1 ;// [rdi+10] = count pixel color ;// [rdi+14] = get pixel color Next ;----------------------------------------------------------------------------------------------------------- EndIf for loop opcode ; pop rbp ; pop rbx ; pop rsi ; pop rdi ; ret $op_code00 &= "5D 5B 5E 5F C3" Return $op_code00 EndFunc Func _MemoryRead6401_text_fix($ivAddress, $ahHandle, $sType = "dword", $value_type00="not_hex") ; type = ( byte, float, dword, char[], byte[] ... etc ) If Not IsArray($ahHandle) Then SetError(1, 0, False) Return 0 EndIf Local $vReadData = DllStructCreate("dword_ptr") ; hex > dec Local $vReadData01 = DllStructCreate($sType) ; hex array bytes Local $vNumberOfBytesRead = DllStructCreate("ulong_ptr lpNumberOfBytesRead") If @Error Then SetError(@Error + 1) Return 0 EndIf If Not @Error Then Local $ahCall = DllCall($ahHandle[0], "bool", "ReadProcessMemory", _ "handle", $ahHandle[1], _ "dword_ptr", $ivAddress, _ "ptr", DllStructGetPtr($vReadData01), _ "ulong_ptr", DllStructGetSize($vReadData01), _ "ptr", DllStructGetPtr($vNumberOfBytesRead)) ;ConsoleWrite(DllStructGetData($vNumberOfBytesRead, "lpNumberOfBytesRead") & @CRLF & DllStructGetSize($vReadData01) & @CRLF) If (Not $ahCall[0]) Or (DllStructGetData($vNumberOfBytesRead, "lpNumberOfBytesRead") <> DllStructGetSize($vReadData01)) Then SetError(2, 0, False) ;Return False EndIf If $value_type00 <> "Hex" Then Local $DllStructGetData_fix01 = DllStructGetData($vReadData01, 1) If StringInStr($sType, 'wchar') > 0 Then $DllStructGetData_fix01 = StringRegExpReplace($DllStructGetData_fix01, "[^\x20-\x7E]", "") ; giữ lại ký tự ASCII printable Return $DllStructGetData_fix01 EndIf If $value_type00 = "Hex" Then Return Hex("0x"&(DllStructGetData($vReadData01, 1))) EndIf EndFunc ;==>_Process_ReadMemory Func _MemoryRead6401($ivAddress, $ahHandle, $sType = "dword", $value_type00="not_hex") ; type = ( byte, float, dword, char[], byte[] ... etc ) If Not IsArray($ahHandle) Then SetError(1, 0, False) Return 0 EndIf ; TỐI ƯU 1: Bỏ hẳn cái Struct $vReadData (dword_ptr) cũ vì trong hàm này bạn chỉ dùng $vReadData01 để hứng dữ liệu. Local $vReadData01 = DllStructCreate($sType) Local $vReadSize = DllStructGetSize($vReadData01) ; TỐI ƯU 2: Bỏ luôn Struct $vNumberOfBytesRead. Truyền thẳng Ptr(0) (NULL) vào tham số cuối của DllCall. ; Điều này giúp Windows API bỏ qua khâu đếm byte, AutoIt không phải cấp phát RAM liên tục nữa. Local $ahCall = DllCall($ahHandle[0], "bool", "ReadProcessMemory", _ "handle", $ahHandle[1], _ "dword_ptr", $ivAddress, _ "ptr", DllStructGetPtr($vReadData01), _ "ulong_ptr", $vReadSize, _ "ptr", Ptr(0)) ; Chỉ check xem hàm API của Windows có gọi thành công không If (Not $ahCall[0]) Then SetError(2, 0, False) Return 0 ; Hoặc Return False tùy bạn, bản gốc của bạn đang để Return 0 ở đầu hàm EndIf ; Trả về dữ liệu chuẩn (Giữ nguyên gốc, không can thiệp Regex để an toàn cho dword, float, byte...) If $value_type00 <> "Hex" Then Return DllStructGetData($vReadData01, 1) Return Hex("0x" & (DllStructGetData($vReadData01, 1))) EndFunc ;==>_Process_ReadMemory Func _FloatToHex($floatval) $sF = DllStructCreate("float") $sB = DllStructCreate("ptr", DllStructGetPtr($sF)) If $floatval = "" Then Exit DllStructSetData($sF, 1, $floatval) $return=DllStructGetData($sB, 1) Return $return EndFunc Func IntToFlt($iVal) Local $result $fs = DllStructCreate("float") $is = DllStructCreate("int64",DllStructGetPtr($fs)) DllStructSetData($is,1,$iVal) $result = DllStructGetData($fs,1) $fs = 0 $is = 0 return $result endfunc Func ASM64_opcode01vtmem($bytes0="102400") Local $tCodeBuffer = _DllStructCreate64("byte ASM["&$bytes0&"]") Return $tCodeBuffer EndFunc Func _DllStructCreate64($struct) ;align auf 16-byte adresse Local $temp = DllStructCreate($struct) Local $tempsize = DllStructGetSize($temp) + 64 Local $ptr = DllStructGetPtr($struct) Local $a1 = Mod(Number($ptr), 64) Local $temp = 0 Local $mem = _MemVirtualAlloc($ptr + $a1, $tempsize, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Local $a2 = Mod(Number($mem), 64) ;rest div 16 adresse = offset Local $sstruct = DllStructCreate($struct, (Number($mem) - $a2 + 64)) Return $sstruct ;auf 16 alingned pointer EndFunc ;==>_DllStructCreate64_2 Func ASM64_color01($c0="506070",$r0=20) Local $return[10] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] $FF0000 = Dec(StringMid($c0, 5, 2)) $00FF00 = Dec(StringMid($c0, 3, 2)) $0000FF = Dec(StringMid($c0, 1, 2)) $FF0000min = $FF0000-$r0 If $FF0000min < 0 Then $FF0000min = 0 $FF0000min = Hex($FF0000min,2) Else $FF0000min = Hex($FF0000min,2) EndIf $FF0000max = $FF0000+$r0 If $FF0000max > 255 Then $FF0000max = 255 $FF0000max = Hex($FF0000max,2) Else $FF0000max = Hex($FF0000max,2) EndIf $00FF00min = $00FF00-$r0 If $00FF00min < 0 Then $00FF00min = 0 $00FF00min = Hex($00FF00min,2) Else $00FF00min = Hex($00FF00min,2) EndIf $00FF00max = $00FF00+$r0 If $00FF00max > 255 Then $00FF00max = 255 $00FF00max = Hex($00FF00max,2) Else $00FF00max = Hex($00FF00max,2) EndIf $0000FFmin = $0000FF-$r0 If $0000FFmin < 0 Then $0000FFmin = 0 $0000FFmin = Hex($0000FFmin,2) Else $0000FFmin = Hex($0000FFmin,2) EndIf $0000FFmax = $0000FF+$r0 If $0000FFmax > 255 Then $0000FFmax = 255 $0000FFmax = Hex($0000FFmax,2) Else $0000FFmax = Hex($0000FFmax,2) EndIf ; "FCFBE3" ;ConsoleWrite(" ms" & @CRLF&$FF0000min&@CRLF&$FF0000max&@CRLF&$00FF00min&@CRLF&$00FF00max&@CRLF&$0000FFmin&@CRLF&$0000FFmax&@CRLF) $return[0] = $FF0000min $return[1] = $FF0000max $return[2] = $00FF00min $return[3] = $00FF00max $return[4] = $0000FFmin $return[5] = $0000FFmax Return $return EndFunc Func Distance( $x1, $y1, $x2, $y2 ) ; PlayerX, PlayerY, EnemyX, EnemyY $dist = sqrt( ( $x2 - $x1 ) ^ 2 + ( $y2 - $y1 ) ^ 2 ) Return $dist EndFunc Func rad2Deg($rad) $Pi = 4 * ATan(1) return ($rad*180/$Pi) EndFunc Func Rotation($x1,$y1,$x2,$y2) ; PlayerX, PlayerY, EnemyX, EnemyY $Pi = 4 * ATan(1) if (($x2 - $x1 ) == 0) Then If ($y2 > $y1) Then $radian = 0 Else $radian = $Pi EndIf Else If ($x2 > $x1) Then $radian = $Pi/2 - aTan(($y2 - $y1)/($x2 - $x1)) Else $radian = $Pi*1.5 - aTan(($y2 - $y1)/($x2 - $x1)) EndIf EndIf Return rad2Deg($radian) EndFunc ;$chrome_website01 = all_cuaso03("Google Chrome") ;MsgBox($MB_SYSTEMMODAL, "", "Title: " & $chrome_website01[0] & @CRLF & "Handle: " & $chrome_website01[1]) Func all_cuaso03($title1="Google Chrome", $title2="not title") ; Retrieve a list of window handles. Local $aList = WinList() Local $title[2] = ["",""] For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then $find_title01 = StringInStr($aList[$i][0], $title1) $find_title02 = StringInStr($aList[$i][0], $title2) If $find_title01 > 0 and $find_title02 < 0+1 then ; find title chrome ; If $aList[$i][0] = $m4_cuaso01[1] Then ; $win_count01 += 1 ; $cuaso[$win_count01] = $aList[$i][1] ; EndIf ; MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1]) $title[0] = $aList[$i][0] $title[1] = $aList[$i][1] EndIf ; end find title chrome EndIf Next Return $title EndFunc Func _MemoryRead64_fix($ivAddress, $ahHandle, $sType = "dword", $value_type00="Hex") If Not IsArray($ahHandle) Then Return SetError(1, 0, False) ; Sử dụng luôn cấu trúc dữ liệu tương ứng để hứng, tránh tạo trùng lặp Local $vReadData = $gh_vReadDataPtr Local $vReadSize = 8 ; Mặc định đọc Pointer là 8 bytes (dword_ptr) If $value_type00 = "Array" Then $vReadData = DllStructCreate($sType) $vReadSize = DllStructGetSize($vReadData) Else ; Nếu truyền sType tùy biến khác, tính lại size chuẩn xác để tránh tràn bộ đệm Local $tTmp = DllStructCreate($sType) $vReadSize = DllStructGetSize($tTmp) EndIf ; TỐI ƯU CHÍ MẠNG: Truyền Ptr(0) vào tham số cuối (lpNumberOfBytesRead) để Windows API bỏ qua khâu đếm byte, nhẹ CPU hơn hẳn Local $ahCall = DllCall($ahHandle[0], "bool", "ReadProcessMemory", _ "handle", $ahHandle[1], _ "dword_ptr", $ivAddress, _ "ptr", DllStructGetPtr($vReadData), _ "ulong_ptr", $vReadSize, _ "ptr", Ptr(0)) If (Not $ahCall[0]) Then Return SetError(2, 0, False) If $value_type00 <> "Hex" Then Return DllStructGetData($vReadData, 1) Return Hex("0x" & (DllStructGetData($vReadData, 1))) EndFunc Func _MemoryRead6401_fix($ivAddress, $ahHandle, $sType = "dword", $value_type00="not_hex") If Not IsArray($ahHandle) Then Return SetError(1, 0, 0) Local $vReadData01 = DllStructCreate($sType) Local $vReadSize = DllStructGetSize($vReadData01) Local $ahCall = DllCall($ahHandle[0], "bool", "ReadProcessMemory", _ "handle", $ahHandle[1], _ "dword_ptr", $ivAddress, _ "ptr", DllStructGetPtr($vReadData01), _ "ulong_ptr", $vReadSize, _ "ptr", Ptr(0)) If (Not $ahCall[0]) Then Return SetError(2, 0, False) If $value_type00 <> "Hex" Then Local $DllStructGetData_fix01 = DllStructGetData($vReadData01, 1) ; CHÊU TRÒ PRO: Thay vì Replace (quét xóa rác), ta dùng Match (chỉ bốc chữ sạch) If $DllStructGetData_fix01 <> "" And StringInStr($sType, 'wchar') > 0 Then ; Quét lấy chuỗi ký tự hợp lệ liên tục đầu tiên, gặp ký tự rác hoặc null là dừng luôn Local $aMatch = StringRegExp($DllStructGetData_fix01, '^([\x20-\x7E]+)', 1) If UBound($aMatch) > 0 Then Return $aMatch[0] Else Return "" ; Nếu toàn bộ là rác dị giáo thì trả về rỗng luôn cho an toàn EndIf EndIf Return $DllStructGetData_fix01 EndIf Return Hex("0x" & (DllStructGetData($vReadData01, 1))) EndFunc