Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1052131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:02:39+00:00 2026-05-16T17:02:39+00:00

When launching a script-type python file from Windows you get a windows shell type

  • 0

When launching a script-type python file from Windows you get a windows shell type window where the script runs. How can the script determine and also set/control the Window Size, Screen Buffer Size and Window Position of said window?. I suspect this can be done with the pywin32 module but I can’t find how.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:02:40+00:00Added an answer on May 16, 2026 at 5:02 pm

    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 = -11
    
    hdl = windll.kernel32.GetStdHandle(STDOUT)
    rect = wintypes.SMALL_RECT(0, 50, 50, 80) # (left, top, right, bottom)
    windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect))
    

    UPDATE:

    The window position is basically what the rect variable above sets through the left, top, right, bottom arguments. The actual size is derived from these arguments:

    width = right - left + 1
    height = bottom - top + 1
    

    To set the screen buffer size to, say, 100 rows by 80 columns, you can use the SetConsoleScreenBufferSize API:

    bufsize = wintypes._COORD(100, 80) # rows, columns
    windll.kernel32.SetConsoleScreenBufferSize(h, bufsize)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am launching a Python script from the command line (Bash) under Linux. I
Right now I am launching a Python script from PHP using exec() as I
I'm using launching firefox from the command line in a script to get snapshots
I'm having a hard time launching active_record from my ruby script. I get :
I get this error when launching my Mongrel server... $ script/server --debugger => Booting
Please tell me what is the difference in bash shell between launching a script
I am running Selenium Server. I'm also launching an automated test script that I
I am happily launching a program in a windows system from Lua using strProgram
I am trying to get a script performance improved, using ThreadPoolExecutor from concurrent.futures. I
I'm trying to write a shell script that, when run, will set some environment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.