IFEX D:\DEBUG_PECMD, LOGS *D:\DEBUG_PECMD.LOG 
TEAM ENVI^ EnviMode=1| ENVI^ ForceLocal=1
TEAM SET &SRC=| SET &TIMEMS=
ENVI &::WM_TRAYNOTIFY=1109  //tray 通知消息

SET  ::WM_LBUTTONDOWN                  =0x0201
SET  ::WM_LBUTTONUP                    =0x0202
SET  ::WM_LBUTTONDBLCLK                =0x0203
SET  ::WM_RBUTTONDOWN                  =0x0204
SET  ::WM_RBUTTONUP                    =0x0205
SET  ::WM_RBUTTONDBLCLK                =0x0206

SET  ::WM_SIZE=0x0005
SET  &SIZE_MINIMIZED=1  //最小化 

ENVI$  &&NL=0d 0a

CALC TIMEMS=60000 * 30  // 30min
SET SRC=%CurDir%\Wallpaper //默认配置 
SET TIMEMS=5000  //调试 

LOAD * %CurFile%.ini   //自定义配置 

WIN1 

_SUB WIN1,W411H249,定时换壁纸 PECMD%PECMDVER%,
    ENVI &&WID=%&&__WINID%
    TEAM SET &I=0| SET &FS=| SET &NUM=1| SET &F=
    TIME &Timer1,%TIMEMS%, THREAD* CALL OnTimer1
    TIME -t:1 &TimerInit,10, THREAD* CALL OnTimer1  //马上一次 
    EDIT -3D -vcenter &ESRC,L32T42W346H30,%SRC%,,
    ITEM &ITEM2,L154T143W101H30,换目录ChangeDir,CALL OnChange,
    ENVI @this.MSG=_%&::WM_TRAYNOTIFY%::&&wp,&&lp, CALL DoMenu %&wp% %&lp%   
    ENVI @this.MSG=_%&::WM_SIZE%::&&wp,&&lp, CALL OnSize %&wp% %&lp%   
_END

_SUB OnSize 
    IFEX $%&SIZE_MINIMIZED%=%1, OnHide
_END

_SUB OnHide
    ENVI @this.Visable=0 
    TIPS* 定时换壁纸,开始,,,#2
_END

_SUB OnExit
    KILL  \  
_END


_SUB OnShow
    TIPS*  //删除
    ENVI @@Visable=%&WID%:2  
    ENVI @@POS=%&WID%:::::4
    WAIT 50
    ENVI @@POS=%&WID%:::::2
_END

_SUB DoMenu
    IFEX $%&::WM_LBUTTONDOWN%=%2,!!  TEAM CALL  OnShow | EXIT
    IFEX $[ %::WM_LBUTTONDOWN%=%2 | %&WM_RBUTTONDOWN%=%2 ], CALL @--popmenu       MyMenu1
_END

_SUB MyMenu1
    MENU Menu1,还原,  CALL  OnShow
    MENU Menu2,换一个, THREAD* CALL OnTimer1
    MENU -
    MENU Menu2,退出, CALl OnExit
_END

_SUB  OnChange
    BROW &&dirp,*%&ESRC%,请选择一个壁纸目录
    FIND $X=X%dirp%, EXIT 
    ENVI @&ESRC=%dirp%
    SET SRC=%dirp% 
_END

_SUB  OnTimer1
    EXEC* FS=!cmd /c dir /b  %SRC%\
    READ -*,-1,NUM,FS 
    IFEX $%NUM%<1, EXIT _SUB
    // CALC #I=  %I%  % %NUM%  + 1  //顺序 
    CALC #I= ( %I% + %RANDOM% )  % %NUM%  + 1  //随机 
    READ -*,%I%,F,FS
    WALL %SRC%\%F%
     
_END




