Option Explicit
' By音符,QQ:337855632 Time:2020-03-17 功能定制:20元起
Const C_GameWith = 1024
Const C_GameHeight = 768
Const C_GameSmallWith = 320
Const C_GameSmallHeight = 240
Dim GamehWnd, dm, AppName, config
config = ".\Angel.ini"
AppName = "Angel_BP"
Function CmpMutlColor(Args, Sleep)
    Dim i
    For i = 0 To UBound(Args)
        CmpMutlColor = (dm.CmpColor(Args(i)(0), Args(i)(1), Args(i)(2), Args(i)(3)) = 0)
        If CmpMutlColor = False Then Exit For
        Api.Delay Sleep
    Next
End Function
Class ListView_Class
    Sub SetText(ByVal hWnd, ByVal x, ByVal y, ByVal m)
        Dim pszText, LVITEM
        pszText = Api.StrConv(m, 128)
        Set LVITEM = Api.Malloc(39)
        LVITEM.SetVal &H1, 0, 4
        LVITEM.SetVal x, 4, 4
        LVITEM.SetVal y, 8, 4
        Call LVITEM.SetVal(Api.StrPtr(pszText), 20, 4)  '控件不支持 W'
        Call Api.ECall("user32.dll", "SendMessageA", hWnd, &H1000 + 6, 0, LVITEM.GetPtr(0))
    End Sub
    Function GetText(ByVal hWnd, ByVal x, ByVal y)
        Dim pszText, LVITEM
        pszText = Space(100)
        Set LVITEM = Api.Malloc(39)
        LVITEM.SetVal y, 8, 4
        LVITEM.SetVal Len(pszText), 24, 4
        Call LVITEM.SetVal(Api.StrPtr(pszText), 20, 4)
        GetText = LeftB(pszText, Api.ECall("user32.dll", "SendMessageA", hWnd, &H1000 + 45, x, LVITEM.GetPtr(0)))
        GetText = Api.StrConv(GetText, &H40)
    End Function
End Class
Const C_WorkProgress = 3
Class QQSpeed_Class
    Public [局数], [位置]
    Private [防止休眠], [游戏大区], [开启截图], DownCpu, StartMode
    Private HIndex, WorkList, WorkIndex, ListView, ListhWnd(1), HNext
    Private Game, itime(3), StartTime, MarkTime, Angel, Vip, mFSO, picPath
    Private leave
    Public Function [准备游戏]()  '准备游戏'
        If dm.CmpColor(25, 5, "7C1601-111111", 0.9) = 0 Then
            Window.LeftClick GamehWnd, 30, 3  '开始游戏
            Api.Delay 500
        End If
    End Function
    Public Sub Start(Arys)
        Dim Stmp, i
        HIndex = Arys
        Set ListView = New ListView_Class
        ThreadEnter 1
        With Globals("Form")
            ListhWnd(0) = .Controls("ListView1").object.ListView.hWnd
            ListhWnd(1) = .Controls("ListView2").object.ListView.hWnd
            StartMode = .Controls("启动方式").ListIndex
            DownCpu = Int(.Controls("游戏降耗").text)
        End With
        WorkList = Globals("QQSpeed").Item(HIndex)
        Api.Include Globals("CString_Class"), , , , , JScript
        ThreadLeave 1
        If UBound(WorkList) = 0 Then
            Exit Sub
        End If
        WorkIndex = WorkList(0)(C_WorkProgress) + 1
        [局数] = WorkList(0)(C_WorkProgress + 2)
        Set CString = JScript.Eval("new CString_Class")
        Set dm = [创建大漠]()
        [游戏大区] = WorkList(0)(2)
        If Len([游戏大区]) = 0 Then [游戏大区] = "*"
        GamehWnd = WorkList(0)(C_WorkProgress + 1)
        If Api.ECall("user32", "IsWindow", GamehWnd) = False Then
            If StartMode = 1 Then
                Set Angel = CreateObject("QQSpeed.Angel")
                Call Angel.Init(Array(JScript, Window))
                Set Vip = Angel.Vip
                GamehWnd = Vip.GethWnd(WorkList(0)(0))
                If GamehWnd = 0 Then
                    GamehWnd = [自动上号](WorkList(0)(0), WorkList(0)(1), "自动上号")
                End If
            Else
                GamehWnd = Window.FindEx(0, "GAMEAPP", "QQ飞车*【" & [游戏大区] & "区】*【" & WorkList(0)(1) & "】*", 2)
            End If
        End If
        If GamehWnd = 0 Then Exit Sub
        If [调整窗口](GamehWnd) = False Then
            ListView.SetText ListhWnd(0), HIndex, 5, "分辨率错误"
            MsgBox "请手动设置分辨率:" & C_GameWith & " x " & C_GameHeight & "(桌面显示设置为100%)", 4096, "无法调整窗口分辨率!"
            Exit Sub
        End If
        Call [绑定窗口](GamehWnd)
        If InStr(File.ReadINI(AppName, "其他设置", config), "1防止休眠") Then [防止休眠] = 1
        Dim ws
        Set ws = CreateObject("WScript.Shell")
        picPath = ws.specialfolders("MyDocuments") & "\QQ飞车\" & WorkList(0)(0) & "\截图\"
        [开启截图] = InStr(File.ReadINI(AppName, "其他设置", config), "1自动截图")
        For i = WorkIndex To UBound(WorkList)
            WorkIndex = i
            Call SetTime(0, True)
            StartTime = Now()
            MarkTime = 0
            ListView.SetText ListhWnd(0), HIndex, 4, WorkList(i)(1)
            ListView.SetText ListhWnd(0), HIndex, 5, "换模式:" & [局数]
            If InStr("|边境模式|绝命车王|秘境闯关|互助接力赛|酷币大作战|双人冲锋战|超能竞速赛|狂野追逐|变身派对|极速对决|浪漫邂逅|双人冲顶赛|换车拉力赛|全城通缉令|超时空巨人赛|", "|" & WorkList(i)(1) & "|") Then
                Set Game = Eval("New [QQSpeed_" & WorkList(i)(1) & "]")
                Set Game.Father = Me
                Call Game.GuaJi
            Else
                Set Game = Eval("New [QQSpeed_" & "多功能" & "]")
            End If
            [局数] = 0
        Next
        HNext = True
    End Sub
    Public Function [调整窗口](hWnd)  '调整窗口'
        Dim x1, y1, x2, y2
        Dim i
        Window.Restore hWnd
        Window.Active hWnd
        Api.Delay 500
        For i = 0 To 15
            Call Window.GetClientRect(hWnd, x1, y1, x2, y2)
            If x2 = C_GameSmallWith And y2 = C_GameSmallHeight Then
                [调整窗口] = True
                Exit Function
            ElseIf x2 <> C_GameWith Or y2 <> C_GameHeight Then
                Window.KeyPress hWnd, 119
                Api.Delay 800
            Else
                [调整窗口] = True
                Exit Function
            End If
        Next
    End Function
    Private Function [创建大漠]()
        Set [创建大漠] = CreateObject("dm.dmsoft")
        [创建大漠].SetShowErrorMsg 0
    End Function
    Private Sub [绑定窗口](hWnd)
        Dim i, iLeft, iTop, ScreenWidth, ScreenHeight, HeightCount, WidthCount
        i = File.ReadINI(AppName, "窗口排列.ListIndex", config, 0)
        ScreenWidth = Api.ECall("user32", "GetSystemMetrics", 0)
        ScreenHeight = Api.ECall("user32", "GetSystemMetrics", 1)
        If i = 0 Or i = 3 Then
            iTop = 50
            HeightCount = (ScreenHeight - C_GameSmallHeight + iTop) \ iTop
        Else
            iTop = C_GameSmallHeight
            HeightCount = ScreenHeight \ iTop
        End If
        If i = 2 Or i = 5 Then
            WidthCount = ScreenWidth \ C_GameSmallWith
            iLeft = (HIndex Mod WidthCount) * C_GameSmallWith
            iTop = (HIndex \ WidthCount) * C_GameSmallHeight
        Else
            iLeft = (HIndex \ HeightCount) * C_GameSmallWith
            iTop = (HIndex Mod HeightCount) * iTop
        End If
        iLeft = IIf(i >= 3, ScreenWidth - C_GameSmallWith + 5 - iLeft, -5 + iLeft)
        If iLeft > ScreenWidth Then
             iLeft = -5
        ElseIf iLeft < -C_GameSmallWith Then
            iLeft = ScreenWidth - C_GameSmallWith + 5
        End If
        If iTop > ScreenHeight Then iTop = 0
        Window.SetStyle hWnd, 128
        Window.Size hWnd, C_GameWith, C_GameHeight
        Window.ClientMove hWnd, iLeft, iTop, C_GameSmallWith, C_GameSmallHeight
        Api.Delay 100
        i = dm.BindWindowEx(hWnd, "dx2", "windows", "windows", "dx.public.disable.window.size", 0)
        Api.Delay 200
        If DownCpu Then dm.DownCpu DownCpu
    End Sub
    Public Function [自动开箱](Count, IntX, IntY, Margin, Args)
        Dim i
        For i = Count To 0 Step -1  '开宝箱'
            Window.LeftClick GamehWnd, IntX - i * Margin, IntY
            Api.Delay 300
            If Eval(Args(0)) Then
                Call [自动截图]("FFFFFF-555555", 100, 88, 220, 158)
                If UBound(Args) Then ExeCute Args(1)
            End If
            If UBound(Args) > 1 Then ExeCute Args(2)
        Next
    End Function
    Public Function [自动截图](Color, x1, y1, x2, y2)
        Dim Save, img, pic, IntX, IntY
        If [开启截图] Then
            Save = ".\截图\"
            pic = [获取文件]()
            If pic = "" Then Exit Function
            Set img = mFSO.GetFile(pic & ".jpg")
            With [创建大漠]()
                IntX = C_GameWith / C_GameSmallWith
                IntY = C_GameHeight / C_GameSmallHeight
                .SetDisplayInput "pic:" & pic & ".bmp"
                .AddDict 0, "084110A4171A037FD080280882080100000208421184E10440B0198008008008$永久$0.0.58$11"
                If .FindStrFast(x1 * IntX, y1 * IntY, x2 * IntX, y2 * IntY, "永久", Color, 0.9, IntX, IntY) >= 0 Then
                    If Not mFSO.FolderExists(Save) Then mFSO.CreateFolder Save
                    img.Copy Save & WorkList(0)(0) & "_" & Api.Format(Now, "yyyy-mm-dd h.mm.ss") & ".jpg"
                End If
                .FreePic (pic & ".bmp")
            End With
            mFSO.DeleteFile pic & ".bmp"
            'img.Delete
            Call dm.Capture(0, 0, C_GameSmallWith, C_GameSmallHeight, pic & "screen.bmp")
        End If
    End Function
    Private Function [获取文件]()
        Dim i, j, t, path
        Window.KeyPress GamehWnd, 115
        t = Now()
        Api.Delay 200
        For i = 0 To 10
            j = i Mod 2
            If j = 0 Then Api.Delay 200
            path = picPath & Api.Format(DateAdd("s", -j, t), "yyyymmdd_hhmmss")
            If mFSO.FileExists(path & ".jpg") Then
                [获取文件] = path
                Exit For
            End If
        Next
        If [获取文件] = "" Then Exit Function
        For i = 0 To 10
            If dm.ImageToBmp(path & ".jpg", path & ".bmp") Then
            ' If Not File.IsLock(Path) Then
                Exit For
            End If
            Api.Delay 200
        Next
        If i = 11 Then [获取文件] = ""
    End Function

    Private Function [上号判断](hWnd, Message)
        Dim i, hWnds, hWndE
        hWnds = Window.EnumWindows(0, "#32770", "QQ安全中心", 32)
        For i = 0 To UBound(hWnds)
            If Vip.IsSameWindow(hWnds(i), hWnd) Then
                If UBound(Window.EnumWindowsEx(hWnds(i), "Static", "密码验证错误", 32)) >= 0 Then
                    Message = "密码错误"
                    WorkList(0)(C_WorkProgress + 3) = &H10000 * 3
                    [上号判断] = True
                    Exit Function
                ElseIf UBound(Window.EnumWindowsEx(hWnds(i), "Static", "*验证码*", 2 + 32)) >= 0 Then
                    Message = "验证码"
                    If InStr(File.ReadINI(AppName, "其他设置", config), "1自动滑块") Then
                        Call Angel.Slider(hWnds(i))
                    End If
                End If
            End If
        Next
        hWnds = Window.EnumWindows(0, "#32770", "提示", 32)
        For i = 0 To UBound(hWnds)
            If Vip.IsSameWindow(hWnds(i), hWnd) Then
                hWndE = Window.FindEx(hWnds(i), "maqHyperTextCtrl", 0, 32)
                If hWndE Then
                    Message = Angel.GetWindowText(hWndE)
                    If InStr(Message, "网络环境") = 0 Then
                        WorkList(0)(C_WorkProgress + 3) = &H10000 * 2
                    End If
                Else
                    Message = "网络环境异常"
                End If
                [上号判断] = True
            End If
        Next
    End Function
    Private Function [自动上号](QQ, Pwd, Message)
        Dim i, Count, TryMax, hWnds, hWnd, Wait, path, ID
        Wait = File.ReadINI(AppName, "上号间隔.text", config, 50)
        If File.ReadINI(AppName, "登录重试.Value", config, 1) Then
            TryMax = File.ReadINI(AppName, "登录重试T.text", config, 3)
        End If
        If InStr(File.ReadINI(AppName, "其他设置", config), "1飞车路径") Then
            path = File.ReadINI(AppName, "飞车路径", config)
        End If
        Do
            Count = Count + 1
            ListView.SetText ListhWnd(0), HIndex, 4, Message & " " & Count
            ThreadEnter 3 '线程锁
            Api.Delay 100
            hWnds = Window.EnumWindows(0, "#32770", "QQ飞车", 32)
            For i = 0 To UBound(hWnds)
                dm.SetWindowState hWnds(i), 0
            Next
            i = InStr("电信联通电信2", [游戏大区]) - 1
            ID = Window.GetInfo(Vip.QQSpeedLogin(QQ, Pwd, Int(i / 2), , , path), 3)
            Api.Delay 1000
            hWnds = Vip.EnumWindows("#32770", "QQ飞车", "330-100", "220-100")
            If UBound(hWnds) >= 0 Then dm.SetWindowText hWnds(0), "QQ飞车" & QQ
            ThreadLeave 3
            For i = 0 To Wait
                hWnd = Window.Find("#32770", "QQ飞车" & QQ)
                If hWnd Then
                    Api.Delay 1000
                    If [上号判断](hWnd, Message) Then
                        i = 999
                        dm.SetWindowState hWnd, 13
                        Exit For
                    End If
                Else
                    Exit Do
                End If
            Next
            If i > Wait Then
                dm.SetWindowState hWnd, 0
                Api.Delay 200
                dm.SetWindowState hWnd, 13
            End If
        Loop While Count < TryMax
        If i > Wait Then
            ListView.SetText ListhWnd(0), HIndex, 4, Message
        ElseIf StartMode Then
            [自动上号] = Vip.GethWnd(QQ)
            If [自动上号] = 0 Then  '不支持热启动
                [自动上号] = Vip.GethWndByID(ID)
            End If
            WorkList(0)(C_WorkProgress + 1) = [自动上号]
        Else
            [自动上号] = Window.FindEx(0, "GAMEAPP", "QQ飞车*【" & [游戏大区] & "区】*【" & WorkList(0)(1) & "】*", 2)
        End If
        ThreadEnter 2
        File.WriteText ".\上号日志.txt", "上号时间:" & Now & String(3, vbTab) & "模式:" & WorkList(WorkIndex)(1) & String(3, vbTab) & "第" & HIndex + 1 & "个号:" & IIf(StartMode, WorkList(0)(0), WorkList(0)(1)) & _
        String(3, vbTab) & "局数:" & [局数] & String(3, vbTab) & IIf([自动上号], "【成功】", "【失败】" & Message) & vbCrLf & vbCrLf, True
        ThreadLeave 2
        Api.Delay 1000
        If [自动上号] = 0 Then
            WorkList(0)(C_WorkProgress + 3) = WorkList(0)(C_WorkProgress + 3) Or 2
            Api.StopThread -1
        End If
    End Function
    Private Function [掉线重连]()
        Dim Wait
        dm.SetWindowState GamehWnd, 13
        If File.ReadINI(AppName, "上号延时.Value", config, 1) Then
            Wait = File.ReadINI(AppName, "上号延时T.text", config, 5)
        End If
        Api.Delay Wait * 1000
        GamehWnd = [自动上号](WorkList(0)(0), WorkList(0)(1), "掉线重连")
        If GamehWnd = 0 Then Exit Function
        If [调整窗口](GamehWnd) = False Then
            ListView.SetText ListhWnd(0), HIndex, 5, "分辨率错误"
            Exit Function
        End If
        Call [绑定窗口](GamehWnd)
        [掉线重连] = True
    End Function
    Public Sub [完成一局](Sleep)
        [局数] = [局数] + 1
        Api.Delay Sleep
        ListView.SetText ListhWnd(0), HIndex, 5, "已完成:" & [局数]
    End Sub
    Public Sub [清理弹窗](Mode)
        Dim IntX, IntY
        If CBool(State([位置])) And CBool(mode And 2) = False Then  '清理 黑屏
            Window.KeyUp GamehWnd, 18
            If dm.FindColor(281, 36, 292, 47, "FFFFFF", 0.9, 0, IntX, IntY) = 0 Then
                Window.KeyPress GamehWnd, 27
                Api.Delay 200
            End If
            If dm.FindMultiColor(185, 33, 300, 100, "F4892A-111111", "3|0|202020-202020,3|1|202020-202020", 0.9, 6, IntX, IntY) Then
                Window.LeftClick GamehWnd, IntX, IntY
                Api.Delay 300
            End If
        ElseIf CBool(mode And 1) = False Then
            If CmpMutlColor(Array(Array(309, 4, "FAE162-080808", 0.9), Array(311, 74, "FCE56F-341A03", 0.9)), 2) Then '返回键
                If dm.CmpColor(16, 235, "FCDC4E-08112B", 0.9) = 1 Then
                    Window.LeftClick GamehWnd, 311, 4  '退出房间'
                    Api.Delay 300
                End If
            End If
        End If
    End Sub
    Public Sub [点击位置]([位置], Flag)
        Dim i, ClickTo, j, IntX, IntY
        i = InStr([位置], "_")
        If i Then
            Call [点击位置](Left([位置], i - 1), 0)
        End If
        Select Case [位置]
        Case "多人游戏"
            ' Window.LeftClick GamehWnd, 42, 25 '经典飞车
            For i = 0 To 2
                dm.MoveTo 32, 7
                Window.LeftClick GamehWnd, 37, 7
                Api.Delay 500
            Next
            Window.LeftClick GamehWnd, 146, 197 '关消息窗口
        Case "多人游戏_快速进入"
            ClickTo = Split(Flag, "-")
            Window.LeftClick GamehWnd, 37, 7
            Api.Delay 500
            IntX = 20
            For i = 0 To UBound(ClickTo)
                IntY = ClickTo(i)
                dm.MoveTo IntX, IntY
                Api.Delay 300
                Window.LeftClick GamehWnd, IntX, IntY
                Api.Delay 300
                IntX = IntX + 38
            Next
        Case "菜单"
            dm.MoveTo 2, 235
            Window.LeftClick GamehWnd, 2, 235
            Api.Delay 500
        Case "菜单_多人游戏"
            Const BOTTOM = 223
            dm.MoveTo 40, 162
            Api.Delay 600
            Window.LeftClick GamehWnd, 100, 223 - Flag * 12
        End Select
    End Sub
    Public Sub [强制到位置](Obj, BackFunc, IniTime)
        Dim This
        Set This = Obj
        IniTime = True
        Call SetTime(1, IniTime)
        [位置] = 0
        Do Until Obj.IsIn() Or CBool(Obj.Where(1))
            'Call Api.CallObj(Obj, BackFunc, 1)
            Call [清理弹窗](0)
            ExeCute "This." & BackFunc
            Api.Delay 1000
            Call [清理弹窗](1)
            Api.Delay 500
            If Handling(1, 60, IniTime) = -1 Then
                Call [强制到位置](Obj, BackFunc, IniTime)
                Exit Do
            End If
        Loop
        IniTime = True
    End Sub
    Public Function [位置被改变](ByVal Num, IniTime)
        Dim i
        If Num = 0 Or Num = 2 Then
            i = [可以下个模式]()
            If i < 0 Then
                [位置被改变] = i
                Exit Function
            End If
        End If
        If [位置] <> Num Then
            [位置] = Num
            IniTime = True
            [位置被改变] = 1
            Select Case [位置]
            Case 0
                ListView.SetText ListhWnd(0), HIndex, 5, "准备中:" & [局数]
            Case 1
                ListView.SetText ListhWnd(0), HIndex, 5, "游戏中:" & [局数]
            Case 2
                ListView.SetText ListhWnd(0), HIndex, 5, "房间中:" & [局数]
            End Select
            Call SetTime(1, IniTime)
        End If
    End Function
    Public Function [可以下个模式]()
        Dim i
        i = Api.Val(WorkList(WorkIndex)(3))
        If i > 0 Then
            If DateDiff("s", itime(0), Now()) > i * 60 Then
                [可以下个模式] = -2
            End If
        End If
        i = Api.Val(WorkList(WorkIndex)(2))
        If i > 0 And [局数] >= i Then
            [可以下个模式] = -1
        End If
        If [可以下个模式] < 0 Then
            Window.LeftClick GamehWnd, 311, 4  '退出房间'
        End If
    End Function
    Public Function Where(ByVal Flag)
        Select Case Flag
        Case 0 '游戏大厅'
            If CmpMutlColor(Array(Array(1, 2, "FFF36E-08090C", 0.9), Array(49, 3, "0DBDE2-0C140E", 0.9), Array(92, 3, "0DBDE2-0C140E", 0.9)), 20) Then
               Where = 1 + dm.CmpColor(309, 5, "F8D95B-0D0F07", 0.9)
            End If
        Case 1 '游戏中'
            Where = CmpMutlColor(Array(Array(52, 30, "E8E8E8-080808", 0.9), Array(29, 31, "C5C5C5-080808", 0.9), Array(52, 11, "949492-080808", 0.9)), 20)
        Case 2 '游戏房间'
            Where = CmpMutlColor(Array(Array(309, 4, "FAE162-080808", 0.9), Array(35, 2, "FFE76B-080808", 0.9)), 20) And dm.CmpColor(1, 2, "FFF472-111111", 0.9) = 1
        Case 3 '颁奖中'
        Case 4 '匹配中'
            Where = CmpMutlColor(Array(Array(147, 225, "0CD9DF-071111", 0.9), Array(172, 225, "0BD9DF-081111", 0.9), Array(147, 230, "0DB2C1-091918", 0.9), Array(172, 230, "0CB3C1-091818", 0.9)), 2) And dm.CmpColor(1161, 219, "0BD9DF-081111", 0.9) = 1
        End Select
    End Function
    Public Function State(ByVal WZ) '弹窗
        If WZ = 2 Or WZ = 3 Then
            WZ = 0
        End If
        If WZ = 0 Then
            If dm.CmpColor(309, 4, "322D14-080808", 0.9) = 0 Then
                State = 1
            ElseIf CmpMutlColor(Array(Array(34, 2, "332E15-080808", 0.9), Array(309, 4, "0F242B-080808", 0.9)), 20) Then
                State = 2   '游戏大厅'
            End If
        ElseIf WZ = 1 Then
            If CmpMutlColor(Array(Array(52, 30, "2E2E2E-080808", 0.9), Array(29, 31, "272727-080808", 0.9), Array(52, 11, "1C1D1C-080808", 0.9)), 2) Then
                State = 1
            End If
        End If
    End Function
    Public Function SetTime(Index, IniTime)
        If IniTime Then
            itime(Index) = Now()
            IniTime = False
            SetTime = True
        End If
    End Function
    Public Function Handling(Index, S, IniTime)
        Dim i
        Handling = 0
        If DateDiff("s", itime(Index), Now()) > S Then '超时处理
            IniTime = True
            Handling = Detect(1)
        End If
        i = DateDiff("s", StartTime, Now())
        If i - MarkTime >= 10 Then
            MarkTime = i
            ListView.SetText ListhWnd(0), HIndex, 4, WorkList(WorkIndex)(1) & ":" & (i \ 10) * 10
            If Handling = 0 Then Handling = Detect(0)
            If [防止休眠] Then
                [防止休眠] = -[防止休眠]
                Call Api.ECall("user32", "mouse_event", &H1, [防止休眠], [防止休眠], 0, 0)
            End If
        End If
    End Function
    Public Function Detect(Default)
        Dim x1, y1, x2, y2
        Select Case True
        Case Default <> 0
            Detect = Default
        Case Api.ECall("user32", "IsWindow", GamehWnd) = 0
            Detect = 11
        Case Else
            For x1 = 0 To 10
                If Api.ECall("user32", "IsHungAppWindow", GamehWnd) = 0 Then
                    Exit For
                End If
                Api.Delay 500
            Next
            If x1 = 11 Then
                Detect = 12
            Else
                Call Window.GetClientRect(GamehWnd, x1, y1, x2, y2)
                If x2 <> C_GameSmallWith Or y2 <> C_GameSmallHeight Then
                    Call [调整窗口](GamehWnd)
                End If
            End If
        End Select
        If Detect Then
            If StartMode = 1 Then
                ListView.SetText ListhWnd(0), HIndex, 5, "重连" & Detect & ":" & [局数]
                If [掉线重连] Then
                    ' Call SetTime(0, True)
                    ' StartTime = Now()
                    ' MarkTime = 0
                    Detect = -1
                End If
            End If
        End If
    End Function
    Public Sub ThreadEnter(Nun)
        Api.EnterCriticalSection Nun
        leave = Nun
    End Sub
    Public Sub ThreadLeave(Nun)
        Api.LeaveCriticalSection Nun
        leave = 0
    End Sub
    Public Function IIf(p, a, b)
        If p Then
            IIf = a
        Else
            IIf = b
        End If
    End Function
    Private Sub GameOver()
        Dim x1, y1, x2, y2
        If leave Then Api.LeaveCriticalSection leave  '防止手动中止
        If HNext Then
            ListView.SetText ListhWnd(0), HIndex, 4, WorkList(WorkIndex)(1)
            ListView.SetText ListhWnd(0), HIndex, 5, "完成"
            dm.SetWindowState GamehWnd, 13
            WorkList(0)(C_WorkProgress + 3) = 1
            Api.EnterCriticalSection 1
            Globals("QQSpeed").Item(HIndex) = WorkList
            Call Api.ECall("user32.dll", "SendMessageW", Globals("Form").hWnd, &H404, HIndex + 1, StartMode)
            Api.LeaveCriticalSection 1
            Exit Sub
        End If
        ListView.SetText ListhWnd(0), HIndex, 4, WorkList(WorkIndex)(1)
        ListView.SetText ListhWnd(0), HIndex, 5, IIf(WorkList(0)(C_WorkProgress + 3) And 2, "上号失败", "手动中止")
        WorkList(0)(C_WorkProgress) = WorkIndex - 1 '保存进度
        WorkList(0)(C_WorkProgress + 2) = [局数]
        Api.EnterCriticalSection 1
        Globals("QQSpeed").Item(HIndex) = WorkList
        If WorkList(0)(C_WorkProgress + 3) And 2 Then
            Call Api.ECall("user32.dll", "SendMessageW", Globals("Form").hWnd, &H404, HIndex + 1, StartMode)
        End If
        Api.LeaveCriticalSection 1
        If GamehWnd = 0 Then Exit Sub
        Window.GetClientRect GamehWnd, x1, y1, x2, y2
        If x2 = C_GameSmallWith Then
            'bgkms.KMUntransform KMData
            If DownCpu Then dm.DownCpu 0
            dm.UnBindWindow
            Api.Delay 50
            Window.SetStyle GamehWnd, 1 + 16 + 128
            Api.Delay 100
            Window.ClientMove GamehWnd, 0, 0, C_GameWith, C_GameHeight
        End If
    End Sub
    Private Sub Class_Initialize()
        Window.Delay = "40-100"
        Set mFSO = CreateObject("Scripting.FileSystemObject")
    End Sub
    Private Sub Class_Terminate()
        GameOver
        Api.EnterCriticalSection 1
        Globals("Form").Controls("ListView1").object.ListView.ListItems(HIndex + 1).Checked = False
        Api.LeaveCriticalSection 1
    End Sub
