📄 dict.bat
字号:
:::::::::::::::::::::::::::::::::::::::::::::::::
:: dict.cmd -V0.1 -- 批处理在线查单词
:: 无奈何@cn-dos.net - 2007-1-2
:: 用法:dict [/F] word ...
:: 支持文件: - mplayer.exe wget.exe or curl.exe
:::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal ENABLEDELAYEDEXPANSION
set mp3file="%TEMP%\dict.mp3"
rem 依赖文件检查
:mplay
call mplayer >nul 2>nul
if "%ERRORLEVEL%" == "1" set nomplay=1
:wget
wget.exe >nul 2>nul
if not "%ERRORLEVEL%" == "9009" (
set "command1=wget -q -O - "
set "command2=wget -q -O %mp3file%"
goto star
)
:curl
curl.exe >nul 2>nul
if not "%ERRORLEVEL%" == "9009" (
set "command1=curl -s "
set "command2=curl -s -o %mp3file%"
goto star
)
echo.本脚本需要 wget 或 curl 的支持。
goto :EOF
:star
set flag=0
if "%~1" == "" goto help
if "%~1" == "?" goto help
if "%~1" == "/?" goto help
if "%~1" == "/F" shift &goto full
if "%~1" == "/f" shift &goto full
:next
if "%~1" == "" goto :EOF
set "word=%~1"
call :down
shift
goto :next
:full
if "%~1" == "" goto :EOF
set mp3=
del %mp3file% 2>nul
set "word=%~1"
call :down
%command2% "%mp3%"
echo.--------------------------------
if "%mp3%" == "" echo.[F]查看详解 [Q/A]退出 &goto :Nselect
echo.[R]朗读 [F]查看详解 [Q/A]退出
:Nselect
set select=
set /p select=请选择:
call :Parse
if "%quit%" == "1" goto :EOF
shift
goto :full
:Parse
for %%s in (R r F f A a) do if "%%s" == "%select%" goto Switch%select%
goto :EOF
:SwitchR
if "%nomplay%" == "1" echo. 播放影音需要 mplayer 支持。&goto :Nselect
start /min %ComSpec% /c "mplayer %mp3file%>nul"
goto :Nselect
goto :EOF
:SwitchF
start http://www.iciba.com/search?s=%word%
goto :Nselect
goto :EOF
:SwitchA
set quit=1
goto :EOF
:down
set url="http://dict.cn/ws.php?q=%word%"
echo.
echo.单词:%word%
echo.释义:
for /f "tokens=1,2,3 delims=<>" %%a in ('%command1% %url%') do (
if "%%a" == "audio" set "mp3=%%b"
if "%%b" == "Not Found" echo 无此单词^^! &goto :EOF
if "%%c" == "/def" echo %%b &goto :EOF
if "%%b" == "/def" echo %%a &set flag=0
if "!flag!" == "1" echo %%a
if "%%a" == "def" echo %%b &set flag=1
)
goto :EOF
:help
echo.批处理在线查单词
echo.
echo.用法:dict [/F] word ...
echo.
echo /F 完全模式查询单词。
echo word 可指定多个单词。
goto :EOF
无奈何发表于 2007-01-03 12:11
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -