How to control the size of the Windows shell window from within a python script?

Not enough credits to upvote
Not enough credits to downvote
By: Speedbird (SysAdmin), Created 8 years ago, Updated 8 years ago.
You can do this using the SetConsoleWindowInfo function from the win32 API. The following should work:
from ctypes import windll, byref
from ctypes.wintypes import SMALL_RECT

STDOUT = -12

hdl = windll.kernel32.GetStdHandle(STDOUT)
rect = wintypes.SMALL_RECT(0, 50, 50, 80) # (left, top, right, bottom)
windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect))

Not enough credits to upvote Not enough Credits to downvote By: Speedbird (SysAdmin), Updated 8 years ago, Votes: 0
This is a comment to see if my comment count is incremented

0 Responses

This question does not have any answers yet.

You may post an answer by signing in or registering for an account Here

Welcome to - QA-Stack is a Q&A open source web application written in the best programming language in the galaxy: Python and using the best web framework in the solar system: web2py, be sure to check for discussions about this site. Have a great stay.

QA-Stack source code is available thanks to the cool folks at, browse the source, or follow updates to this projects by visiting the qa-stack page at


Documentation for QA-Stack can be found at the QA-Stack Google Docs Page.


Submit your bugs in i-track, another web application made by the same author (we eat our own dog food): View currently submitted bugs on i-track.

Popular Tags