@TEAM ENVI^ EnviMode=1|ENVI^ ForceLocal=1   //这个不能掉了，否则显示失真
//LOGS * X.LOG
SET  WM_SIZE=0x0005
SET SIZE_MAXHIDE=4
SET SIZE_MAXSHOW=3
SET SIZE_MAXIMIZED=2
SET SIZE_MINIMIZED=1
SET SIZE_RESTORED=0
SET$ &NL=0d 0a
SET$ &TAB=09
SET  ::WM_LBUTTONDOWN=0x0201
SET  ::WM_RBUTTONDOWN                  =0x0204
SET  ::WM_KEYDOWN                      =0x0100
SET-def VK_DELETE=46 

_SUB WIN1,W750H680,进程管理器PECMD%PECMDVER%,,,,, -maxb -size 
    ENVI I=0
    SET-def  run=1
    SET-def  All=
    SET-def  pause=0
    ITEM -def ITEM3,L220T10W40H25,刷新, CALL OnT1 
    CHEK BAUTO,L70T10W50H25,自动, CALL OnAuto,1  
    EDIT  -vcenter IntMs,L130T10W60H25,1000 
    SET &TITLE=50:进程号%TAB%=50:父进程%TAB%=60:内存%TAB%=0:CPU时间%TAB%=0:总时间%TAB%240:文件%TAB%550:命令行
    TABL E1,L15T40W475H150,%TITLE%,%DrvVolDat%,0x10040
    ENVI @E1.MSG=_%&::WM_LBUTTONDOWN%:CALL OnTable
    ENVI @E1.MSG=_%&::WM_RBUTTONDOWN%: CALL @--popmenu       MyMenu1  //右键菜单
    ENVI @E1.MSG=_%&WM_KEYDOWN%::&&wParm,&&lParm,CALL OnKey %&wParm%  %&lParm% 
    ITEM ITEM4,L270T10W40H25,拷贝, ENVI^ Clipboard=%All%  

    ENVI @WIN1.MSG=%&WM_SIZE%::&&wParm,&&lParm,CALL OnSize_WIN1 %&wParm%  %&lParm% 
    SCRN -win  &&maxX,&&maxY 
    ENVI @this.POS=0:0:%&maxX%:%&maxY%
    @TEAM TIME  T1, 0, CALL OnT1
    CALL OnAuto 
_END
call @WIN1
_SUB OnTable
    FIND $1=%run%,! EXIT 
    ENVI @E1.Sel=?&&Sel
    IFEX $1>%&Sel%,EXIT
    ENVI @E1.Val=?%Sel%;&&V1
    ENVI^ Clipboard=%V1%
_END  

_SUB DoKill
    FIND $1=%run%,! EXIT 
    ENVI @E1.Sel=?&&Sel
    IFEX $1>%&Sel%,EXIT
    ENVI @E1.Val=?%Sel%.1;&&V1
    MESS 杀死进程 %V1%吗? @杀死进程#YN $N *5000
    FIND $YES=%&YESNO%,! EXIT
    KILL *%V1%
    
_END  

_SUB OnKey
    FIND $1=%run%,! EXIT
    IFEX $%&wParm%=%VK_DELETE%, CALL DoKill
_END  


_SUB MyMenu1
    FIND $1=%run%,! EXIT 
    ENVI @E1.Sel=?&&Sel
    IFEX $1>%&Sel%,EXIT
    MENU Menu1,拷贝, OnTable  
    MENU -
    MENU Menu2,杀死, DoKill  
_END

_SUB OnAuto
    IFEX $%BAUTO.Check%=1, CALL OnITEM2 ! CALL  OnITEM1
_END 
_SUB OnITEM1
    ENVI @T1=0
_END 
_SUB OnITEM2
    CALL OnT1
    CALC #IntMs=%IntMs%
    IFEX $%IntMs%<101, SET IntMs=1000
    ENVI @T1=%IntMs%
_END 
_SUB OnT1
    FIND $1=%pause%, EXIT 
    FIND --pid*@  &All,
    ENVI @E1.Val=?*;&&Lines 
    ENVI @E1.Val=1*#;%All%  //##清除尾部多余行
_END

_SUB OnSize_WIN1
   TEAM ENVI &&sz=0| ENVI &&w=0| ENVI &&h=0
   IFEX $%1 = %&SIZE_MAXIMIZED%, ENVI &sz=1
   IFEX $%1 = %&SIZE_MAXSHOW%, ENVI &sz=1
   IFEX $%1 = %&SIZE_RESTORED%, ENVI &sz=1
   IFEX $1=%&sz%,
   {
        ENVI &&LP=%2
        CALC #&w= %&LP% & 0xFFFF   //LOW
        CALC #&h= %&LP% / 0x10000  //HIGH

        CALC #&w= %&w% - 20
        CALC #&h= %&h% - 50
        
        ENVI @E1.POS=::%&w%:%&h%
   }
    
_END