End Class
Class [QQSpeed_边境模式]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime
        Dim i
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                Api.Delay 200
                If dm.CmpColor(108, 75, "FFFFFF", 0.9) = 0 Then '选择频道'
                    Window.LeftClick GamehWnd, 100, 132 + 20 * i
                Else
                    Window.LeftClick GamehWnd, 100, 90 '再来一次'
                End If
            ElseIf Where(1) Then
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf CmpMutlColor(Array(Array(24, 74, "303030-080808", 0.9), Array(22, 105, "0B0706-080808", 0.9)), 20) Then '正在进入游戏'
                Api.Delay 1000
            ElseIf Where(0) Then
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 80, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 180, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If dm.CmpColor(285, 44, "FFFFFF", 1) = 1 Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 8000
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Function IsIn() '是否在边境'
        IsIn = CmpMutlColor(Array(Array(105, 60, "F68608-0B1F0A", 0.9), Array(70, 59, "F78609-0A1D0B", 0.9), Array(114, 69, "05C7CF-071411", 0.9), Array(92, 69, "05C8CF-081412", 0.9)), 20)
    End Function
    Public Function Where(Flag)
        Where = QQSpeed.Where(Flag)
    End Function
    Public Sub Go()
        Dim i
        For i = 0 To 3
            Window.LeftClick GamehWnd, 38, 7
            Api.Delay 200
        Next
        Window.LeftClick GamehWnd, 220, 3
        Api.Delay 500
    End Sub
    Public Property Set Father(Obj) '继承?'
        Set QQSpeed = Obj
    End Property
End Class
Class [QQSpeed_绝命车王]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime, i
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                Call LuckyBox
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                Window.LeftClick GamehWnd, 42, 105   '单人匹配'
                Api.Delay 200
            ElseIf Where(1) Then
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf Where(2) Then
                Window.LeftClick GamehWnd, 311, 4  '退出房间'
                If QQSpeed.[位置被改变](2, IniTime) < 0 Then Exit Do
            ElseIf Where(0) Then
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 150, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 300, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If dm.CmpColor(52, 30, "E8E8E8-080808", 0.9) = 1 Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 8000
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Sub Go()
        QQSpeed.[点击位置] "菜单_多人游戏", 16
    End Sub
    Public Function IsIn()
        IsIn = CmpMutlColor(Array(Array(17, 208, "45090C-060606", 0.9), Array(38, 184, "C68D4A-070807", 0.9), Array(10, 144, "2C1113-070707", 0.9), Array(7, 45, "291010-060707", 0.9)), 2)
    End Function
    Public Function Where(Flag)
        Where = QQSpeed.Where(Flag)
    End Function
    Public Sub LuckyBox()
        Call QQSpeed.[自动开箱](2, 115, 155, 39, Array(True))
    End Sub
    Public Property Set Father(Obj) '继承?'
        Set QQSpeed = Obj
    End Property
End Class
Class [QQSpeed_秘境闯关]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime, i, itime
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                Call LuckyBox
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                If dm.GetTime Mod 2 Then
                    Window.LeftClick GamehWnd, 160, 50
                Else
                    Window.LeftClick GamehWnd, 85, 100   '单人匹配'
                End If
                Api.Delay 200
            ElseIf Where(1) Then
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf Where(2) Then
                LuckyBox()
                i = QQSpeed.[位置被改变](2, IniTime)
                If i < 0 Then Exit Do
                If dm.CmpColor(26, 235, "0D4959-070909", 0.9) = 1 Then  'BUG 进了普通房间
                    Window.LeftClick GamehWnd, 311, 4  '退出房间
                    Api.Delay 500
                ElseIf i Then
                    itime = Now()
                ElseIf DateDiff("s", itime, Now()) > 10 Then
                    Window.LeftClick GamehWnd, 311, 4  '退出房间
                    Api.Delay 500
                Else
                    QQSpeed.[准备游戏]
                End If
            ElseIf Where(0) Then
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 200, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 300, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If dm.CmpColor(9, 236, "0083C5-06130E", 0.9) = 1 Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 5000
                ElseIf dm.CmpColor(149, 12, "A0FFFF-110808", 0.9) = 0 Then  '放技能'
                    dm.KeyPress 32
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Sub Go()
        QQSpeed.[点击位置] "菜单_多人游戏", 15
    End Sub
    Public Function IsIn()
        IsIn = CmpMutlColor(Array(Array(10, 155, "472B95-080808", 0.9), Array(3, 95, "1D1F5B-070607", 0.9), Array(3, 89, "3A306B-070707", 0.9), Array(8, 237, "9B6FFB-0C0A08", 0.9)), 2)
    End Function
    Public Function Where(Flag)
        If Flag = 1 Then
            Where = CmpMutlColor(Array(Array(9, 236, "0083C5-06130E", 0.9), Array(259, 17, "FAFBFF-0A0906", 0.9), Array(9, 42, "FFFFFF-080808", 0.9)), 2)
        Else
            Where = QQSpeed.Where(Flag)
        End If
    End Function
    Public Sub LuckyBox()
        If Where(2) Then
            Call QQSpeed.[自动开箱](1, 286, 25, 28, Array("dm.CmpColor(213, 73,""313642-080808"", 0.9) = 0", "Window.LeftClick GamehWnd, 217, 76"))
        Else
            Call QQSpeed.[自动开箱](4, 115, 123, 24, Array("dm.CmpColor(213, 73,""313642-080808"", 0.9) = 0", "Window.LeftClick GamehWnd, 217, 76"))
        End If
    End Sub
    Public Property Set Father(Obj) '继承?'
        Set QQSpeed = Obj
    End Property
End Class
Class [QQSpeed_互助接力赛]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime, i
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                Call LuckyBox
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                Window.LeftClick GamehWnd, 40, 80   '单人匹配'
                Api.Delay 200
            ElseIf Where(1) Then
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf Where(2) Then
                Call LuckyBox
                Window.LeftClick GamehWnd, 311, 4  '退出房间'
                Api.Delay 300
                Window.LeftClick GamehWnd, 140, 152 '确定
                If QQSpeed.[位置被改变](2, IniTime) < 0 Then Exit Do
            ElseIf Where(0) Then
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                If QQSpeed.State(0) Then
                    If CmpMutlColor(Array(Array(213, 84, "291B64-080808", 0.9), Array(216, 88, "372976-080808", 0.9)), 20) Then '弹窗'
                        Window.LeftClick GamehWnd, 208, 82
                    End If
                ElseIf CmpMutlColor(Array(Array(3, 6, "4749BA-080808", 0.9), Array(315, 5, "4BECF4-080808", 0.9)), 20) Then '等待开局'
                    If dm.CmpColor(311, 100, "FBE699-080811", 0.9) = 0 Then '点赞'
                        Window.LeftClick GamehWnd, 310, 100
                    End If
                End If
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 150, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 300, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If QQSpeed.State(1) Then
                    If CmpMutlColor(Array(Array(195, 83, "392974-070607", 0.9), Array(213, 84, "291B63-060606", 0.9), Array(215, 156, "352772-070707", 0.9)), 2) Then '队友离开
                        Window.LeftClick GamehWnd, 140, 152
                    End If
                ElseIf dm.CmpColor(52, 30, "E8E8E8-080808", 0.9) = 1 Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 8000
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Sub Go()
        QQSpeed.[点击位置] "菜单_多人游戏", 14
    End Sub
    Public Function IsIn() '是否在边境'
        IsIn = CmpMutlColor(Array(Array(23, 33, "FEFCFF-080808", 0.9), Array(135, 38, "1AFCF3-080808", 0.9), Array(132, 38, "1AFCF3-080808", 0.9)), 20)
    End Function
    Public Function Where(Flag)
        Where = QQSpeed.Where(Flag)
    End Function
    Public Sub LuckyBox()
        If QQSpeed.[位置] = 2 Then
            Call QQSpeed.[自动开箱](1, 173, 90, 23, Array(True))
        Else
            Call QQSpeed.[自动开箱](2, 30, 145, 45, Array(True))
        End If
    End Sub
    Public Property Set Father(Obj) '继承?'
        Set QQSpeed = Obj
    End Property
End Class
Class [QQSpeed_酷币大作战]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime, i
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                Window.LeftClick GamehWnd, 40, 110   '单人匹配'
                Api.Delay 200
            ElseIf Where(1) Then    '游戏中'
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf Where(0) Then
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                Call LuckyBox
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 150, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 360, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If dm.CmpColor(264, 7, "FFF4DF-080808", 0.9) = 1 Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 8000
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Sub Go()
        QQSpeed.[点击位置] "菜单_多人游戏", 13
    End Sub
    Public Function IsIn()
        IsIn = CmpMutlColor(Array(Array(139, 70, "5266DD-080808", 0.9), Array(147, 85, "7388D9-080808", 0.9), Array(12, 75, "30A8FF-080808", 0.9)), 20)
    End Function
    Public Function Where(Flag)
        If Flag = 1 Then
            Where = CmpMutlColor(Array(Array(264, 7, "FFF4DF-080808", 0.9), Array(289, 11, "FFF4DF-080808", 0.9), Array(203, 10, "E0F4FF-080808", 0.9)), 20)
        Else
            Where = QQSpeed.Where(Flag)
        End If
    End Function
    Public Sub LuckyBox()
        Dim i, IntX, IntY
        If CmpMutlColor(Array(Array(84, 65, "56342C-071111", 0.9), Array(34, 106, "F6D1BF-081111", 0.9), Array(71, 162, "F78796-091918", 0.9)), 20) Then
            Api.Delay 3000
            For i = 0 To 7
                IntX = 117 + 50 * (i Mod 4)
                IntY = 120 + 61 * (i \ 4)
                If dm.CmpColor(IntX, IntY, "7462D3-111111", 0.9) = 0 Then
                    IntX = IntX - 20
                    IntY = IntY - 11
                    Exit For
                End If
                Api.Delay 20
            Next
            If i = 8 Then
                IntX = 40
                IntY = 143
            End If
            Call QQSpeed.[自动截图]("00FFFF-222222", 40, IntY + 35, 72, IntY + 7)
            Api.Delay 5000
        End If
    End Sub
    Public Property Set Father(Obj) '继承?'
        Set QQSpeed = Obj
    End Property
End Class
Class [QQSpeed_双人冲锋战]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime, i
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                Call LuckyBox
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                Window.LeftClick GamehWnd, 40, 95   '单人匹配'
                Api.Delay 200
                Window.LeftClick GamehWnd, 134, 115  '选枪王'
                Api.Delay 200
                Window.LeftClick GamehWnd, 160, 150  '确定'
            ElseIf Where(1) Then
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf Where(2) Then
                Window.LeftClick GamehWnd, 311, 4  '退出房间'
                If QQSpeed.[位置被改变](2, IniTime) < 0 Then Exit Do
            ElseIf Where(0) Then
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                If QQSpeed.State(0) Then
                    If CmpMutlColor(Array(Array(214,84,"0C2D6B-070707",0.9),Array(189,88,"FFFEE3-060609",0.9),Array(221,95,"4070D0-090706",0.9)), 2) Then '队友离开'
                        Window.LeftClick GamehWnd, 160,153
                    End If
                End If
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 200, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 300, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If dm.CmpColor(52, 30, "E8E8E8-080808", 0.9) = 1 Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 8000
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Sub Go()
        QQSpeed.[点击位置] "菜单_多人游戏", 12
    End Sub
    Public Function IsIn() '是否在边境'
        IsIn = CmpMutlColor(Array(Array(78, 54, "293B96-080808", 0.9), Array(136, 56, "233374-080808", 0.9), Array(71, 40, "E8ECFF-080808", 0.9), Array(40, 12, "201C35-080808", 0.9)), 20)
    End Function
    Public Function Where(Flag)
        Where = QQSpeed.Where(Flag)
    End Function
    Public Sub LuckyBox()
        Call QQSpeed.[自动开箱](3, 112, 153, 29, Array(True))
    End Sub
    Public Property Set Father(Obj) '继承?'
        Set QQSpeed = Obj
    End Property
