Page 1 of 1

Prevent CMD from flickering

Posted: 06 Apr 2016 07:19
by Hradschek
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

Re: Prevent CMD from flickering

Posted: 06 Apr 2016 23:34
by ShadowThief
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

Posted: 07 Apr 2016 03:18
by Hradschek
Thank you. I'll test it today with PAUSE but i have another idea how to fix it.

Re: Prevent CMD from flickering

Posted: 07 Apr 2016 15:01
by Hradschek
There is nothing wrong with my code, it is because of Windows. :cry:

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

Posted: 07 Apr 2016 17:23
by foxidrive
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.

Re: Prevent CMD from flickering

Posted: 08 Apr 2016 02:01
by Hradschek
Someone wrote this code, but it doesnt work in my code.




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?

Re: Prevent CMD from flickering

Posted: 08 Apr 2016 11:22
by einstein1969
look at this(anti-flicker in dos batch) post

post your code for achieve major help.

einsten1969

Re: Prevent CMD from flickering

Posted: 09 Apr 2016 03:04
by Hradschek
For example:



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.

Re: Prevent CMD from flickering

Posted: 09 Apr 2016 04:02
by einstein1969
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?

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

Re: Prevent CMD from flickering

Posted: 09 Apr 2016 04:05
by Hradschek
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.

Re: Prevent CMD from flickering

Posted: 09 Apr 2016 04:11
by einstein1969
I have update the previus post.

Re: Prevent CMD from flickering

Posted: 09 Apr 2016 08:17
by Hradschek
No. :cry:
The flicker is stronger than before.

Re: Prevent CMD from flickering

Posted: 09 Apr 2016 08:21
by foxidrive
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.