#code=936T950
TEAM ENVI^ ENVIMODE=1| ENVI^ FORCELOCAL=1
IFEX OSK.LOG, LOGS * OSK.LOG
SET &NA_NFOCUS=-na
FIND $%~1=-na, SET NA_NFOCUS=-na! FIND $%~1=-nfocus, SET NA_NFOCUS=-nfocus
SET &Dou=,
//系统设置大字体时缩小界面字体: 5大代码
TEAM ENVI &Font_Size=| REGI #HKCU\Control Panel\Desktop\WindowMetrics\AppliedDPI,&&Font_Size
IFEX $%&Font_Size%=0x78, ENVI &&Font_Size=7! ENVI &&Font_Size=9 // 0x60为100%，0x78为125%，0x90为150%
ENVI &&Font_Cmd=IFEX %windir%\fonts\simsun*, ENVI @this.Font=%&Font_Size%:simsun! ENVI @this.Font=%&Font_Size%
CALL @*WIN1

_SUB WIN1,W855H285,软键盘,OnClose,,5,,-top %NA_NFOCUS% //-na //-nfocus //5改为#，变成无边框，无标题
    %&Font_Cmd%
    TEAM SET &bCaps=0| SET &bLShift=0| SET &bRShift=0| SET &bShift=0| SET &bCtrl=0| SET &bRCtrl=0| SET &bLCtrl=0|SET &bWin=0
    TEAM SET &bAlt=0| SET &bRAlt=0| SET &bLAlt=0|SET &bWin=0| SET &bRWin=0| SET &bLWin=0| SET &bNum=0| SET &bScroll=0|SET &bPause=0
    //人造标题栏
    //ENVI @this.HitTest=30:736:30 
    //LABE -vcenter -3D  Title,L30T1W736H18,软键盘,,
    //ITEM -b ITEM2,L769T1W18H18,_,ENVI @this.Visable=*4,
    //ITEM -b ITEM1,L789T1W18H18,X,KILL \,
    //ENVI @Title.bkcolor=0xFF0000


    ITEM -b IESC,L16T24W30H24,Esc,SEND VK_ESCAPE,
    ITEM -b IF1,L92T24W30H24,F1,SEND VK_F1,
    ITEM -b IF2,L130T24W30H24,F2,SEND VK_F2,
    ITEM -b IF3,L168T24W30H24,F3,SEND VK_F3,
    ITEM -b IF4,L206T24W30H24,F4,SEND VK_F4,

    ITEM -b IF5,L254T24W30H24,F5,SEND VK_F5,
    ITEM -b IF6,L292T24W30H24,F6,SEND VK_F6,
    ITEM -b IF7,L330T24W30H24,F7,SEND VK_F7,
    ITEM -b IF8,L368T24W30H24,F8,SEND VK_F8,

    ITEM -b IF9,L414T24W30H24,F9,SEND VK_F9,
    ITEM -b IF10,L454T24W30H24,F10,SEND VK_F10,
    ITEM -b IF11,L492T24W30H24,F11,SEND VK_F11,
    ITEM -b IF12,L530T24W30H24,F12,SEND VK_F12,


    ITEM -b ITop,L16T59W30H30,`,XSEND #0xC0,
    ITEM -b I1,L54T59W30H30,1, XSEND 1 ,
    ITEM -b I2,L92T59W30H30,2,XSEND 2 ,
    ITEM -b I3,L130T59W30H30,3,XSEND 3 ,
    ITEM -b I4,L168T59W30H30,4,XSEND 4 ,
    ITEM -b I5,L206T59W30H30,5,XSEND 5 ,
    ITEM -b I6,L244T59W30H30,6,XSEND 6 ,
    ITEM -b I7,L282T59W30H30,7,XSEND 7 ,
    ITEM -b I8,L320T59W30H30,8,XSEND 8 ,
    ITEM -b I9,L358T59W30H30,9,XSEND 9 ,
    ITEM -b I0,L394T59W30H30,0,XSEND 0 ,
    ITEM -b I_,L434T59W30H30,-,XSEND - ,
    ITEM -b IEQ,L472T59W30H30,=,XSEND = ,
    ITEM -b IEQ,L510T59W50H30,BackSpa,XSEND VK_BACK,


    ITEM -b ITAB,L16T96W40H30,Tab,XSEND #9 ,
    ITEM -b IQ,L73T96W30H30,q,XSEND q ,
    ITEM -b IW,L111T96W30H30,w,XSEND w,
    ITEM -b IE,L149T96W30H30,e,XSEND e,
    ITEM -b IR,L187T96W30H30,r,XSEND r,
    ITEM -b IT,L225T96W30H30,t,XSEND t,
    ITEM -b IY,L263T96W30H30,y,XSEND y,
    ITEM -b IU,L301T96W30H30,u,XSEND u,
    ITEM -b II,L339T96W30H30,i,XSEND i,
    ITEM -b IO,L377T96W30H30,o,XSEND o,
    ITEM -b IP,L415T96W30H30,p,XSEND p,
    ITEM -b IML,L453T96W30H30,[,XSEND [,
    ITEM -b IMR,L491T96W30H30,],XSEND ],
    ITEM -b ISLASH,L530T96W30H30,\,XSEND \,


    ITEM -b ICaps,L16T133W60H30,Caps,*PinPong ICaps bCaps  VK_CAPITAL VK_CAPITAL 1,
    ITEM -b IA,L92T133W30H30,a,XSEND a ,
    ITEM -b IS,L130T133W30H30,s,XSEND s ,
    ITEM -b ID,L168T133W30H30,d,XSEND d ,
    ITEM -b IF,L206T133W30H30,f,XSEND f ,
    ITEM -b IG,L244T133W30H30,g,XSEND g ,
    ITEM -b IH,L282T133W30H30,h,XSEND h ,
    ITEM -b IJ,L320T133W30H30,j,XSEND j ,
    ITEM -b IK,L358T133W30H30,k,XSEND k ,
    ITEM -b IL,L394T133W30H30,l,XSEND l ,
    ITEM -b IFen,L434T133W30H30,;,XSEND #0xBA 
    ITEM -b IQU,L472T133W30H30,',XSEND #222 ,
    ITEM -b IEN,L510T133W50H30,Ent,XSEND #0xD ,


    ITEM -b ILShift,L16T170W90H30,Shift,*PinPong ILShift bLShift VK_LSHIFT_  VK_LSHIFT^ 1,
    ITEM -b IZ,L111T170W30H30,z,XSEND z,
    ITEM -b IX,L149T170W30H30,x,XSEND x,
    ITEM -b IC,L187T170W30H30,c,XSEND c,
    ITEM -b IV,L225T170W30H30,v,XSEND v,
    ITEM -b IB,L263T170W30H30,b,XSEND b,
    ITEM -b IN,L301T170W30H30,n,XSEND n,
    ITEM -b IM,L339T170W30H30,m,XSEND m,
    ITEM -b IDou,L377T170W30H30,%Dou%,XSEND #0xBC,
    ITEM -b IDot,L415T170W30H30,.,XSEND . ,
    ITEM -b IAsk,L453T170W30H30,?,XSEND ?,
    ITEM -b IRShift,L491T170W69H30,Shift,*PinPong IRShift bRShift VK_RSHIFT_  VK_RSHIFT^ 1,


    ITEM -b ILCtrl,L16T207W55H30,Ctrl,*PinPong ILCtrl bLCtrl VK_LCONTROL_  VK_LCONTROL^,
    ITEM -b ILWIN,L82T207W35H30,Win,*PinPong ILWIN bLWin VK_LWIN_  VK_LWIN^,
    ITEM -b ILALT,L125T207W35H30,Alt,*PinPong ILALT bLAlt VK_LMENU_  VK_LMENU^,
    ITEM -b ISPACE,L168T207W220H30,,XSEND VK_SPACE,
    ITEM -b IRALT,L394T207W35H30,Alt,*PinPong IRALT bRAlt VK_RMENU_  VK_RMENU^,
    ITEM -b IRWIN,L439T207W35H30,Win,*PinPong IRWIN bRWin VK_RWIN_  VK_RWIN^,
    ITEM -b IPRT,L482T207W35H30,Prt,SEND #0x11_%&Dou%P%&Dou%#0x11^
    ITEM -b IRCtrl,L525T207W35H30,Ctrl,*PinPong IRCtrl bRCtrl VK_RCONTROL_  VK_RCONTROL^,


    ITEM -b IPrtSc,L570T59W30H30,PrtS,XSEND VK_SNAPSHOT,
    ITEM -b IScroll,L608T59W30H30,Scrl,*PinPong IScroll bScroll VK_SCROLL  VK_SCROLL,
    ITEM -b IPause,L648T59W30H30,Paus,*PinPong IPause bPause VK_PAUSE  VK_PAUSE,

    ITEM -b IInsert,L570T96W30H30,Ins,XSEND VK_INSERT,
    ITEM -b IHome,L608T96W30H30,Home, XSEND VK_HOME ,
    ITEM -b IPageup,L648T96W30H30,PgUp,XSEND VK_PRIOR ,

    ITEM -b IDelete,L570T133W30H30,Del,XSEND VK_DELETE,
    ITEM -b IEnd,L608T133W30H30,End, XSEND VK_END ,
    ITEM -b IPageDown,L648T133W30H30,PgDn,XSEND VK_NEXT ,

    ITEM -b IUp,L608T170W30H30,↑, XSEND VK_UP ,

    ITEM -b ILeft,L570T207W30H30,←,XSEND VK_LEFT,
    ITEM -b IDown,L608T207W30H30,↓, XSEND VK_DOWN ,
    ITEM -b IRight,L648T207W30H30,→,XSEND VK_RIGHT ,



    ITEM -b INum,L688T59W30H30,Num,*PinPong INum bNum VK_NUMLOCK  VK_NUMLOCK 2,
    ITEM -b IPadSlash,L726T59W30H30,/,XSEND #0x6F
    ITEM -b IPadMul,L766T59W30H30,*,XSEND #0x6A,
    ITEM -b IPadMin,L804T59W30H30,-,XSEND #0x6D

    ITEM -b IPad7,L688T96W30H30,Home,XSENDPad VK_NUMPAD7 VK_HOME,
    ITEM -b IPad8,L726T96W30H30,↑,XSENDPad VK_NUMPAD8 VK_UP,
    ITEM -b IPad9,L766T96W30H30,PgUp,XSENDPad VK_NUMPAD8 VK_PRIOR,
    ITEM -b IPadAdd,L804T96W30H67,+,XSEND #0x6B,

    ITEM -b IPad4,L688T133W30H30,←,XSENDPad VK_NUMPAD4 VK_LEFT,
    ITEM -b IPad5,L726T133W30H30, ,XSENDPad VK_NUMPAD5 "",
    ITEM -b IPad6,L766T133W30H30,→,XSENDPad VK_NUMPAD6 VK_RIGHT,

    ITEM -b IPad1,L688T170W30H30,End,XSENDPad VK_NUMPAD1 VK_END,
    ITEM -b IPad2,L726T170W30H30,↓,XSENDPad VK_NUMPAD2 VK_DOWN,
    ITEM -b IPad3,L766T170W30H30,PgDn,XSENDPad VK_NUMPAD3 VK_NEXT,
    ITEM -b IPadEnter,L804T170W30H67,Ent,XSEND #0x0D,

    ITEM -b IPad0,L688T207W68H30,Ins,XSENDPad VK_NUMPAD0 VK_INSERT,
    ITEM -b IPadDot,L766T207W30H30,Del,XSENDPad VK_DECIMAL VK_DELETE 


    ITEM -b IF1,L570T24W30H24,Mult,SEND #0xAD,
    ITEM -b IF2,L608T24W30H24,Vol-,SEND #0xAE,
    ITEM -b IF3,L648T24W30H24,Vol+,SEND #0xAF,
    ITEM -b IF4,L688T24W30H24,NoIn,SEND #0xAE,

    ITEM -b IF7,L726T24W30H24,▕←,SEND #0xB1,
    ITEM -b IF8,L766T24W30H24,→║,SEND #0xB3,
    ITEM -b IF9,L804T24W30H24,→▏,SEND #0xB0,
//    ITEM -b IF6,L254T244W30H24,Lock,SHUT K,

    CheckKey
    TIME  TK,1000, @CheckKey

    SET &bCaps0=%bCaps%
    SET &bNum0=%bNum%
    SET &bScroll0=%bScroll%
_END

_SUB CheckKey
    @WAIT -scanall &V
    @FIND $%&V0%<>%&V%,
    {*  @TEAM SET &bCaps1=%bCaps%| SET &bNum1=%bNum%| SET &bScroll1=%bScroll%| SET &bPause1=%bPause%
        @TEAM MSTR  &Key=<21>%&V%|  CALC &bCaps= %&Key% & 1     //CAPLOCK 20+1//    低位是否亮(乒乓状态)
        @TEAM MSTR  &Key=<145>%&V%|  CALC &bNum= %&Key% & 1     //NUM 144+1//    低位是否亮(乒乓状态)
        @TEAM MSTR  &Key=<146>%&V%|  CALC &bScroll= %&Key% & 1  //ScrLOCK 145+1//    低位是否亮(乒乓状态)
        @TEAM MSTR  &Key=<20>%&V%|  CALC &bPause= %&Key% & 1    //PAUSE 19+1//    低位是否亮(乒乓状态)
        
        IFEX $%bCaps%<>%bCaps1%, UpdateCase
        IFEX $%bNum%<>%bNum1%, UpdateNum
        IFEX $%bCaps%<>%bCaps1%,!! IFEX $%bCaps%>0, ENVI @ICaps.bkcolor=0x80FF80!ENVI @ICaps.bkcolor=-1
        IFEX $%bNum%<>%bNum1%,!! IFEX $%bNum%>0, ENVI @INum.bkcolor=0x80FF80!ENVI @INum.bkcolor=-1
        IFEX $%bScroll%<>%bScroll1%,!! IFEX $%bScroll%>0, ENVI @IScroll.bkcolor=0x80FF80!ENVI @IScroll.bkcolor=-1
        IFEX $%bPause%<>%bPause1%,!! IFEX $%bPause%>0, ENVI @IPause.bkcolor=0x80FF80!ENVI @IPause.bkcolor=-1
    }
_END


_SUB OnClose
    IFEX $%&bLShift%>0, SEND VK_LSHIFT^
    IFEX $%&bRShift%>0, SEND VK_RSHIFT^
    IFEX $%&bLCtrl>0, SEND VK_LCONTROL^
    IFEX $%&bRCtrl%>0, SEND VK_RCONTROL^
    IFEX $%&bLAlt%>0, SEND VK_LMENU^
    IFEX $%&bRAlt%>0, SEND VK_RMENU^
    IFEX $%&bLWin%>0, SEND VK_LWIN^
    IFEX $%&bRWin%>0, SEND VK_RWIN^
    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| ENVI @IR=R| ENVI @IT=T| ENVI @IY=Y| ENVI @IU=U
        TEAM ENVI @II=I| ENVI @IO=O| ENVI @IP=P| ENVI @IA=A| ENVI @IS=S| ENVI @ID=D| ENVI @IF=F
        TEAM ENVI @IG=G| ENVI @IH=H| ENVI @IJ=J| ENVI @IK=K| ENVI @IL=L| ENVI @IZ=Z| ENVI @IX=X
        TEAM ENVI @IC=C| ENVI @IV=V| ENVI @IB=B| ENVI @IN=N| ENVI @IM=M
    }!
    {*  TEAM ENVI @IQ=q| ENVI @IW=w| ENVI @IE=e| ENVI @IR=r| ENVI @IT=t| ENVI @IY=y| ENVI @IU=u
        TEAM ENVI @II=i| ENVI @IO=o| ENVI @IP=p| ENVI @IA=a| ENVI @IS=s| ENVI @ID=d| ENVI @IF=f
        TEAM ENVI @IG=g| ENVI @IH=h| ENVI @IJ=j| ENVI @IK=k| ENVI @IL=l| ENVI @IZ=z| ENVI @IX=x
        TEAM ENVI @IC=c| ENVI @IV=v| ENVI @IB=b| ENVI @IN=n| ENVI @IM=m
    }
    IFEX $%bShift%>0,
    {*  TEAM ENVI @ITop=~| ENVI @I1=!| ENVI @I2=@| ENVI @I3=#| ENVI @I4=$| ENVI @I5=%| ENVI @I6=^
        TEAM ENVI @I7=&&| ENVI @I8=*| ENVI @I9=(| ENVI @I0=)| ENVI @I_=_| ENVI @IEQ=+| ENVI @ISLASH=|||
        TEAM ENVI @IFen=:| ENVI @IDou=<| ENVI @IDot=>| ENVI @IAsk=?|ENVI @IML={|ENVI @IMR=}| ENVI @IQU="
    }!
    {*  TEAM ENVI @ITop=`| ENVI @I1=1| ENVI @I2=2| ENVI @I3=3| ENVI @I4=4| ENVI @I5=5| ENVI @I6=6
        TEAM ENVI @I7=7| ENVI @I8=8| ENVI @I9=9| ENVI @I0=0| ENVI @I_=-| ENVI @IEQ==| ENVI @ISLASH=\
        TEAM ENVI @IFen=;| ENVI @IDou=,| ENVI @IDot=.| ENVI @IAsk=/|ENVI @IML=[|ENVI @IMR=]|  ENVI @IQU='
    }
    ENVI @this.InvalidateRect=::::1
