呵呵,源码如下:
主程序
- @echo off&setlocal enabledelayedexpansion
- mode con cols=50 lines=10&color 1f
- title 幸运观众抽奖软件 made by batman
- for /f "delims=" %%i in (a.txt) do set /a total+=1
- set "m=0"&echo 中奖名单:>name.txt
- :begin
- for /f "tokens=2 delims= " %%i in ('tasklist^|findstr "cmd.exe"') do set "pid=%%i"&goto next
- :next
- cls&echo.&echo ========^> 幸运抽奖 ^<========
- echo.&echo 总共有%total%名现场观众参与抽奖
- if %m% equ 0 echo.&set /p num= 请输入要抽取的人数:
- echo %num%|findstr "[^0-9]">nul&&goto begin
- if %num% geq %total% goto begin
- echo.&echo 请按任意键开始抽奖&pause>nul
- :again
- start lp.exe&set /a v=num-m
- cls&echo.&echo 已抽取%m%名幸运观众,还剩余%v%名
- echo.&echo 名单正在滚动中...
- echo.&echo 请按任意键抽取幸运观众&pause>nul
- for /f "tokens=2 delims= " %%i in ('tasklist^|findstr "cmd.exe"') do (
- if "%%i" neq "%pid%" taskkill /pid %%i /f>nul 2>nul
- )
- :loop
- set /a a=%random%%%%total%+1,n=0
- for /f "delims=" %%i in (a.txt) do (
- set /a n+=1
- if !n! equ %a% (
- findstr "%%i" 中奖.txt>nul&&goto loop||set "str=%%i"
- )
- )
- cls&echo.&echo.&echo 本次抽取的幸运观众是:%str%
- echo.&echo 请按任意键继续抽奖&pause>nul
- echo %str%>>name.txt
- set /a m+=1
- if %m% neq %num% goto again
- echo.&echo 所有幸运观众已抽取完毕,请按任意键退出
- pause>nul
复制代码
副程序
- @echo off&mode con cols=50 lines=5&color 1c
- title ***抽 奖 滚 动 窗 口***
- :lp
- for /f "delims=" %%a in (a.txt) do (
- echo %%a
- for /l %%i in (1,1,100) do echo>nul
- )
- goto lp
复制代码
|