-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I'm mostly just leaving this snippet here for future me
def get_buffer_size():
import ctypes
class CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
_fields_ = [
('dwSize', ctypes.wintypes._COORD),
('dwCursorPosition', ctypes.wintypes._COORD),
('wAttributes', ctypes.c_ushort),
('srWindow', ctypes.wintypes._SMALL_RECT),
('dwMaximumWindowSize', ctypes.wintypes._COORD)
]
ctypes.windll.kernel32.GetStdHandle.restype = ctypes.wintypes.HANDLE
hstd = ctypes.windll.kernel32.GetStdHandle(-11) # STD_OUTPUT_HANDLE = -11
csbi = CONSOLE_SCREEN_BUFFER_INFO()
# print(csbi.__dict__)
# print(csbi.srWindow)
# print(csbi.srWindow.Top)
# print(csbi.srWindow.Right)
ret = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(
hstd,
ctypes.byref(csbi)
)
if ret == False:
return Error('Failed to retrieve console buffer size')
width = csbi.srWindow.Right - csbi.srWindow.Left
height = csbi.srWindow.Bottom - csbi.srWindow.Top
return Success( (width, height) )
# print(csbi.__dict__)
# print(csbi.srWindow)
# print(csbi.srWindow.Top)
# print(csbi.srWindow.Right)
return ResultAndData(ret, csbi)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels