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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 542k
  • Answers 542k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Put it into plugin. May 17, 2026 at 3:12 am
  • Editorial Team
    Editorial Team added an answer If you're implementing very simple routes (and since this is… May 17, 2026 at 3:12 am
  • Editorial Team
    Editorial Team added an answer Subversion has a feature called autoversioning where a directory mounted… May 17, 2026 at 3:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am launching a Python script from the command line (Bash) under Linux. I
Please tell me what is the difference in bash shell between launching a script
I have a script that links to the server I am hosting (IP can
I am building a kiosk type config script on low-spec hardware. At the end
How do I have a PowerShell script embedded within the same file as a
I have a .bat script launching a java program. The java program deletes the
I'm trying to applescript XCode into building and launching on device. My script is
Is there a way to redirect output of an executing PHP script? Of course
I have some small python 2.6 scripts built.... Now, I would like run them
I have a PHP script that launches another script in the background. Recently my

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.