Hi cats,
for kindness I try to modify a batch so that the script ask to the user:
want u use smooth resize (press Yes "Y")? or LancZosResiZE (press No "N") ?
if (within 3 seconds) the user type "Y" a variable called smoothResize become == 1
otherwise after 3 seconds (even if you do not type anything in the keyboard) the batch have to continue
How can I resolve? thanks
PS: IF POSSIBLE I DON'T WANT USE THE CHOICE COMMAND : THANKS ^^
+ Reply to Thread
Results 1 to 11 of 11
-
-
Would this work from another link?
Use the SET /P command to read input from the user. The SET /P command will print the string you specify and prompt the user for information:
@echo off
SET /P ANSWER=Do you want to continue (Y/N)?
echo You chose: %ANSWER%
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)
goto :no
:yes
echo You pressed yes!
exit /b 0
:no
echo You pressed no!
exit /b 1 -
I have do some search on the internet but for example, in your script where is specify the timeout of 3 seconds?
I correct my initial request:
tha batch don't have to differentiate from yes and no: simply the user have to type Y (yes) if he want the smoothresize, in the meantime the countdown goes on. After 3 seconds, if the user have no-input on the keyboard the batch assume to use the normal resize method
only if the user have type Y --> a variable called smoothResize change of state from 0 to 1Last edited by marcorocchini; 15th Nov 2014 at 12:43.
-
Which is the entire reason why "choice" exists, if you don't want to use the only command that was designed for the task, then you're out of luck.
-
I have a little program that asks whatever is on the command line and returns errorlevel 0 if n/N is pressed, errorlevel 1 if y/Y is pressed. No timeout though.
-
This works for me and sets 10 second delay. If you want more change waitMins to minutes and waitMins*10 to waitMins*60. The object is to arrive at Seconds...
1*10=10 seconds... 30*60=1800 Seconds(30 Minutes). You will also have to fill in a valid process to perform instead of the Echo Process1 and Echo Process2. The default is set to n (/d n) so change to /d c if you wish it.
This is documented courtesy of a better DOS person than I at http://stackoverflow.com/questions/12331428/how-to-ask-for-batch-file-user-input-with-a-timeout
----Code Below-----
Echo off
:START
set waitMins=1
echo PC WILL RESTART IN %waitMins% SECONDS: Press N to restart [N]ow or C to [C]ancel
:: Calculate Seconds
set /a waitMins=waitMins*10
:: Choices are n and c, default choice is n, timeout = 1800 seconds
choice /c nc /d n /t %waitMins%
:: [N]ow = 1; [C]ancel = 2
goto Label%errorlevel%
:Label1
echo Process1 here
:: Make sure that the process doesn't fall through to Lable2
goto :eof
:Label2
echo process2 here
::exit -
PERHAPS these ones will be helpful
Code:timeout TIMEOUT - This utility is similar to the DOS PAUSE command. However, it accepts a timeout parameter to specify a length of wait (in seconds) at which time it will continue without a key press. Written by Eric Brown, Business System Division. Copyright (C) Microsoft Corporation, 1992-1995. Usage - TIMEOUT <###> where <###> is a decimal number of seconds between -1 and 100000. The value -1 means to wait indefinitely for a key hit.
Code:sleep --help Usage: sleep NUMBER[SUFFIX]... or: sleep OPTION Pause for NUMBER seconds. SUFFIX may be `s' for seconds (the default), `m' for minutes, `h' for hours or `d' for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. --help display this help and exit --version output version information and exit Report bugs to <bug-coreutils@gnu.org>.
-
move that question to the beginning of your batch script, it kind of makes little sense to wait long time to confirm something
-
The problem I have with 'Sleep' and 'Timeout' as I understand them, is that Sleep does just that and cannot be interrupted with keystrokes and Timeout can be interrupted with key-presses but they have to be set with 'set /p' which again will wait forever until you type something in. No matter which I put first, i couldn't arrive at a maximum timeout that can be shortened by hitting a key and yet fall through automatically if nothing is pressed.
Maybe I missed something but the Choice with timeout accomplished it for me but as I mentioned earlier, I'm far from a DOS Guru. -
https://www.dropbox.com/s/kyn5p41j01pjvw8/CHOOSE.EXE?dl=0
I try the choose.exe but it don't show countdown
Code::MP4gopro_50fps <VCF_FILENAME> <AVS_FILENAME> <FILENAME> <ORG_FILENAME> color d cls echo *** ____ MP4gopro ____ any resolutions but 50fps to MorganMJPEG AVI HD 1920x1080 interlaced 25 fps using Avisynth+Virtualdub *** echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ echo ³ ³ echo ³ MP4 GOpro any 50fps versus SD 25fps ³ echo ³ LowPassFiltering On/Off ³ echo ³ press Y if you want become a *** ³ echo ³ ³ echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ echo. CHOOSE.EXE /c:ynq /t:n,7 " untils 7 seconds press Y if u want to be smooth like a cat " set "LowPassFilter=0" if errorlevel==255 echo No such choice (255) if not errorlevel==4 if errorlevel==3 echo The choice was a q (3) if not errorlevel==3 if errorlevel==2 echo LowPass OFF if not errorlevel==2 if errorlevel==1 (Set LowPassFilter=1) if not errorlevel==1 if errorlevel==0 echo The choice was interrupted (0) IF "%LowPassFilter%"=="1" echo LowPassFiltering ATTIVATO per ammorbidire contorni IF "%LowPassFilter%"=="1" Set "filteringVirtualdubMode=135" IF "%LowPassFilter%"=="0" echo LowPassFiltering Disabled IF "%LowPassFilter%"=="0" Set "filteringVirtualdubMode=7" rem *** TRY to test if input file have or not audio *** if exist "%WorkFolder%\TESTonly.wav" del "%WorkFolder%\TESTonly.wav" v:\automazioneclip\core\ffmpeg.exe -loglevel fatal -y -i %4 -ss 00:00:00 -t 00:00:10 -filter_complex "[0:1] volume=1.5" "%WorkFolder%\TESTonly.wav" for %%v in ("TESTonly.wav") do ( if %%~zv LSS 128 ( del "%WorkFolder%\TESTonly.wav" ) ) Set "TokenS=0" Set "audioInsideFileExist=0" if exist "%WorkFolder%\TESTonly.wav" set "audioInsideFileExist=1" del "%WorkFolder%\TESTonly.wav" IF "%audioInsideFileExist%"=="1" set "AudioFile=%4" IF NOT "%audioInsideFileExist%"=="1" set AudioFile="v:\automazioneclip\system\empty.wav" echo PROCESSING %4 if not "%FPSforVirtualdub%"=="0" (set /a "newFPSforVirtualdub=%FPSforVirtualdub%-1") else (set "newFPSforVirtualdub=0") echo FrameCount %newFPSforVirtualdub% rem ***Make The .vcf Script File*** echo VirtualDub.audio.SetSource^(0^);>%1 echo VirtualDub.audio.SetMode^(0^);>>%1 echo VirtualDub.audio.SetInterleave^(1,500,1,0,0^);>>%1 echo VirtualDub.audio.SetClipMode^(1,1^);>>%1 echo VirtualDub.audio.SetEditMode^(1^);>>%1 echo VirtualDub.audio.SetConversion^(0,0,0,0,0^);>>%1 echo VirtualDub.audio.SetVolume^(^);>>%1 echo VirtualDub.audio.SetCompression^(^);>>%1 echo VirtualDub.audio.EnableFilterGraph^(0^);>>%1 echo VirtualDub.video.SetInputFormat^(0^);>>%1 echo VirtualDub.video.SetOutputFormat^(11^);>>%1 IF "%LowPassFilter%"=="0" echo VirtualDub.video.SetMode^(1^);>>%1 IF "%LowPassFilter%"=="1" echo VirtualDub.video.SetMode^(3^);>>%1 echo VirtualDub.video.SetSmartRendering^(0^);>>%1 echo VirtualDub.video.SetPreserveEmptyFrames^(0^);>>%1 echo VirtualDub.video.SetFrameRate2^(0,0,1^);>>%1 echo VirtualDub.video.SetIVTC^(0, 0, 0, 0^);>>%1 echo VirtualDub.video.SetCompression^(0x31626d64,0,10000,0^);>>%1 echo VirtualDub.video.filters.Clear^(^);>>%1 echo VirtualDub.video.filters.Add^("deinterlace"^);>>%1 echo VirtualDub.video.filters.instance^[0^].Config^(0,1,1^);>>%1 echo VirtualDub.video.filters.Add^("resize"^);>>%1 IF "%LowPassFilter%"=="0" echo VirtualDub.video.filters.instance^[1^].Config^(720,576,0,4,3,0,320,240,4,3,0,7,1,0x000000^);>>%1 IF "%LowPassFilter%"=="1" echo VirtualDub.video.filters.instance^[1^].Config^(720,576,0,4,3,0,320,240,4,3,0,135,1,0x000000^);>>%1 echo VirtualDub.video.filters.Add^("interlace"^);>>%1 echo VirtualDub.video.filters.instance^[2^].Config^(0, 0^);>>%1 echo VirtualDub.audio.filters.Clear^(^);>>%1 if NOT "%TimeCode%"=="" echo VirtualDub.project.ClearTextInfo^(^);>>%1 if NOT "%TimeCode%"=="" echo VirtualDub.project.AddTextInfo^("ISMP", "%TIMECODE%"^);>>%1 echo VirtualDub.SaveAVI^("%DestFolder%\\%~n1_SD.avi"^);>>%1 echo VirtualDub.Close^(^);>>%1 rem ***Make The .avs Script File*** echo Import^("C:\Program Files\AviSynth\plugins\IcResize.avsi"^)>%2 echo vid=FFVideoSource^(%4^)>>%2 echo aud=FFAudioSource^(%4^)>>%2 echo left = GetChannel^(aud, 1^)>>%2 echo right = GetChannel^(aud, 1^)>>%2 echo both=mergechannels^(left, right^)>>%2 echo audioDub^(vid,both^)>>%2 echo ConvertAudioTo16Bit^(^)>>%2 echo ConvertToYUY2^(interlaced=false^)>>%2 rem echo ColorYUV^(levels="PC->TV"^)>>%2 rem echo ColorYUV^(gamma_y=-7, gamma_u=-7, gamma_v=-7^)>>%2 rem echo colorMatrix^(mode="Rec.709->Rec.601"^)>>%2 IF "%LowPassFilter%"=="0" IF NOT "%GoPro1920%"=="1" IF NOT "%GoPro1080%"=="1" echo LancZosResiZe^(1920,1080^)>>%2 echo AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave().trim^(0,%newFPSforVirtualdub%^)>>%2 echo AssumeFPS^(25^)>>%2 echo processing source file %4 rem ***Call VirtualDub*** if NOT EXIST %VD_LOC% ( echo Um, where the hell is VirtualDubMod? pause ) %VD_LOC% /min %2 /s %1 for %%v in ("%DestFolder%\\%~n1_SD.avi") do ( if %%~zv LSS 128 ( echo ERROR!!! Extra Small File Size Detected!!! pause ) ) v:\automazioneclip\virtualdub\cfourcc.exe -i "%CD%\%~n1_SD.avi" -u MJPG -d MJPG v:\automazioneclip\virtualdub\cfourcc.exe -i "%CD%\%~n1_SD.avi" -u MJPG -d MJPG v:\automazioneclip\core\ffmpeg.exe -y -i "%~dp1%~n1.avs" -filter_complex "[0:1] volume=1.5" -c:a pcm_s16le "%~dp1%~n1_SD.wav" DEL "%DestFolder%\*.ffindex" DEL "%~dp1%~n1.vcf" DEL "%~dp1%~n1.avs" rem #### check duration of avi and wav file #### for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\virtualdub\FFProbe -hide_banner -loglevel fatal -pretty -select_streams v:0 -show_streams -show_entries stream^=codec_type^,duration^,r_frame_rate^,width^,height^,sample_aspect_ratio:stream_disposition^=:format_tags^=timecode^,company_name^,product_name^,product_version "%~dp1%~n1_SD.avi" 2^>^&1') DO ( if "%%~g"=="duration" set "aviDuration=%%~h") for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\virtualdub\FFProbe -hide_banner -loglevel fatal -pretty -show_streams -show_entries stream^=codec_type^,duration^,r_frame_rate^,width^,height^,sample_aspect_ratio:stream_disposition^=:format_tags^=timecode^,company_name^,product_name^,product_version "%~dp1%~n1_SD.wav" 2^>^&1') DO ( if "%%~g"=="duration" set "wavDuration=%%~h") echo durata del file wav pari a %wavDuration% echo durata del file avi pari a %aviDuration% cls if "%wavDuration%"=="%aviDuration%" (color A0) else echo attention_different_durations>"%~dp1%~n1PleaseAttentionsToTheDifferentDurations.txt" timeout /t 1 goto :eof
-
http://ss64.com/nt/choice.html
Considering some of the ridiculous string sequences the average programmer has to memorize, not even having English as a second language can excuse that mistake.