End Class
Class [QQSpeed_超能竞速赛]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime, i
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                Call LuckyBox
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                Window.LeftClick GamehWnd, 42, 105   '单人匹配'
                Api.Delay 200
            ElseIf Where(1) Then
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf Where(2) Then
                Window.LeftClick GamehWnd, 311, 4  '退出房间'
                If QQSpeed.[位置被改变](2, IniTime) < 0 Then Exit Do
            ElseIf Where(0) Then
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 150, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 300, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If dm.CmpColor(52, 30, "E8E8E8-080808", 0.9) = 1 Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 8000
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Sub Go()
        QQSpeed.[点击位置] "菜单_多人游戏", 11
        Api.Delay 1000
    End Sub
    Public Function IsIn()
        IsIn = CmpMutlColor(Array(Array(13, 41, "FFFFFF-080808", 0.9), Array(9, 66, "6086E6-080808", 0.9), Array(116, 63, "4D62DE-080808", 0.9)), 20)
    End Function
    Public Function Where(Flag)
        Where = QQSpeed.Where(Flag)
    End Function
    Public Sub LuckyBox()
        Call QQSpeed.[自动开箱](3, 123, 165, 31, Array(True))
    End Sub
    Public Property Set Father(Obj) '继承?'
        Set QQSpeed = Obj
    End Property
End Class
Class [QQSpeed_狂野追逐]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime, i
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                Call LuckyBox
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                Window.LeftClick GamehWnd, 42, 140   '单人匹配'
                Api.Delay 200
            ElseIf Where(1) Then
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf Where(2) Then
                Window.LeftClick GamehWnd, 311, 4  '退出房间'
                If QQSpeed.[位置被改变](2, IniTime) < 0 Then Exit Do
            ElseIf Where(0) Then
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 150, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 300, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If dm.CmpColor(6, 230, "0DB4C5-080808", 0.9) = 1 Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 8000
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Sub Go()
        QQSpeed.[点击位置] "菜单_多人游戏", 10
    End Sub
    Public Function IsIn()
        IsIn = CmpMutlColor(Array(Array(135, 55, "02809F-080808", 0.9), Array(135, 218, "0CB3D2-080808", 0.9), Array(10, 218, "F8FCFD-080808", 0.9)), 20)
    End Function
    Public Function Where(Flag)
        If Flag = 1 Then
            Where = CmpMutlColor(Array(Array(6, 230, "0DB4C5-080808", 0.9), Array(14, 230, "0A94AD-080808", 0.9), Array(52, 30, "E8E8E8-080808", 0.9)), 20)
        Else
            Where = QQSpeed.Where(Flag)
        End If
    End Function
    Public Sub LuckyBox()
        Call QQSpeed.[自动开箱](3, 122, 200, 35, Array(True))
    End Sub
    Public Property Set Father(Obj) '继承?'
        Set QQSpeed = Obj
    End Property
End Class
Class [QQSpeed_变身派对]
    Private QQSpeed
    Public Sub GuaJi()
        Dim IniTime, i
        QQSpeed.[强制到位置] Me, "Go", IniTime
        Do
            If IsIn() Then
                Call LuckyBox
                If QQSpeed.[位置] = 1 Then QQSpeed.[完成一局] 0
                If QQSpeed.[位置被改变](0, IniTime) < 0 Then Exit Do
                Window.LeftClick GamehWnd, 42, 115   '单人匹配'
                Api.Delay 200
            ElseIf Where(1) Then
                Api.Delay 1000
                Call QQSpeed.[位置被改变](1, IniTime)
            ElseIf Where(2) Then
                Window.LeftClick GamehWnd, 311, 4  '退出房间'
                If QQSpeed.[位置被改变](2, IniTime) < 0 Then Exit Do
            ElseIf Where(0) Then
                QQSpeed.[强制到位置] Me, "Go", IniTime
            Else
                QQSpeed.[清理弹窗] (0)
            End If
            Select Case QQSpeed.[位置]
            Case 0, 2
                Select Case QQSpeed.Handling(1, 150, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
            Case 1
                Select Case QQSpeed.Handling(1, 300, IniTime)
                Case -1
                    QQSpeed.[强制到位置] Me, "Go", IniTime
                End Select
                If CmpMutlColor(Array(Array(111,76,"E5C5A2-070708",0.9),Array(125,46,"E07A5A-070707",0.9),Array(242,108,"568BD4-060606",0.9),Array(94,86,"FF9F7F-060707",0.9)), 2) Then
                    QQSpeed.[位置] = 3  '颁奖中'
                    QQSpeed.[完成一局] 8000
                End If
            End Select
            Api.Delay 100
        Loop
    End Sub
    Public Sub Go()
        QQSpeed.[点击位置] "菜单_多人游戏", 6
    End Sub
    Public Function IsIn()
        IsIn = CmpMutlColor(Array(Array(192, 212, "F3E5D4-080808", 0.9), Array(20, 133, "2C64AE-080808", 0.9), Array(28, 126, "EDCBB5-080808", 0.9)), 20)
    End Function
    Public Function Where(Flag)
        If Flag = 1 Then
            Where = CmpMutlColor(Array(Array(178, 25, "FBCF8D-080808", 0.9), Array(150, 27, "FFF9EE-080808", 0.9), Array(162, 6, "FFEDDB-080808", 0.9)), 20)
        Else
            Where = QQSpeed.Where(Flag)
        End If
    End Function
    Public Sub LuckyBox()
        Call QQSpeed