Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python change cmd title

>>> import ctypes
>>> ctypes.windll.kernel32.SetConsoleTitleA("My New Title")
Comment

python change cmd title

import os
import ctypes
import msvcrt
import subprocess

from ctypes import wintypes

kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
user32 = ctypes.WinDLL('user32', use_last_error=True)

SW_MAXIMIZE = 3

kernel32.GetConsoleWindow.restype = wintypes.HWND
kernel32.GetLargestConsoleWindowSize.restype = wintypes._COORD
kernel32.GetLargestConsoleWindowSize.argtypes = (wintypes.HANDLE,)
user32.ShowWindow.argtypes = (wintypes.HWND, ctypes.c_int)

def maximize_console(lines=None):
    fd = os.open('CONOUT$', os.O_RDWR)
    try:
        hCon = msvcrt.get_osfhandle(fd)
        max_size = kernel32.GetLargestConsoleWindowSize(hCon)
        if max_size.X == 0 and max_size.Y == 0:
            raise ctypes.WinError(ctypes.get_last_error())
    finally:
        os.close(fd)
    cols = max_size.X
    hWnd = kernel32.GetConsoleWindow()
    if cols and hWnd:
        if lines is None:
            lines = max_size.Y
        else:
            lines = max(min(lines, 9999), max_size.Y)
        subprocess.check_call('mode.com con cols={} lines={}'.format(
                                cols, lines))
        user32.ShowWindow(hWnd, SW_MAXIMIZE)
Comment

PREVIOUS NEXT
Code Example
Python :: Get Key From value in dictionary 
Python :: discordpy 
Python :: Finding the Variance and Standard Deviation of a list of numbers in Python 
Python :: py insert char at index 
Python :: spacex 
Python :: python udp receive 
Python :: TypeError: sequence item 0: expected str instance, int found 
Python :: scatter plot plotly 
Python :: sklearn rmse 
Python :: uninstall poetry 
Python :: location of python in cmd 
Python :: telethon invite to group 
Python :: how to run python code on github 
Python :: how to change the color of command prompt in python 
Python :: how to install python 2 
Python :: pandas dataframe column to datetime 
Python :: how to find second maximum element of an array python 
Python :: how to play mp3 audio in python 
Python :: python virus 
Python :: how to make python remove the duplicates in list 
Python :: python element wise multiplication list 
Python :: python control browse mouse selenium 
Python :: how to get a row from a dataframe in python 
Python :: the system cannot find the file specified sublime text 3 python 
Python :: encode labels in scikit learn 
Python :: RuntimeWarning: invalid value encountered in true_divide 
Python :: get href scrapy xpath 
Python :: run git pull from python script 
Python :: how to get discord username nextcord interactions 
Python :: python version kali linux 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =