码迷,mamicode.com
首页 > 其他好文 > 详细

VB一键扫雷

时间:2016-08-12 23:43:33      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

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

VB一键扫雷

标签:

原文地址:http://www.cnblogs.com/tinker/p/5766781.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!