var threadID
//从这里开始Doit


var threadID2, LoopSwitch1, LoopSwitch2

//
function Doit() 
    var dm = com("dm.dmsoft")
    var ret
    LoopSwitch1 = 1 
    while(LoopSwitch1) 
        ret = dllcall("user32.dll","long", "GetAsyncKeyState","long",1) 
        if(ret != 0) 
            threadID2=threadbegin("Doit2","") 
            
        end 
        // 
        while(ret != 0) 
            ret = dllcall("user32.dll","long", "GetAsyncKeyState","long",1) 
            sleep(20) 
        end 
        threadclose(threadID2) 
    end 
end 
// 
// 
function Doit2() 
    
    var dm = com("dm.dmsoft")
    LoopSwitch2 = 1
    var 当前x,当前y
    mousegetpoint(当前x,当前y)
    var speed = editgettext("speed1")
    var 频率 = editgettext("频率1")
    var 范围X1 = 当前x-200
    var 范围X2 = 当前x+200
    var 范围Y1 = 当前y-500
    var 范围Y2 = 当前y+500
    while(LoopSwitch2)
        var 找色x=-1,找色y=-1
        var ret=findcolor(范围X1,范围Y1,范围X2,范围Y2,"FE0013",0.9,0,找色x,找色y)
        if(ret>=0)
            var 敌人x =  找色x - 910 
            var 敌人y =  找色y - 470 
            dm.mover(敌人x * 0.5 * speed * 0.1 + 敌人x / 6,敌人y*speed*0.05*0.75)
            sleep(101-频率)
        end
    end
end 

function 启动_热键()
    threadID=threadbegin("Doit","")
end


function 终止_热键()
    threadclose(threadID)
end



function 走走走_初始化()
    
    
    var ABC = regdll("rc:dm.dll",true)
    if(ABC)
        messagebox("辅助初始化完成")
        var dm = com("dm.dmsoft")
        
    else
        messagebox("辅助初始化失败")
    end
    editsettext("speed1",filereadini("配置","速度","C:\\Peizhi.ini") )
    editsettext("频率1",filereadini("配置","频率","C:\\Peizhi.ini") )
end


function 按钮0_点击()
    filewriteini("配置","频率",editgettext("频率1"),"C:\\Peizhi.ini") 
    filewriteini("配置","速度",editgettext("speed1"),"C:\\Peizhi.ini") 
end




function 按钮1_点击()
    editsettext("speed1",filereadini("配置","速度","C:\\Peizhi.ini") )
    editsettext("频率1",filereadini("配置","频率","C:\\Peizhi.ini") )
end


function 按钮2_点击()
    //这里添加你要执行的代码
    editsettext("speed1",15)
    editsettext("频率1",91)
end
