Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove blinking underscore on console / cmd prompt

This probably something very simple, but Google doesn't seem to have the answer.

Is there a simple command for a console program to stop the blinking cursor?

Before my program runs it has a percentage of loading, but when it updates the cursor gets messed up and it is really annoying. I know its possible, lots of programs have it.

What command turns the blinking underscore on and off?

like image 310
Nicholas Pipitone Avatar asked Aug 03 '13 02:08

Nicholas Pipitone


1 Answers

You can hide the cursor by calling SetConsoleCursorInfo. .

#include <windows.h>

void ShowConsoleCursor(bool showFlag)
{
    HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);

    CONSOLE_CURSOR_INFO     cursorInfo;

    GetConsoleCursorInfo(out, &cursorInfo);
    cursorInfo.bVisible = showFlag; // set the cursor visibility
    SetConsoleCursorInfo(out, &cursorInfo);
}

int main()
{
    ShowConsoleCursor(false);
    system("pause");
}
like image 156
Captain Obvlious Avatar answered Sep 20 '22 07:09

Captain Obvlious