Prevent CMD from flickering

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Locked
Message
Author
Hradschek
Posts: 10
Joined: 03 Apr 2016 12:39
Location: Germany

Prevent CMD from flickering

#1 Post by Hradschek » 06 Apr 2016 07:19

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

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Prevent CMD from flickering

#2 Post by ShadowThief » 06 Apr 2016 23:34

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.

Hradschek
Posts: 10
Joined: 03 Apr 2016 12:39
Location: Germany

Re: Prevent CMD from flickering

#3 Post by Hradschek » 07 Apr 2016 03:18

Thank you. I'll test it today with PAUSE but i have another idea how to fix it.

Hradschek
Posts: 10
Joined: 03 Apr 2016 12:39
Location: Germany

Re: Prevent CMD from flickering

#4 Post by Hradschek » 07 Apr 2016 15:01

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?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Prevent CMD from flickering

#5 Post by foxidrive » 07 Apr 2016 17:23

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.

Hradschek
Posts: 10
Joined: 03 Apr 2016 12:39
Location: Germany

Re: Prevent CMD from flickering

#6 Post by Hradschek » 08 Apr 2016 02:01

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?

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Prevent CMD from flickering

#7 Post by einstein1969 » 08 Apr 2016 11:22

look at this(anti-flicker in dos batch) post

post your code for achieve major help.

einsten1969

Hradschek
Posts: 10
Joined: 03 Apr 2016 12:39
Location: Germany

Re: Prevent CMD from flickering

#8 Post by Hradschek » 09 Apr 2016 03:04

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.

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Prevent CMD from flickering

#9 Post by einstein1969 » 09 Apr 2016 04:02

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
Last edited by einstein1969 on 09 Apr 2016 04:09, edited 2 times in total.

Hradschek
Posts: 10
Joined: 03 Apr 2016 12:39
Location: Germany

Re: Prevent CMD from flickering

#10 Post by Hradschek » 09 Apr 2016 04:05

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.

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Prevent CMD from flickering

#11 Post by einstein1969 » 09 Apr 2016 04:11

I have update the previus post.

Hradschek
Posts: 10
Joined: 03 Apr 2016 12:39
Location: Germany

Re: Prevent CMD from flickering

#12 Post by Hradschek » 09 Apr 2016 08:17

No. :cry:
The flicker is stronger than before.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Prevent CMD from flickering

#13 Post by foxidrive » 09 Apr 2016 08:21

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.

Locked