_END

_SUB UpdateNum
    IFEX $%bNum%>0,
    {*  TEAM ENVI @IPad0=0| ENVI @IPad1=1| ENVI @IPad2=2| ENVI @IPad3=3| ENVI @IPad4=4| ENVI @IPad5=5
        TEAM ENVI @IPad6=6| ENVI @IPad7=7| ENVI @IPad8=8| ENVI @IPad9=9| ENVI @IPadDot=.
    }!
    {*  TEAM ENVI @IPad0=Ins| ENVI @IPad1=End| ENVI @IPad2=↓| ENVI @IPad3=PgDn| ENVI @IPad4=←| ENVI @IPad5=
        TEAM ENVI @IPad6=→| ENVI @IPad7=Home| ENVI @IPad8=↑| ENVI @IPad9=PgUp| ENVI @IPadDot=Del
    }
    ENVI @this.InvalidateRect=::::1
_END

//ICapsU bCaps  VK_CAPITAL,
_SUB PinPong 
    CALC &&bShift1=%bLShift% + %bRShift%
    SET &gnm=%1
    SET &vnm=%2
    SET~  &v=%vnm%
    --v[%&v%]
    CALC #v=1 - %&v%
    IFEX $%v%>0, ENVI @%gnm%.bkcolor=0x80FF80!ENVI @%gnm%.bkcolor=-1
    SET %vnm%=%v%
    IFEX $%v%>0, SEND  %~3!SEND  %~4
    CALC &&bShift2=%bLShift% + %bRShift%
    CALC &&bAlt2=%bLAlt% + %bRAlt%
    CALC &&bWin2=%bLWin% + %bRWin%
    IFEX $%bShift2%>%bShift1%, SET bShift=1! IFEX $%bShift2%<%bShift1%, SET bShift=0
    FIND $%~5=1,UpdateCase! FIND $%~5=2,UpdateNum
_END


_SUB XSEND 
    SEND %1
_END

_SUB XSENDPad 
    IFEX $%bNum%>0, SEND %~1!SEND %~2
_END


