Home > Blockchain >  Batch Script | Flash the screen while a command is running
Batch Script | Flash the screen while a command is running

Time:11-11

I've created a batch script to call VLC to record. Whilst VLC is recording I want the commmand prompt screen to flash a red and black back ground as a visual indicator that recording is happening.

This is my string to run VLC:

vlc screen:// --qt-start-minimized :screen-fps=30 :run-time=300 :quiet :sout=#transcode{vcodec=h264,vb072}:standard{access=file,mux=mp4,dst="C:\Users\danbradshaw\Desktop\screencast.mp4"} vlc://quit

This is how I'm getting the background to cycle colours:

:S 
color 40
color 04
goto S

As the VLC string stops the runner until VLC is quit I can't place the colour cycle code after. But as the colour cycle code is a loop it stops the VLC string from executing if placed before.

What should I do to get them to run together?

CodePudding user response:

This works:

@echo off

if "%1" neq "" goto %1

echo Start process
"%~F0" emitter > pipefile.txt | "%~F0" receiver < pipefile.txt
color
echo End process
goto :EOF


:emitter
ping -n 10 -w 500 localhost > CON
echo EOT
exit /B


:receiver
color 40
ping -n 1 localhost > NUL
color 04
ping -n 1 localhost > NUL
set /P "end="
if not defined end goto receiver
exit /B

Just replace the ping -n 10 -w 500 localhost > CON command I used in my tests by your vlc screen:// --qt-start-minimized :screen-fps=30 :run-time=300 :quiet :sout=#transcode{vcodec=h264,vb072}:standard{access=file,mux=mp4,dst="C:\Users\danbradshaw\Desktop\screencast.mp4"} vlc://quit

CodePudding user response:

I got this working with the suggestions above. Here is my final batch script:

@echo off
:start
cls
cd /d C:\Program Files\VideoLAN\VLC
start vlc screen:// --qt-start-minimized :screen-fps=30 :run-time=300 :quiet :sout=#transcode{vcodec=h264,vb072}:standard{access=file,mux=mp4,dst="C:\Users\danbradshaw\Desktop\screencast.mp4"} vlc://quit
:S 
color 40
timeout 1 >nul
color 04
timeout 1 >nul
goto S

Thanks for the responses.

  • Related