--[[
飺
    źԶű޸ԼҪݡ
    źſݼźͼ귢źŶԶ

£
[200999]
Alt+СͼźԶ֧
[2010412]
Alt+źŵͬģʽٳĿԡ
[2010426]
Ż˴룬ų˷źԶᵼʧ⡣

                                       ߣҹ
                                                              ]]

--ű

if getwshscriptversion() < 4 then
    msgbox('ʹø߰汾')
end

--û޸Ĵ
sTalkMsg='ħ޳ѡ-----עźŵص-----'       --źź
--û޸Ĵ

iPressState=0

setmousewatchex('mousehookfuncex')
setmousewatch('mousehookfunc')
setkeywatch('keyhookfunc')

function mousehookfuncex(msg, x, y)
    if 0==iswar3front() then return 0 end
    war3w = getwar3window()
    win3wl,win3wr,win3wt,win3wb = getclientrect(war3w)
    mx=(win3wr-win3wl)*0.195
    my=(win3wb-win3wt)*0.761
    mw=(win3wr-win3wl)*0.0265
    mh=(win3wb-win3wt)*0.0325
    mx,my = clienttoscreen(war3w, mx, my)
    if x>mx and y>my and x<(mx+mw) and y<(my+mh) then
        if msg==11 then 
            mouseup(0)
            iPressState=1
            return 1
        end
    end
end

function mousehookfunc(msg)
    if 0==iswar3front() then return 0 end
    if 0==isplaying() then return 0 end
    if iPressState==1 then
        if msg==11 then
            talk(sTalkMsg,0)
            iPressState=0
            return 0
        end
    end
    if (1==getcontrolkeystate(1) or 1==getcontrolkeystate(2)) and 11==msg then
            keydown(18)
            sleep(10)
            mousedown(0)
            sleep(10)
            mouseup(0)
            sleep(10)
            keyup(18)
            sleep(10)
            talk(sTalkMsg,0)
            return 1
    end
end

function keyhookfunc(keycode, controlkeycode, downorup)        
    if 0==iswar3front() then return 0 end
    if 0==isplaying() then return 0 end
    if 71==keycode and (1==controlkeycode or 2==controlkeycode) and downorup==0 then
        iPressState=1
        return 0
    end
end
