How to turn off blinking cursor in command window?

To anyone who is seeing this in 2019, there is a Python3 module called "cursor" which basically just has hide and show methods. Install cursor, then just use:

import cursor
cursor.hide()

And you're done!


I've been writing a cross platform colour library to use in conjunction with colorama for python3. To totally hide the cursor on windows or linux:

import sys
import os

if os.name == 'nt':
    import msvcrt
    import ctypes

    class _CursorInfo(ctypes.Structure):
        _fields_ = [("size", ctypes.c_int),
                    ("visible", ctypes.c_byte)]

def hide_cursor():
    if os.name == 'nt':
        ci = _CursorInfo()
        handle = ctypes.windll.kernel32.GetStdHandle(-11)
        ctypes.windll.kernel32.GetConsoleCursorInfo(handle, ctypes.byref(ci))
        ci.visible = False
        ctypes.windll.kernel32.SetConsoleCursorInfo(handle, ctypes.byref(ci))
    elif os.name == 'posix':
        sys.stdout.write("\033[?25l")
        sys.stdout.flush()

def show_cursor():
    if os.name == 'nt':
        ci = _CursorInfo()
        handle = ctypes.windll.kernel32.GetStdHandle(-11)
        ctypes.windll.kernel32.GetConsoleCursorInfo(handle, ctypes.byref(ci))
        ci.visible = True
        ctypes.windll.kernel32.SetConsoleCursorInfo(handle, ctypes.byref(ci))
    elif os.name == 'posix':
        sys.stdout.write("\033[?25h")
        sys.stdout.flush()

The above is a selective copy & paste. From here you should pretty much be able to do what you want. Assuming I didn't mess up the copy and paste this was tested under Windows Vista and Linux / Konsole.


I'm surprised nobody mentioned that before, but you actually don't need any library to do that.

Just use print('\033[?25l', end="") to hide the cursor.

You can show it back with print('\033[?25h', end="").

It's as easy as that :)