-
-
Save no1xsyzy/58dff1441e6dc6919ba4b7c7e350d2ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
import os | |
import msvcrt | |
from ctypes import wintypes | |
kernel32 = ctypes.windll.kernel32 | |
def get_console_mode(output=False): | |
'''Get the mode of the active console input or output | |
buffer. Note that if the process isn't attached to a | |
console, this function raises an EBADF IOError. | |
''' | |
device = r'\\.\CONOUT$' if output else r'\\.\CONIN$' | |
with open(device, 'w' if output else 'r') as con: | |
mode = wintypes.DWORD() | |
hCon = msvcrt.get_osfhandle(con.fileno()) | |
kernel32.GetConsoleMode(hCon, ctypes.byref(mode)) | |
return mode.value | |
print(f'{get_console_mode():016b}::{get_console_mode(True):016b}::::\033[35mcolored\033[39mreset') | |
os.system('') | |
print(f'{get_console_mode():016b}::{get_console_mode(True):016b}::::\033[35mcolored\033[39mreset') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment