DimEnv Hwnd  //定义环境变量(多线程需要)
Global Hwnd1 //定义全局变量(多线程需要)

MessageBox "点击窗口运行脚本"
WaitClick 
Hwnd = Plugin.Window.MousePoint() //得到鼠标指向的窗口句柄
Hwnd1=Hwnd
BeginThread 决战30  //启动线程 决战30
Delay 100    //延时100毫秒

ii=0
While ii=0
    //不要退出脚本
Wend
EndScript

Sub 决战30()
Hwnd2 = Hwnd1  //首先获取环境变量 窗口句柄 (用于后台执行)
//MessageBox "运行窗口句柄:" & Hwnd2
Call Plugin.Bkgnd.LeftClick(Hwnd2, 667, 30) //点击 日常标
Delay 2000
Call Plugin.Bkgnd.LeftClick(Hwnd2, 383, 124) //点击 决战签
Delay 2000
Call Plugin.Bkgnd.LeftClick(Hwnd2, 372, 294) //点击 30级决战
Delay 2000
Call Plugin.Bkgnd.LeftClick(Hwnd2, 473, 211) //点击 挂机停止

For 150
  Delay 1000
  Call Plugin.Bkgnd.LeftClick(Hwnd2, 510, 470) //点击 进入战场
  Delay 2000

  xxyy = Plugin.BkgndColor.FindColorEx(Hwnd2, 496, 215, 500, 218, "FFFFFF", 0, 0.9)
  dim okok //分割字符串
  okok = Split(xxyy, "|")
  xx = Clng(okok(0)): yy = Clng(okok(1)) //将字符串转换成数值
  If xx > 495 Then 
    Call Plugin.Bkgnd.LeftClick(Hwnd2, 500,214) //点击 ok
    //Msgbox "后台窗口颜色X坐标="& xx & "    Y坐标=" & yy 
    Exit For
  End If
Call Plugin.Bkgnd.LeftClick(Hwnd2, 352,467) //点击 开始战斗
Delay 3000
Call Plugin.Bkgnd.LeftClick(Hwnd2, 518,247) //点击 战斗胜利确定
next

MessageBox "今日决战任务完成"
End Sub