Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & CLS
- REM demo of non blocking animation during menu input.
- REM https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
- If not "%~1"=="" Goto:%1
- CD /D "%~dp0"
- REM Signal file that the Controller uses to pass keypress to the game via without blocking execution.
- REM - Note - This is not a Lockfile: executing multiple instances of this script simultaneously is not supported.
- Set "SignalFile=%TEMP%\%~n0_Signal.tmp"
- REM Signal file that the game uses to communicate an Exit signal to the controllor.
- Del "%SignalFile:Signal=Stop%" 2> nul 1> nul
- REM Stores the active codepage for restoration upon script completion.
- For /F "tokens=2 Delims=:" %%G in ('CHCP')Do >"%TEMP%\%~n0_restore.cmd" Echo(@CHCP %%G ^> nul
- REM Defines nonprintable characters used by this script.
- Call :init
- CHCP 65001 >nul
- Setlocal EnableExtensions EnableDelayedExpansion
- Set "volta="
- For /f "tokens=1,* delims=:" %%G in ('%systemRoot%\system32\findstr.exe /BRIC:":volta" "%~f0"') Do Set "%%G=!%%G!%\E%[K%%H%\E%[E"
- Set "volta=%\e%[H%\e%[E!volta!"
- Set "Volta_1=!volta:0=▒!"
- Set "Volta_1=!volta_1:1=▓!"
- Set "Volta_2=!volta:0=▓!"
- Set "Volta_2=!volta_2:1=▒!"
- REM Pipe the output of the function *CONTROLLER to Game to facilitate non blocking input.
- Start /Wait /B "" "%~F0" %TypeOfControl%CONTROLLER 1>"%SignalFile%" | "%~F0" Main <"%SignalFile%" 2> nul
- CALL "%TEMP%\%~n0_restore.cmd"
- DEL "%TEMP%\%~n0_restore.cmd"
- (Title )
- Pause
- Exit /B 0
- :Main
- Setlocal EnableDelayedExpansion
- Set "functions="
- For /f "tokens=1,2,* delims=:.\" %%G in ('%systemRoot%\system32\findstr.exe /BRIC:":func." "%~f0"') Do (
- Set "functions=!functions! %%H : class="re0">%%I %\E%[E"
- Set "func.%%H=func.%%H\%%I"
- )
- (Title )
- Set ^"t()=for %%n in (1 2) do if %%n==2 (For /f "tokens=1,*" %%1 in ("^!args^!")do (set /a "p=(%%~2)%%510"^&if ^^^!p^^^! GTR 255 (set /a "%%1=510-p") else set /a "%%1=p")) else set args=^"
- Set /a "CSe=(100/4)"
- set /a "i=1"
- For /l %%i in () Do (
- for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do Set /a "t2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, tDiff=t2-t1,estFPS=100/tDiff"
- If !tDiff! lss 0 Set /a tDiff+=24*60*60*100
- If !tDiff! geq !CSe! (
- Title centisecond interval:!CSe! Fps:!estFPS!
- Set /a t1=t2
- set /a t=t %% 510 + 10
- %t()% R !t!
- %t()% G !t!+170
- %t()% B !t!+340
- Set /p "newKey="
- set /a i = i %% 2 + 1
- For %%I in (!i!) do echo(%\E%[38;2;!R!;!G!;!B!m!volta_%%I!%\E%[0m!functions:_= !
- If Defined newKey For /f "delims=" %%K in ("!newKey!")Do (
- If /I "%%K" == "quit" EXIT
- if not "!functions: %%K =!" == "!functions!" Call:!func.%%K!
- Set "newKey="
- )
- )
- )
- :volta: 01╗ 01╗ 101010╗ 10╗ 01010101╗ 01010╗
- :volta: 10║ 10║10╔═══10╗01║ ╚══01╔══╝01╔══10╗
- :volta: 01║ 01║01║ 01║10║ 10║ 1010101║
- :volta: ╚01╗ 01╔╝10║ 10║01║ 01║ 01╔══10║
- :volta: ╚0101╔╝ ╚101010╔╝1010101╗10║ 10║ 01║
- :volta: ╚═══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝
- :init
- %= Tab =% for /f "delims= " %%T in ('robocopy /L . . /njh /njs' )do set "TAB=%%T"
- %= Carriage Return =% for /f %%C in ('copy /Z "%~dpf0" nul') do set "CR=%%C"
- %= BackSpace =% for /F "delims=#" %%B in ('"prompt #$H# &echo on &for %%b in (1) do rem"') do Set "BS=%%B"
- Set "BS=%BS:~0,1%"
- %= VT escape =% For /F "delims=" %%G in ('echo Prompt $E^|%comspec%')Do set \E=%%G
- (Set "TypeOfControl=XCOPY" & Set "QUITKEY=%TAB%")
- Set "ForceQuit="
- For /F "Delims=" %%G in ('Where Powershell.exe')Do If not Defined ForceQuit Set "ForceQuit=%%G -c "$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('{TAB}')"
- exit /b 0
- :XCOPYCONTROLLER
- Setlocal DISABLEdelayedExpansion
- REM Environment handling allows use of ! key
- For /l %%C in () do (
- If Exist "%SignalFile:Signal=Stop%" (
- EXIT
- )
- Set "Key="
- for /f "delims=" %%A in ('%SystemRoot%\System32\xcopy.exe /w "%~f0" "%~f0" 2^>nul') do If not Defined Key (
- set "key=%%A"
- Setlocal ENABLEdelayedExpansion
- set key=^!KEY:~-1!
- If "!key!" == "!QUITKEY!" (
- <nul Set /P "=quit"
- EXIT
- )
- If "!Key!" == "%BS%" ( <nul Set /p "={BACKSPACE}"
- )else If "!Key!" == "!CR!" ( <nul Set /p "={ENTER}"
- )else If "!Key!" == "%TAB%" ( <nul Set /p "={TAB}"
- )else (%= Echo without Linefeed. Allows output of equals and Space keys =%
- 1> %~n0txt.tmp (echo(!Key!!sub!)
- copy %~n0txt.tmp /a %~n0txt2.tmp /b > nul
- type %~n0txt2.tmp
- del %~n0txt.tmp %~n0txt2.tmp
- )
- Endlocal
- ) )
- EXIT
- :func.g\Goodbye_World
- Echo %\E%[0JGoodbye world
- Goto:Eof
- :func.h\Hello_World
- Echo %\E%[0JHello world
- Goto:Eof
- :func.s\Shift_Animation_Frequency
- if not defined CSe.freq Set "CSe.freq=4,6,8,10,20,24,50,100,2"
- For /f "tokens=1,* Delims=," %%1 in ("!CSe.freq!") Do Set "CSe.Freq=%%2,%%1"
- Set /a "CSe=(100/CSe.freq)"
- Goto:Eof
- :func.q\quit
- %ForceQuit%
- Exit /b 0
Advertisement