It is a bit tricky, because you do not want the background color changing process to intercept any of your console input. You could add the /NOBREAK option to the TIMEOUT command, such that the script never reads stdin, except it still could process a <CTRL-Break>
interupt, and ask if you want to terminate the script. The user could respond with Y
and terminate the background process, but that could get confusing if the main process also has a running batch script. Which process gets the input?
You can redirect stdin to nul for the background process, but TIMEOUT fails if input is redirected.
I modified your auto-change-text-color.bat to use a PING delay instead of TIMEOUT, thus allowing stdin to be redirected to NUL. I also put one last COLOR command at the end to finish with a more readable color combination.
@echo off
set NUM=0 1 2 3 4 5 6 7 8 9 A B C D E F
for %%x in (%NUM%) do (
for %%y in (%NUM%) do (
color %%x%%y
>nul ping localhost -n 2
)
)
color 07
The following command is used to launch the script in the background with stdin redirected to nul:
start "" /b cmd /c "auto-change-text-color.bat <nul"
The only odd side effect is that the background process still can receive <CTRL-Break>
, and it prints out the message Terminate batch job (Y/N)?
, but immediately continues without waiting for input. So you can safely start a batch script in the main process, issue <CTRL-Break>
and get two Terminate messages, and press Y or N knowing that only the batch script in your main process will respond (terminate or not).
Best Answer
The Popup Background settings from the Console Windows Properties is for the the color of the console popup window such as when you press F7 to view the history of commands you've used in your console session.
By default the console screen highlight color simply appears to be the inverse color of whatever color you have set in the Console Windows Properties from the Screen Background setting.
Therefore as suggested, if you set the Screen Background colors to 50,50,50 in the Selected Color Values settings, then this seems to give you a gray highlight color per its inverse color.
The trade off for doing this is that the regular of non-highlighted console background color will be of a lighter shade than just solid black.
Further Resources