Option Explicit
Const C_WorkProgress = 4
Class UI_Class
    Public Form, Control, Tip, config, AppName, Starting
    Private Angel, Menu, hMenu1(1), hMenu2(0), timing
    Private Sub Create()
        Dim i, v, s, j, arr
        JScript.AddCode Globals("Control_Class")
        Set Control = JScript.Eval("new Control_Class")
        Set Menu = Control.Menu()
        Set Form = Api.NewFrom()
        With Form
            Form.Caption = "软件定制337855632"
            Call Api.ECall("user32.dll", "SetWindowLongA", .hWnd, -16, Api.ECall("user32.dll", "GetWindowLongA", .hWnd, -16) And Not (&H10000 Or &H40000))
            .Move 0, 0, 0, 0
            .Width = (285 - .ScaleWidth) * Globals("Screen").TwipsPerPixelX + .Width
            .Height = (410 - .ScaleHeight) * Globals("Screen").TwipsPerPixelY + .Height
            .Move (Globals("Screen").Width - .Width) \ 2, (Globals("Screen").Height - .Height) \ 2
        End With
        Const iLeft = 150
        Const Margin = 2
        Const UpDate = "2021-05-09"
        Dim Top
        config = ".\Angel.ini"
        AppName = "Angel_HX"
        If CDate(UpDate) > CDate(File.ReadINI(AppName, "UpDate", config, "2020-01-01")) Then
            File.Delete config
            File.WriteINI AppName, "UpDate", UpDate, config
        End If
        Call CreateListBox
        Top = 5
        arr = Array("使用权限", "免费使用|试用会员|登录会员", "窗口排列", "左竖叠加|左竖平铺|左横平铺|右竖叠加|右竖平铺|右横平铺", "游戏模式", "火线追击", "方向按键", "上下左右|W A S D", "游戏大区", "默认大区|刷电信区|刷联通区|刷电信二", "游戏完成", "不做处理|播放音乐|关闭电脑")
        For i = 0 To UBound(arr) Step 2
            With Form.Controls.Add("VB.Label", arr(i) & "L")
                .Move iLeft + 10, Top + 3 + (20 + Margin) * i \ 2, 60, 20
                .Caption = arr(i) & ":"
                .Visible = True
            End With
            With Form.Controls.Add("VB.ComboBox", arr(i))
                .Move iLeft + 60, Top + (20 + Margin) * i \ 2, 73
                .Visible = True
                Call ComboBoxStyle(Form.Controls(arr(i)), arr(i + 1), 0)
                .ListIndex = File.ReadINI(AppName, arr(i) & ".ListIndex", config, 0)
            End With
            Call Form_Event(Form.Controls(arr(i)), &H100 * &H100, 0)
        Next
        Top = Top + (20 + Margin) * 6
        arr = Array("定时功能", "0启动辅助|0终止辅助|0关闭电脑", "重上设置", "0重上文本|1游戏超时|1准备超时", "其他设置", "1防止休眠|0开机启动|0开机上号|0换号局数|1自动滑块|0飞车路径")
        For i = 0 To UBound(arr) Step 2
            With Form.Controls.Add("VB.Label", arr(i) & "L")
                .Move iLeft + 10, Top + 3 + (20 + Margin) * i \ 2, 60, 20
                .Caption = arr(i) & ":"
                .Visible = True
            End With
            With Form.Controls.Add("QQSpeed.ComboList", arr(i))
                .Move iLeft + 60, Top + (20 + Margin) * i \ 2, 73
                .Visible = True
                s = File.ReadINI(AppName, arr(i), config, arr(i) & "|" & arr(i + 1))
                .object.List = s
                File.WriteINI AppName, arr(i), s, config
            End With
        Next
        Form.SetEvent Form.Controls(arr(0)), Me, "ActiveXEvents", "ComboBox"

        Top = Top + 70
        arr = Array("同时线程", 6, 1, "游戏降耗", 0, 1, "登录重试", 3, 1, "上号间隔", 5, 1, "上号等待", 50, 1, "顶号等待", 50, 1)
        For i = 0 To UBound(arr) Step 3
            s = Left(arr(i), 4)
            With Form.Controls.Add("VB.TextBox", s & "T")
                .Move iLeft + 89, Top + (20 + Margin) * i \ 3, 43, 20
                .Visible = True
                .Text = File.ReadINI(AppName, s & "T.Text", config, arr(i + 1))
            End With
            With Form.Controls.Add("VB.CheckBox", s)
                .Caption = arr(i) & ":"
                .Move iLeft + 10, Top + (20 + Margin) * i \ 3, 130, 20
                .Visible = True
                .Value = File.ReadINI(AppName, s & ".Value", config, arr(i + 2))
            End With
            Call Form_Event(Form.Controls(s & "T"), &H30000 * &H100, 0)
            Call Form_Event(Form.Controls(s), &H100 * &H100, 0)
        Next
        Form.Controls("上号等待").ToolTipText = "登录游戏时的读条时间:秒"
        
        Top = Top + 135
        arr = Array("使用帮助", "常用功能", "会员服务", "启动游戏", "中止全部", "清除进度")
        For i = 0 To UBound(arr)
            With Form.Controls.Add("VB.CommandButton", arr(i))
                .Caption = arr(i)
                .Move iLeft + 10 + 60 * (i \ 3), Top + (20 + Margin) * (i Mod 3), 60, 21
                .Visible = True
            End With
        Next
        Form.Controls("启动游戏").ToolTipText = "快捷键(F9)"
        Form.Controls("中止全部").ToolTipText = "快捷键(F10)"
        Form.Controls("清除进度").ToolTipText = "手动中止后。游戏进度会被保存以备启动继续。清除后可以完全重新开始"
        
        Form.SetUnloadEvent Me, "Form_Unload"
        Const WM_HOTKEY = &H312
        Const WM_CLOSE = &H10
        Const WM_COMMAND = &H111
        Const WM_SIZE = &H5
        Const WM_USER = &H400
        Const WM_APP = &H8000
        Form.SetEventLong Form.hWnd, Array(WM_CLOSE, WM_HOTKEY, WM_COMMAND, WM_SIZE, WM_APP + 4), Me, "Form"
        Form.Show
        Call Api.ECall("user32", "RegisterHotKey", Form.hWnd, 1, 0, &H78)
        Call Api.ECall("user32", "RegisterHotKey", Form.hWnd, 2, 0, &H79)
        Call Api.ECall("user32", "RegisterHotKey", Form.hWnd, 3, 0, &H24)
        Starting = 1
    ' s = "C:\Users\Administrator\Desktop\脚本\VBS+\SkinH_VB6.dll"
    ' Call Api.ECall(Api.ProcAddress(s, "SkinH_AttachEx"), False, Api.StrConv("C:\Users\Administrator\Desktop\脚本\VBS+\皮肤\vista.she"& chr(0),&H80), "")
    End Sub
    Private Function times(ByVal s, ByVal d)
        Dim i, t
        i = InStr(s, "|")
        If i = 0 Then i = InStrRev(s, ":")
        t = Left(s, i - 1)
        s = Mid(s, i + 1)
        Select Case Int(s)
        Case 3
            d = DateAdd("s", DateDiff("s", "00:00:00", t), Now())
            times = Api.Format(d, "yyyy-mm-dd HH:mm:ss")
        Case Else
            d = DateAdd("s", d, Time())
            d = DateAdd("d", IIf(DateDiff("s", d, t) <= 0, 1, 0), Date)
            times = Api.Format(d, "yyyy-mm-dd") & " " & t
        End Select
        times = times & "|" & s
    End Function
    Public Sub Timer_Timer()
        Dim i, v, arr, s, t
        If UBound(timing) >= 0 Then
            arr = Split(timing(0), "|")
            i = InStr("启动辅助|终止辅助|关闭电脑", arr(2))
            If i Then i = -10
            If Now() >= DateAdd("s", i, arr(0)) Then 'CDate(arr(0)) Then
                t = File.ReadINI(AppName, arr(2), config)
                Select Case arr(1)
                Case 2
                    Set v = CString.Array(timing)
                    Call v.Shift
                    s = Form.Controls("定时功能").object.List
                    s = Replace(s, "|1" & arr(2), "|0" & arr(2))
                    Form.Controls("定时功能").object.List = s
                    File.WriteINI AppName, "定时功能", s, config
                Case Else
                    timing(0) = times(t, -i) & "|" & arr(2)
                    Set v = CString.Array(timing)
                End Select
                If i Then i = Window.MessageBox(Form.hWnd, "启动定时功能:" & arr(2) & vbTab & t, "定时功能:", vbOKCancel + 64, 10)
                If i > 0 And i <> 2 Then
                    Select Case arr(2)
                    Case "启动辅助"
                        Call Form_Event(Form.Controls("启动游戏"), 0, 0)
                    Case "终止辅助"
                        Call Form_Event(Form.Controls("中止全部"), 0, 0)
                    Case "关闭电脑"
                        Call Api.Shell("shutdown -f -s -t 30")
                    End Select
                End If
                timing = Api.ArrayFormat(v.sort())
            End If
        End If
    End Sub
    Private Sub Form_Event(Obj, wParam, lParam)
        Dim i, b
        Select Case TypeName(Obj)
        Case "CommandButton"
            Select Case Obj.Name
            Case "使用帮助"
                Call Window.MessageBox(Form.hWnd, "请查阅使用说明文本,其他加QQ群:123066586", "提示", 64, 5)
            Case "常用功能"
                MsgBox "功能正在添加中!", 4096
            Case "会员服务"
                MsgBox "请登录!", 4096
            Case "清除进度"
                Globals("QQSpeed").RemoveAll
            Case Else
                Dim j, y
                With Form.Controls("ListBox").object.ListBox
                    y = Int(Form.Controls("同时线程T").Text)
                    For i = 0 To .ListCount - 1
                        Select Case Obj.Name
                        Case "启动游戏"
                            If .Selected(i) Then
                                j = j + 1
                            End If
                        Case "中止全部"
                            If .Selected(i) Then
                                .Selected(i) = False
                            End If
                        End Select
                    Next
                    If Obj.Name = "启动游戏" Then
                        If Angel.Vip Is Nothing Then Exit Sub
                        i = 0
                        While j < y
                            If i < .ListCount Then
                                If .Selected(i) = False Then
                                    .Selected(i) = True
                                End If
                            Else
                                ListBox_ItemCheck i
                            End If
                            i = i + 1
                            j = j + 1
                        Wend
                    End If
                End With
            End Select
        Case "CheckBox"
            Select Case Obj.Name

            End Select
            File.WriteINI AppName, Obj.Name & ".Value", Obj.Value, config
        Case "TextBox"
            Select Case wParam \ &H100
            Case &H20000
                If IsNumeric(Obj.Text) = False Then
                    Obj.Text = "0"
                ElseIf Obj.Text < 0 Then
                    Obj.Text = "0"
                End If
            Case &H30000
                File.WriteINI AppName, Obj.Name & ".Text", Obj.Text, config
            End Select
        Case "ComboBox"
            Select Case wParam \ &H100
            Case &H100
                Select Case Obj.Name
                Case "使用权限"
                    ' If Obj.ListIndex Then
                    '     If Angel.Vip Is Nothing Then
                    '         Obj.ListIndex = 0
                    '         Exit Sub
                    '     End If
                    ' End If
                    ' ' Form.Controls("ListBox").object.ListView.OLEDropMode = Obj.ListIndex
                    ' ' SetListBox Obj.ListIndex
                End Select
                File.WriteINI AppName, Obj.Name & ".ListIndex", Obj.ListIndex, config
            End Select
        End Select
    End Sub
    Public Sub Form_GetMessage(cHwnd, Message, wParam, lParam)
        Dim i, j, Obj, b
        Select Case Message
        Case &H8004
            i = Globals("QQSpeed").Item(wParam)(C_WorkProgress + 3)
            i = IIf(i And 2, i \ &H10000, 5) * 2
            If i Then
                ' With Form.Controls("StatusBar").object
                '     .Panels(i).Text = Int(.Panels(i).Text) + 1
                ' End With
            End If
            With Form.Controls("ListBox").object.ListBox
                .Selected(wParam) = False
                i = wParam + 1
                Do
                    If i < .ListCount Then
                        If .Selected(i) = False Then
                            b = True
                            If Globals("QQSpeed").Exists(i) Then
                                b = Globals("QQSpeed").Item(C_WorkProgress + 3) = 0
                            End If
                            If b Then
                                .Selected(i) = True
                                Exit Do
                            End If
                        End If
                    Else
                        ListBox_ItemCheck i
                        Exit Do
                    End If
                    i = i + 1
                Loop
            End With
            If b = False And j = 0 Then
                Select Case Form.Controls("游戏完成").ListIndex
                Case 1
                    Call Api.ECall("winmm.dll", "mciSendStringW", "open ""http://music.player.E5%90%8D%E4%BE%A6%E6%8E%A2%E6%9F%AF%E5%8D%97.mid?0.mp3"" alias mysong", 0, 0, 0)
                    Call Api.ECall("winmm.dll", "mciSendStringW", "play mysong", 0, 0, 0)
                    MsgBox "游戏已全部完成!", 4096
                    Call Api.ECall("winmm.dll", "mciSendStringW", "Close mysong", 0, 0, 0)
                Case 2
                    Const SHUTDOWN = 0
                    Const RESTART = 1
                    Const POWEROFF = 2
                    Const SE_SHUTDOWN_PRIVILEGE = 19
                    Call Api.ECall("ntdll.dll", "RtlAdjustPrivilege", SE_SHUTDOWN_PRIVILEGE, 1, 0, Api.VarPtr(i) + 8) '提权
                    Call Api.ECall("ntdll.dll", "NtShutdownSystem", SHUTDOWN)
                End Select
            End If
        Case &H10   '内置的窗口好像不响应这个'
            MsgBox "WM_CLOSE", , Message
        Case &H5 'WM_SIZE'
            If Form.WindowState = 1 Then
                'Form.Visible = False
            End If
        Case &H111 ' "WM_COMMAND"
            For Each Obj In Form.Controls
                If InStr("CommandButton|CheckBox|TextBox|ComboBox", TypeName(Obj)) Then
                    If Obj.hWnd = lParam Then
                        Form_Event Obj, wParam, lParam
                    End If
                End If
            Next
        Case &H312
            Select Case wParam
            Case 1
                Call Form_Event(Form.Controls("启动游戏"), 0, 0)
            Case 2
                Call Form_Event(Form.Controls("中止全部"), 0, 0)
            Case 3
                Call ListBox_MouseMove(1, 0, &H202 * Globals("Screen").TwipsPerPixelX, 0)
            End Select
        End Select
    End Sub

    Public Sub ComboBox_Click(byEvent, Parameters)
        Select Case Parameters(0).Value
        Case "定时功能"
            'Form.Controls(Parameters(0).Value).Object.List="测试一下|0开机启动|1自动截图|0自动重启|0自动滑块|0飞车路径"
        Case "异常设置"
            With Form.Controls(Parameters(0).Value).object
                .Tips = "|在游戏中超时没有结束|定时终止辅助"
            End With
        Case "其他设置"
        End Select
    End Sub
    Public Sub ComboBox_ItemCheck(byEvent, Parameters)
        Dim s, t, b, i, v, Name
        With Form.Controls(Parameters(0).Value).object
            Name = .ComboBox.List(Parameters(1).Value)
            Select Case Parameters(0).Value
            Case "定时功能"
                If UBound(timing) = -1 Then
                    i = -1
                Else
                    For i = 0 To UBound(timing)
                        If InStr(timing(i), Name) Then
                            Exit For
                        End If
                    Next
                    If i > UBound(timing) Then
                        i = -1
                    End If
                End If
                If .ComboBox.Selected(Parameters(1).Value) Then
                    b = 1
                    s = Control.TimeDialog()
                    If Len(s) Then
                        t = times(s, 0) & "|" & Name
                        If i = -1 Then
                            Set v = CString.Array(timing)
                            v.push (t)
                        Else
                            timing(i) = t
                            Set v = CString.Array(timing)
                        End If
                        timing = Api.ArrayFormat(v.sort())
                    End If
                Else
                    Set v = CString.Array(timing)
                    v.splice i, 1
                    timing = Api.ArrayFormat(v.sort())
                End If
            Case "重上设置"
                Select Case Name
                Case "重上文本"
                    If .ComboBox.Selected(Parameters(1).Value) Then
                        b = 1
                        s = File.Select("请选择QQ账号", "支持文件(*.txt)|*.txt")
                    End If
                End Select
            Case "其他设置"
                Select Case Name
                Case "飞车路径"
                    If .ComboBox.Selected(Parameters(1).Value) Then
                        b = 1
                        s = File.Select("请选择QQ飞车路径", "支持文件(*.exe)|*.exe")
                    End If
                End Select
            End Select
            If Len(s) Then
                File.WriteINI AppName, Name, s, config
            ElseIf b Then
                .ComboBox.Selected(Parameters(1).Value) = False
                Exit Sub
            End If
            File.WriteINI AppName, Parameters(0).Value, .List, config
        End With
    End Sub
    Public Sub ComboBox_MouseMove(byEvent, Parameters)
        Dim v, s
        On Error Resume Next
        Select Case Parameters(0).Value
        Case "定时功能"
        Case "重上设置"
            v = Array("设置重上登录飞车的文本路径", "在游戏中超时重上", "没开始游戏超时重上")
        Case "其他设置"
            v = Array("防止系统休眠屏幕保护", "开机自动启动辅助", "开机自动启动辅助并开始上号刷", "出好东西自动截图", "登录飞车自动过滑块", "如果启动不了飞车。可以尝试填写安装飞车的路径")
        End Select
        With Form.Controls(Parameters(0).Value).object.ComboBox
            If .Selected(Parameters(1).Value) Then
                s = File.ReadINI(AppName, .List(Parameters(1).Value), config)
                If Len(s) Then s = .List(Parameters(1).Value) & ":" & s
            End If
            If Len(s) = 0 Then s = v(Parameters(1).Value)
            .ToolTipText = s
        End With
    End Sub
    Private Sub SetListBox(ByVal i)
        Dim v

    End Sub
    Private Sub CreateListBox()
        Dim i, w
        ' Set Angel = Api.CreateObject("QQSpeed.Angel")
        ' If Angel Is Nothing Then
            ' Call Api.ECall(".\plugin\QQSpeed.ocx", "DllRegisterServer") '注册插件'
            i = ".\plugin\QQSpeed.ocx"
            w = Api.ProcAddress(i, "DllRegisterServer")
            If w > 0 Then Call Api.ECall(w, False)
            Set Angel = CreateObject("QQSpeed.Angel")
        ' End If
        Call Angel.Init(Array(JScript, Window))
        Set Tip = Control.Tray()
        With Form.Controls.Add("QQSpeed.ClickBox", "ListBox")
            .Visible = True
            .Width = 150
            .Height = 410
            ' .object.CanDrag =True
            With .object.ListBox
                hMenu1(0) = Menu.Create(.hWnd, Join(Array("启动全部", "删除选中", "清空全部", "-", "提取名字"), Chr(0)))
                Tip.Add .hWnd, Globals("App").Title, Api.ECall("user32.dll", "SendMessageA", Form.hWnd, &H7F, 1, 0)
            End With
        End With
        Form.SetEvent Form.Controls("ListBox"), Me, "ActiveXEvent"
    End Sub

    Public Sub ListBox_DragDrop(Data, Effect, Button, Shift, x, y)
        If Data.GetFormat(15) Then Call Import(Data.Files(1))
    End Sub
    Public Sub ListBox_DragOver(Data, Effect, Button, Shift, x, y)
        Effect = Abs(Data.GetFormat(15))
    End Sub
    Public Sub ListBox_ItemClick(Item)

    End Sub
    Public Sub ListBox_ItemCheck(Item)
        Dim arr, s, b
        With Form.Controls("ListBox").object.ListBox
            If Item < .ListCount Then
                If .Selected(Item) = False And Globals("QQSpeed").Exists(Item) Then
                    arr = Globals("QQSpeed").Item(Item)
                    If arr(0) Then
                        Api.StopThread arr(0)
                        arr(0) = 0
                        Globals("QQSpeed").Item(Item) = arr
                    End If
                    Exit Sub
                End If
            End If
            If InStr(File.ReadINI(AppName, "重上设置", config), "1重上文本") Then
                s = File.ReadINI(AppName, "重上文本", config)
                s = File.ReadTextEx(s)
                If Len(s) = 0 Then
                    Call Window.MessageBox(Form.hWnd, "重上文本设置错误!", "提示", 16, 5)
                    If Item >= .ListCount Then Exit Sub
                Else
                    Dim regEx, Matches
                    Set regEx = New RegExp
                    regEx.Pattern = "(\d{4,}\-{4}\S{5,})\s*?\n?"
                    regEx.IgnoreCase = True
                    regEx.Global = True
                    Set Matches = regEx.Execute(s)
                    If Item >= .ListCount Then
                        If Item < Matches.Count Then
                            .AddItem ""
                            .Selected(Item) = True
                        End If
                        Exit Sub
                    End If
                    s = Matches(Item).SubMatches(0)
                End If
            ElseIf Item >= .ListCount Then
                Exit Sub
            End If
            b = .Selected(Item)
            If Globals("QQSpeed").Exists(Item) Then
                arr = Globals("QQSpeed").Item(Item)
                arr(3) = s
                If arr(C_WorkProgress + 3) And 1 Then
                    b = MsgBox("该账号已经完成!是否重新启动?", 4096 + 4, "账号:" & Item) = 6
                End If
            Else
                arr = Array(0, Item, .List(Item), s, 0, 0, 0, 0)    '进度, 句柄, 局数, 传递
            End If
            If b Then
                arr(0) = Api.CreateThread("ThreadStart " & Item)
                Globals("QQSpeed").Item(Item) = arr
            End If
        End With
    End Sub


    Private Function SetMenu(Menu, Index, Mode, Val)
        Dim pszText, MENUITEMINFO, fState
        Const MIIM_TYPE = &H10
        Const MIIM_STATE = &H1
        Const MIIM_CHECKMARKS = &H8

        Const MFT_STRING = &H0

        Const MF_CHECKED = &H8&
        Const MFS_GRAYED = &H3&
        pszText = Space(255)
    '   Private Type MENUITEMINFO
        '   cbSize As Long          0
        '   fMask As Long           4
        '   fType As Long           8
        '   fState As Long          12
        '   wID As Long             16
        '   hSubMenu As Long        20
        '   hbmpChecked As Long     24
        '   hbmpUnchecked As Long   28
        '   dwItemData As Long      32
        '   dwTypeData As String    36
        '   cch As Long             40
    '   End Type
        Set MENUITEMINFO = Api.Malloc(43)
        MENUITEMINFO.SetVal 44, 0, 4
        MENUITEMINFO.SetVal MIIM_TYPE Or MIIM_STATE, 4, 4
        MENUITEMINFO.SetVal Api.StrPtr(pszText), 36, 4
        MENUITEMINFO.SetVal Len(pszText), 40, 4
        If Api.ECall("user32", "GetMenuItemInfoW", Menu, Index, True, MENUITEMINFO.GetPtr(0)) Then
            If Mode And 1 Then
                pszText = Val
                MENUITEMINFO.SetVal Api.StrPtr(pszText), 36, 4
                MENUITEMINFO.SetVal Len(pszText), 40, 4
            End If
            fState = MENUITEMINFO.ReadVal(12, 4)
            If Mode And 2 Then
                fState = fState And Not MF_CHECKED
            ElseIf Mode And 4 Then
                fState = fState Or MF_CHECKED
            End If
            If Mode And 8 Then
                fState = fState And Not MFS_GRAYED
            ElseIf Mode And 16 Then
                fState = fState Or MFS_GRAYED
            End If
            MENUITEMINFO.SetVal fState, 12, 4
            SetMenu = Api.ECall("user32", "SetMenuItemInfoW", Menu, Index, True, MENUITEMINFO.GetPtr(0))
        End If
    End Function
    Public Sub ListBox_MouseUp(Button, Shift, x, y)
        Dim i, Index
        If Button = 2 Then
            With Form.Controls("ListBox").object.ListBox
                Call SetMenu(hMenu1(0), 10 - 1, 1, "提取名字")
                Index = Globals("InGame")
                For i = 2 To Api.ECall("user32", "GetMenuItemCount", hMenu1(0))
                    Call SetMenu(hMenu1(0), i - 1, IIf(Index > 0, 16, 8), "")
                Next
                Index = Menu.Pop(.hWnd, hMenu1(0), x, y)
                ' Call SetMenu(hMenu1(0), Index - 1, 1 + 4 + 16, "测试")
                ' Dim pszText
                ' pszText = Space(255)
                'MsgBox Left(pszText, Api.ECall("user32", "GetMenuStringW", hMenu1(0), Index, pszText, Len(pszText), 0)), , Index
                Select Case Index
                Case 1
                    For i = 0 To .ListCount - 1
                        .Selected(i) = True
                    Next
                Case 2
                    .RemoveItem .ListIndex
                Case 3
                    Call ListBox_Clear
                Case 5
                    Dim Names
                    Names = GetGameNames("QQ飞车*【*区】*")
                    If UBound(Names) >= 0 Then
                        Call ListBox_Clear
                    End If
                    For i = 0 To UBound(Names)
                        .AddItem Names(i)
                    Next
                End Select
            End With
        End If
        Form.Refresh
    End Sub

    Public Sub ListBox_MouseMove(Button, Shift, x, y)
        Select Case CLng(x / Globals("Screen").TwipsPerPixelX)
        Case &H202
            With Form
                If .WindowState = 1 Then
                    .WindowState = 0
                    .Visible = True
                End If
                Call Api.ECall("user32", "SetForegroundWindow", .hWnd)
            End With
        End Select
    End Sub
    Private Sub ListBox_Clear()
        With Form.Controls("ListBox").object.ListBox
            .Clear
            Globals("QQSpeed").RemoveAll
        End With
    End Sub
    Private Function GetGameNames(Name)
        Dim hWnds, i, v, ret()
        hWnds = Window.EnumWindows(0, "GAMEAPP", Name, 2)
        If UBound(hWnds) = -1 Then
            GetGameNames = Array()
            Exit Function
        End If
        ReDim ret(UBound(hWnds))
        For i = 0 To UBound(hWnds)
            v = Split(Window.GetText(hWnds(i)), "【")
            ret(i) = Left(v(3), InStr(v(3), "】") - 1)
        Next
        GetGameNames = ret
    End Function

    Private Function ComboBoxStyle(Control, List, ListIndex)
        Dim v, i, ChildHwnd
        Const GWL_STYLE = (-16)
        Const GW_CHILD = 5
        v = Split(List, "|")
        With Control
            For i = 0 To UBound(v)
                .AddItem v(i)
            Next
            .ListIndex = ListIndex
            ChildHwnd = Api.ECall("user32.dll", "GetWindow", .hWnd, GW_CHILD)
            Call Api.ECall("user32.dll", "DestroyWindow", ChildHwnd)
            Call Api.ECall("user32.dll", "SetWindowLongA", .hWnd, GWL_STYLE, Api.ECall("user32.dll", "GetWindowLongA", .hWnd, GWL_STYLE) + 1)
        End With
    End Function
    Public Sub Form_LoadOver()  '防止杀毒 挂起卡住界面'
        Dim v, i
        If Starting = 0 Then Class_Terminate
        Starting = 2
        v = Array("http://www.bccn.net/paste/4338", "QQSpeed", 128, _
        "ivmowo310ib", "", ".\plugin\dmsoft\dm.dll", "imFbdosa3za", "QMPlugin.bgkms6_10", ".\plugin\bgkms.dll")
        i = (UBound(v) + 1) \ 3
        Form.Tag = "0/" & i
        Me.Caption = "QQ群:123066586     正在加载数据(0/" & i & ")..."
        Form.MousePointer = 13
        Form.Tag = HttpLoaderEx(v, Me, "HttpOver") & "/" & i
        Api.NewHttp().GetHttpEx "https://www.yuque" & Chr(46) & "com/api/docs/tb66hu?book_id=19888673", Array(Me, "ReadMe", ".\使用说明.txt")
    End Sub
    Public Sub ReadMe(xmlhttp, Args)
        If xmlhttp.ReadyState = 4 Then
            Dim html
            Set html = CreateObject("htmlfile")
            With html
                .parentWindow.execScript "iData ='" & CString.GetMid(xmlhttp.responseText, """content"":""", """,""selected_at""", , 2) & "'"
                .Write .parentWindow.iData
                File.WriteText Args, .body.innerText
            End With
        End If
    End Sub
    Public Sub HttpOver(xmlhttp, Args)
        If HttpClass(xmlhttp, Args) Then
            Dim v, i
            v = Split(Form.Tag, "/")
            v(0) = v(0) + 1
            Form.Tag = v(0) & "/" & v(1)
            Me.Caption = "QQ群:123066586     正在加载数据(" & Form.Tag & ")..."
            If v(0) = Int(v(1)) Then
                Me.Caption = "QQ飞车火线追击"
                Form.MousePointer = 0

                Args = Split(File.ReadINI(AppName, "定时功能", config), "|")
                Set v = CString.Array()
                For i = 1 To UBound(Args)
                    If Left(Args(i), 1) = "1" Then
                        v.push times(File.ReadINI(AppName, Mid(Args(i), 2), config), 0) & "|" & Mid(Args(i), 2)
                    End If
                Next
                timing = Api.ArrayFormat(v.sort())
                With Form.Controls.Add("VB.Timer", "Timer")
                    .Interval = 500
                    .Enabled = True
                End With
                Form.SetEvent Form.Controls("Timer"), Me, "Timer"  '没句柄的对象事件'

                ' Call Api.Shell("regsvr32 plugin\*.dll /s", 0)
                ' Call Api.Shell("regsvr32 plugin\*.ocx /s", 0)
                v = Array("dmsoft\dm.dll", "bgkms.dll")
                On Error Resume Next
                For i = 0 To UBound(v)
                    Call Api.ECall(".\plugin\" & v(i), "DllRegisterServer") '注册插件'
                Next
            End If

        End If
    End Sub
    Public Property Let Caption(Text)
        Call Api.ECall("user32.dll", "SetWindowTextW", Form.hWnd, Text)
    End Property
    Public Property Get Caption()
        Caption = Form.Caption
    End Property
    Private Function IIf(p, a, b)
        If p Then
            IIf = a
        Else
            IIf = b
        End If
    End Function
    Public Sub UnLoad()
        Class_Terminate
    End Sub
    Public Sub Form_Unload(Cancel)
        If Globals("InGame") Then Cancel = MsgBox("游戏进行中,确定了要退出?", 4096 + 1, "关闭窗口") - 1
        If Cancel = 0 Then '关闭'
        End If
    End Sub
    Private Sub Class_Initialize()
        'Call Api.ECall("comctl32.dll", "InitCommonControls")
        Set Globals("QQSpeed") = CreateObject("Scripting.Dictionary")
        Call Create
    End Sub
    Private Sub Class_Terminate()
        On Error Resume Next
        Tip.Remove
        'Api.UnloadFrom Form
        Call Api.ECall("kernel32", "TerminateProcess", -1, 0)
    End Sub
End Class