标签:
XP游戏,扫描内存,然后模拟鼠标点击
Private Sub Command1_Click() Dim lhwnd As Long Dim lpid As Long Dim lRet As Long Dim lhProcess As Long Dim bData(1024) As Byte Dim bXY(8) As Byte Dim x As Long Dim y As Long Dim temp As Long Dim k As Long ‘其中8F就表示雷,0F表示非雷,当非雷区被点击后如是1,则该地址会由0F 变成41 ;如是2 则变为42, ‘每行32个数据,从每一行最开始到10之间的数据为有效数据 ‘例如9*9的扫雷一行数据为:16 15 15 66 65 64 64 65 143 15 16 lhwnd = FindWindow(vbNullString, "扫雷") If lhwnd = 0 Then MsgBox "请先打开Windows自带扫雷游戏" Exit Sub End If lRet = GetWindowThreadProcessId(lhwnd, lpid) lhProcess = OpenProcess(16, False, lpid) lRet = ReadProcessMemory(lhProcess, ByVal 16798560, bData(0), 1024, 0) lRet = ReadProcessMemory(lhProcess, ByVal 16798516, bXY(0), 8, 0) For y = 0 To bXY(4) - 1 For x = 1 To bXY(0) temp = bData(x + y * 32) If temp < 0 Then temp = 256 + temp End If k = lng坐标合并(20, 60) + lng坐标合并(16 * (x - 1), 16 * y) If temp <> 143 Then lRet = PostMessage(lhwnd, WM_LBUTTONDOWN, 0, k) lRet = PostMessage(lhwnd, WM_LBUTTONUP, 0, k) Debug.Print "*"; ‘打印地图矩阵,*为安全,@为雷 Else Debug.Print "@"; End If Next x Debug.Print Next y CloseHandle lhProcess End Sub Private Function lng坐标合并(x As Long, y As Long) As Long lng坐标合并 = x + y * 65536 End Function
标签:
原文地址:http://www.cnblogs.com/tinker/p/5766781.html