Prevent CMD from flickering
Moderator: DosItHelp
Prevent CMD from flickering
How do I prevent the console window from flickering? After pressing [ENTER] the last command is repeated. This causes that the window is flickering. Do you guys know how to fix this?
Greetings
Abel Hradschek, Neu Lewin
Greetings
Abel Hradschek, Neu Lewin
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Prevent CMD from flickering
PAUSE by itself doesn't have that behavior, so without seeing your code, I couldn't even begin to guess what's wrong with it.
Re: Prevent CMD from flickering
Thank you. I'll test it today with PAUSE but i have another idea how to fix it.
Re: Prevent CMD from flickering
There is nothing wrong with my code, it is because of Windows.
The auto-repeat with pressing ENTER or hold ENTER pressed causes this problem because i have a while loop that runs until the command is repeated 100 times (but only if you press ENTER or hold ENTER after typing a specific command). I know there is a method called 'Double-Buffering'. Are you able to tell me more about this?
The auto-repeat with pressing ENTER or hold ENTER pressed causes this problem because i have a while loop that runs until the command is repeated 100 times (but only if you press ENTER or hold ENTER after typing a specific command). I know there is a method called 'Double-Buffering'. Are you able to tell me more about this?
Re: Prevent CMD from flickering
double buffering isn't a batch tool.
Tell us which part of your code makes this happen - make a sample batch file so we can see what you mean, because your descriptions so far don't explain what you are doing in code, or give us any real idea of what is happening.
if you know of some method using double buffering, then show a URL so we can know what you are referring to.
Tell us which part of your code makes this happen - make a sample batch file so we can see what you mean, because your descriptions so far don't explain what you are doing in code, or give us any real idea of what is happening.
if you know of some method using double buffering, then show a URL so we can know what you are referring to.
Re: Prevent CMD from flickering
Someone wrote this code, but it doesnt work in my code.
Are you able to tell me exactly how this code works?
Code: Select all
@echo off & setlocal EnableDelayedExpansion
rem tuning flickering
rem use fonts 8x8 or Lucida Console 5
mode 120,80
set LF=^
rem above 2 blank lines necessary!
set st0=°±²Û²±°
set st=!st0!g!st0!o!st0!u!st0!z
set st=!st!!st!!st!!st!!st!
set "sp= "
set [=!sp!By Einstein1969!sp!=]!LF!!st!!st!!st!!st!!st!!st!!st!!st!!st!
rem empty env for faster execution
For /f "delims==" %%v in ('set') do if not %%v == [ set %%v=
set/p "AF=Do you want use anti-flicker? [Y/N] "
If /I "!AF!" == "Y" goto :Antiflicker
set AF=
for /L %%N in (1,1,1000000) do (
cls&set
set /a "_=%%N %% 1000"
if !_! equ 0 (
if !`! gtr 60 (
set [=![:z =z!
set [=![:o =o!
set [=![:g =g!
set [=![:u =u!
) else (
set [=![:z=z !
set [=![:o=o !
set [=![:g=g !
set [=![:u=u !
)
set /A "`=(`+1) %% 120"
)
)
exit /b
:Antiflicker
set AF=
for /L %%N in (1,1,1000000) do (
if not "!_OT!"=="!time:~10,1!" (
cls&set
set _OT=!time:~10,1!
)
set /a "_=%%N %% 10000"
if !_! equ 0 (
if !`! gtr 60 (
set [=![:z =z!
set [=![:o =o!
set [=![:g =g!
set [=![:u =u!
) else (
set [=![:z=z !
set [=![:o=o !
set [=![:g=g !
set [=![:u=u !
)
set /A "`=(`+1) %% 120"
)
)
exit /b
Are you able to tell me exactly how this code works?
-
- Expert
- Posts: 961
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
Re: Prevent CMD from flickering
For example:
If you hold ENTER pressed, this code is repeated.
Code: Select all
:pSub1
cls
if %userinput%==p (
set /a pc=%pc%+1
set /a sc=%sc%-1
)
echo %pc%
echo %sc%
goto pSub1
If you hold ENTER pressed, this code is repeated.
-
- Expert
- Posts: 961
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
Re: Prevent CMD from flickering
This seem a piece of code, not whole code.
In this piece there isn't INPUT section and the repeat is caused by the GOTO statment ,not by ENTER key.
Where is the INPUT section?
EDIT:this work for you?
einstein1969
In this piece there isn't INPUT section and the repeat is caused by the GOTO statment ,not by ENTER key.
Where is the INPUT section?
EDIT:this work for you?
Code: Select all
@echo off
setlocal Enabledelayedexpansion
set nbsp=ÿ
set userinput=p
:pSub1
if %userinput%==p (
set /a pc=%pc%+1
set /a sc=%sc%-1
)
(
:loop_antiflicker
if "%time:~-1%"=="!time:~-1!" goto :loop_antiflicker
cls
echo(%nbsp%
echo %pc%
echo %sc%
)
goto pSub1
einstein1969
Last edited by einstein1969 on 09 Apr 2016 04:09, edited 2 times in total.
Re: Prevent CMD from flickering
It is not necessary, but k.
set /a pc=0
set /a sc=0
set /p userinput=
THIS IS NOT THE PROBLEM. THE LOOP IS THE PROBLEM.
set /a pc=0
set /a sc=0
set /p userinput=
THIS IS NOT THE PROBLEM. THE LOOP IS THE PROBLEM.
-
- Expert
- Posts: 961
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
Re: Prevent CMD from flickering
I have update the previus post.
Re: Prevent CMD from flickering
No.
The flicker is stronger than before.
The flicker is stronger than before.
Re: Prevent CMD from flickering
See here: viewtopic.php?f=3&t=6108
Send a PM to a mod to reopen your thread, if you decide to provide details.
I asked you quite politely for explanation or sample code, but there ya go.
Send a PM to a mod to reopen your thread, if you decide to provide details.
I asked you quite politely for explanation or sample code, but there ya go.