def _get_terminal_size_windows():
 try:
  from ctypes import windll, create_string_buffer
  h = windll.kernel32.GetStdHandle((-12))
  csbi = create_string_buffer(22)
  res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
  if res:
   (bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy) = struct.unpack('hhhhHhhhhhh', csbi.raw)
   sizex = ((right - left) + 1)
   sizey = ((bottom - top) + 1)
   return (sizex, sizey)
 except:
  pass

def _get_terminal_size_windows ( ) : try : from ctypes import windll , create_string_buffer h = windll . kernel32 . GetStdHandle ( ( - 12 ) ) csbi = create_string_buffer ( 22 ) res = windll . kernel32 . GetConsoleScreenBufferInfo ( h , csbi ) if res : ( bufx , bufy , curx , cury , wattr , left , top , right , bottom , maxx , maxy ) = struct . unpack ( 'hhhhHhhhhhh' , csbi . raw ) sizex = ( ( right - left ) + 1 ) sizey = ( ( bottom - top ) + 1 ) return ( sizex , sizey ) except : pass
get terminal size on ms windows .