#code=936T950
TEAM ENVI^ ENVIMODE=1| ENVI^ FORCELOCAL=1
IFEX OSK.LOG, LOGS * OSK.LOG
CALL @*WIN1 
_SUB WIN1,W756H271,软键盘,OnClose,,#,, -nfocus  -top  
    //人造标题栏
    ENVI @this.HitTest=30:676:30 
    LABE -vcenter -center -3D  Title,L30T1W676H18,软键盘,,
    ITEM -b ITEM2,L709T1W18H18,_,ENVI @this.Visable=*4,
    ITEM -b ITEM1,L729T1W18H18,X,KILL \,
    ENVI @Title.bkcolor=0xFF0000


    ITEM -b IESC,L16T24W39H30,Esc,SEND1 VK_ESC,
    ITEM -b IF1,L66T24W30H30,F1,SEND1 VK_F1,
    ITEM -b IF2,L104T24W28H30,F2,SEND1 VK_F2,
    ITEM -b ITop,L35T57W26H30,`,XSEND #0xC0,
    ITEM -b I15,L70T58W26H30,1, XSEND 1 ,
    ITEM -b I2,L101T59W29H30,2,XSEND 2 ,
    ITEM -b IQ,L85T96W31H30,q,XSEND q ,
    ITEM -b IW,L124T97W30H30,w,XSEND w,
    ITEM -b IE,L159T97W29H30,e,XSEND e,
    LABE -vcenter -center -mod ICapsU,L12T155W60H27,Caps,*PinPong ICapsU ICapsD bCaps 1 VK_CAPITAL,
    LABE -vcenter -center -3D ICapsD,L12T155W60H27,Caps,*PinPong ICapsD ICapsU bCaps 0 VK_CAPITAL,,-16 
    LABE -vcenter -center -mod IShiftU,L12T187W60H26,Shift,*PinPong IShiftU IShiftD bShift 1 VK_SHIFT_,
    LABE -vcenter -center -3D IShiftD,L12T187W60H26,Shift,*PinPong IShiftD IShiftU bShift 0 VK_SHIFT^,,
    ENVI @IShiftD.Visable=0 
    SET &bCaps=0
    SET &bShift=0

    WAIT -scanall &V
    FIND $%&V0%=%&V%, EXIT _SUB 
    
    MSTR  &Key=<21>%&V%  //CAPLOCK 20+1
    CALC &&bCAP= %&Key% & 1 //    低位是否亮(乒乓状态)
    IFEX $%bCAP%>0, TEAM ENVI @ICapsU.Visable=0| ENVI @ICapsD.Visable=1| SET bCaps=1
    UpdateCase
    SET &bCaps0=%bCaps%
_END

_SUB OnClose
    IFEX $%&bShift%>0, SEND VK_SHIFT^
    IFEX $%&bCaps%<>%bCaps0%, SEND VK_CAPITAL
_END



_SUB UpdateCase
    FIND $[ %bCaps%%bShift%=01 | %bCaps%%bShift%=10 ],
    {*  TEAM ENVI @IQ=Q| ENVI @IW=W| ENVI @IE=E
    }!
    {*  TEAM ENVI @IQ=q| ENVI @IW=w| ENVI @IE=e
    }
    IFEX $%bShift%>0, ENVI @ITop=~! ENVI @ITop=`
    ENVI @this.InvalidateRect=::::1
_END

_SUB PinPong 
    ENVI @%~1.Visable=0
    ENVI @%~2.Visable=1
    SET %3=%~4
    SEND  %~5
    UpdateCase
_END

_SUB XSEND 
    SEND %1
_END


_SUB SEND1 
    SEND %2! SEND %1
_END


