标题: [文本处理] 请大佬帮忙修改批处理运行后选择哪个直接跳转,谢谢。 [打印本页]
作者: 帝尊 时间: 2023-2-27 15:38 标题: 请大佬帮忙修改批处理运行后选择哪个直接跳转,谢谢。
- @ECHO OFF
-
- SET VERSIONS=download,uRL,cap,box
- SET /A DV=1
-
- SET PRESETS=1,2,3,4,5,6
- SET /A DP=4
-
- :BEGIN
-
- FOR %%V IN (1.2.3.4.5.6.7.8.9) DO FOR %%S IN (%CLT% %~N0 %*) DO IF /I %%~XV EQU .%%~S SET "CLT=%%~NV" & SET "VID=%%~S"
- IF DEFINED CLT IF NOT DEFINED VID SET "CLT="
-
- FOR %%S IN (%~N0 %*) DO IF /I %%S EQU AUTO SET /A AUTO=1
- IF DEFINED AUTO SET /A PRE=1 & IF NOT DEFINED CLT SET /A CLT=%DV% & IF %OS_VERSION%0 LSS 102400 SET /A CLT=13
-
- FOR %%S IN (%*) DO FOR %%P IN (1 2 3 4) DO IF %%~NS GTR 0 IF %%~NS LSS 15 IF %%~XS. EQU .%%P. SET /A PRE=%%P & SET /A CLT=%%~NS
-
- IF "%CLT%%PRE%"=="" CALL :CHOICES2 CLT "%VERSIONS%" %DV% "INVENTEC TOOLS BY CHEN.LEI" PRE "%PRESETS%" %DP% "BY CHEN.LEI" 11 WHITE 0X005A9E 320
- IF %CLT%0 LSS 1 IF %PRE%0 GTR 1 CALL :CHOICES CLT "%VERSIONS%" %DV% "INVENTEC TOOLS BY CHEN.LEI" 11 WHITE 0X005A9E 320
- IF %CLT%0 GTR 1 IF %PRE%0 LSS 1 CALL :CHOICES PRE "%PRESETS%" %DP% "BY CHEN.LEI" 11 WHITE 0X005A9E 320
- IF %CLT%0 GTR 1 IF %PRE%0 LSS 1 GOTO CHOICE-0 = CANCEL
- GOTO CHOICE-%CLT%
-
- :CHOICE-4
- ECHO 4
- TIMEOUT /T 3
- GOTO :EOF
-
- :CHOICE-3
- ECHO 3
- TIMEOUT /T 3
- GOTO :EOF
-
- :CHOICE-2
- ECHO 2
- TIMEOUT /T 3
- GOTO :EOF
-
- :CHOICE-1
- ECHO 1
- TIMEOUT /T 3
- GOTO :EOF
-
- :CHOICE-
- SET /A CLT=%DV% & SET /A PRE=%DP% & GOTO CHOICE-%DV%
-
- :CHOICE-0
- EXIT /B
-
- ::--------------------------------------------------------------------------------------------------------------------------------
- #:CHOICES:# [PARAMS] INDEXVAR "C,H,O,I,C,E,S" [OPTIONAL] DEFAULT-INDEX "TITLE" FONTSIZE BACKCOLOR FORECOLOR WINSIZE
- SET ^ #=;$F0=[IO.FILE]::READALLTEXT($ENV:0); $0=($F0-SPLIT '#\:CHOICES\:' ,3)[1]; $1=$ENV:1-REPLACE'([`@$])','`$1'; IEX($0+$1)
- SET ^ #=&SET "0=%~F0"& SET 1=;CHOICES %*& (FOR /F %%X IN ('POWERSHELL -NOP -C "%#%"') DO SET "%1=%%X")& EXIT /B
- FUNCTION CHOICES ($INDEX,$CHOICES,$DEF=1,$TITLE='CHOICES',[INT]$SZ=12,$BC='MIDNIGHTBLUE',$FC='SNOW',[STRING]$WIN='300') {
- [VOID][REFLECTION.ASSEMBLY]::LOADWITHPARTIALNAME('SYSTEM.WINDOWS.FORMS'); $F=NEW-OBJECT WINDOWS.FORMS.FORM; $GLOBAL:RET=''
- $BT=@(); $I=1; $CH=($CHOICES+',CANCEL').SPLIT(','); $CH |FOREACH {$B=NEW-OBJECT WINDOWS.FORMS.BUTTON; $B.FONT='CONSOLAS,'+$SZ
- $B.NAME=$I; $B.TEXT=$_; $B.MARGIN='0,0,9,9'; $B.LOCATION='9,'+($SZ*3*$I-$SZ); $B.MINIMUMSIZE=$WIN+',18'; $B.AUTOSIZE=1
- $B.ADD_GOTFOCUS({$THIS.BACKCOLOR=$FC; $THIS.FORECOLOR=$BC}); $B.ADD_LOSTFOCUS({$THIS.BACKCOLOR=$BC; $THIS.FORECOLOR=$FC})
- $B.FLATSTYLE=0; $B.CURSOR='HAND'; $B.ADD_CLICK({$GLOBAL:RET=$THIS.NAME;$F.CLOSE()}); $F.CONTROLS.ADD($B); $BT+=$B; $I++}
- $F.TEXT=$TITLE; $F.BACKCOLOR=$BC; $F.FORECOLOR=$FC; $F.STARTPOSITION=4; $F.AUTOSIZE=1; $F.AUTOSIZEMODE=0; $F.MAXIMIZEBOX=0
- $F.ACCEPTBUTTON=$BT[$DEF-1]; $F.CANCELBUTTON=$BT[-1]; $F.ADD_SHOWN({$F.ACTIVATE();$BT[$DEF-1].FOCUS()})
- $F.SHOWDIALOG() >$NULL; $INDEX=$GLOBAL:RET; IF ($INDEX -EQ $CH.LENGTH) {RETURN 0} ELSE {RETURN $INDEX}
- } #:CHOICES:#
-
- ::--------------------------------------------------------------------------------------------------------------------------------
- #:CHOICES2:# [INTERNAL]
- SET ^ #=;$F0=[IO.FILE]::READALLTEXT($ENV:0); $0=($F0-SPLIT '#\:CHOICES2\:' ,3)[1]; $1=$ENV:1-REPLACE'([`@$])','`$1'; IEX($0+$1)
- SET ^ #=&SET "0=%~F0"&SET 1=;CHOICES2 %*&(FOR /F "TOKENS=1,2" %%X IN ('POWERSHELL -NOP -C "%#%"')DO SET %1=%%X&SET %5=%%Y)&EXIT /B
- FUNCTION CHOICES2 {IEX($F0-SPLIT '#\:CHOICES\:' ,3)[1]; FUNCTION :LOOP { $A=$ARGS
- $C1 = @($A[0], $A[1], $A[2], $A[3], $A[-4], $A[-3], $A[-2], $A[-1]); $R1= CHOICES @C1; IF ($R1 -LT 1) {RETURN "0 0"}
- $A_7_ = $A[1].SPLIT(',')[$R1-1] + ' ' + $A[7] #:: USE 1ST DIALOG RESULT IN THE TITLE FOR 2ND DIALOG
- $C2 = @($A[4], $A[5], $A[6], $A_7_, $A[-4], $A[-3], $A[-2], $A[-1]); $R2= CHOICES @C2; IF ($R2 -GE 1) {RETURN "$R1 $R2"}
- IF ($R2 -LT 1) {$A[2]=$R1; :LOOP @A} }; :LOOP @ARGS #:: INDEX1 CHOICES1 DEF1 TITLE1 INDEX2 CHOICES2 DEF2 TITLE2 FONT BC TC WIN
- } #:CHOICES2:#
复制代码
上面是相关代码,可否改成运行后选择哪个直接跳转到:CHOICE-1,:CHOICE-2,:CHOICE-3?二级菜单可以去掉。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |