Call MyDelay()
            If IsTimeout > 4 Then //超时 2s
                Exit Do
            End If
        End If
    Loop	
End Sub
Sub CLoseAll()
    Do While True
        GameHwnd = Plugin.Window.Find(0, "三国 - Google Chrome")
        If GameHwnd = 0 Then 
            Exit Do
        End If
        Call CloseGame()
        Delay 500
    Loop
End Sub
Sub MyDelay()
    IsError = True
    IsTimeout = IsTimeout + 1
    Delay 500  //延时0.5ms
End Sub
Sub FindMilitary
    //找军事按钮
    IsTimeout = 0
    Do While True
        FindPic 0,0,1024,768,"Attachment:\军事.bmp",0.9,intX,intY
        If intX > 0 And intY > 0 Then 
            //关闭抽奖
            Call CloseLottery
            FindPic 0,0,1024,768,"Attachment:\军事.bmp",0.9,intX,intY
            If intX > 0 And intY > 0 Then
                
                MouseClick intX, intY, 1
                IsError = False
            End if
            Exit Do
        Else 
            Call MyDelay()
            If IsTimeout > 20 Then //超时 10s
                Exit Do
            End If
        End If
    Loop
End Sub
Sub FindLdle()
    //找空闲武将
    IsLdle = False  //假调没有空闲武将
    IsTimeout = 0
    Do While True
        FindPic 526,300,606,700, "Attachment:\命令.bmp", 0.9, intX, intY
        If intX > 0 And intY > 0 Then 
            FindPic 526,300,606,700, "Attachment:\空闲.bmp", 0.9, intX, intY
            If intX > 0 And intY > 0 Then 
                IsLdle = True //找到空闲武将 
                MouseClick intX,intY,1
                IsError = False
                Exit Do
            Else
                IsLdle = False
                Exit Do
            End if
        Else
            Call MyDelay()
            If IsTimeout > 20 Then //超时 10s
                Exit Do
            End If
        End If
    Loop	
End Sub
//程序开始
Call SetUser
nIndex = 0
Call Main()
ExitScript
//------------------------------
Sub Start()
    Do WHile True
        Call FindLdle() //找空间武将
        If IsLdle Then 
            IsTimeout = 0
            Do While True
                FindPic 0,0,1024,768, "Attachment:\配兵.bmp", 0.9, intX, intY
                If intX > 0 And intY > 0 Then 
                    MouseClick intX,intY,1
                    IsError = False
                    Exit Do
                Else 
                    Call MyDelay()
                    If IsTimeout > 20 Then //超时 10s
                        Exit Do
                    End If                
                End If
            Loop
            //开始配兵
            IsTimeout = 0
            Do While True  
                FindPic 0,0,1024,768, "Attachment:\修改.bmp", 0.9, intX, intY
                If intX > 0 And intY > 0 Then 
                    MouseClick intX+3,intY+3,1