Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: default_cmd_properties.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- This script gathers the default Command Prompt properties and outputs them in the terminal.
- Requirements:
- - Python 3.x
- - pygetwindow library (install via 'pip install pygetwindow')
- Usage:
- Run the script in a Python environment. It will automatically retrieve the default properties of the Command Prompt window and display them in the terminal.
- Functions:
- get_default_cmd_properties():
- Retrieves the default properties of the Command Prompt window.
- Returns:
- dict: A dictionary containing the default properties:
- - "Window Size": Tuple of width and height of the Command Prompt window.
- - "Font Name": Default font name used in the Command Prompt window (Consolas).
- - "Font Size": Default font size used in the Command Prompt window (12).
- Example Output:
- Default Command Prompt Properties:
- Window Size: (993, 519)
- Font Name: Consolas
- Font Size: 12
- Additional Notes:
- - If the Command Prompt window is not found or an error occurs during retrieval, an error message will be printed.
- """
- import winreg
- def get_cmd_properties():
- """
- Retrieves the properties of the Command Prompt window.
- Returns:
- dict: A dictionary containing the Command Prompt properties.
- """
- cmd_key_path = r"HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe"
- cmd_properties = {}
- try:
- with winreg.OpenKey(winreg.HKEY_CURRENT_USER, cmd_key_path) as key:
- # Iterate over the values in the registry key
- for i in range(winreg.QueryInfoKey(key)[1]):
- name, value, _ = winreg.EnumValue(key, i)
- cmd_properties[name] = value
- return cmd_properties
- except FileNotFoundError:
- print("Error: Command Prompt properties not found in the registry.")
- return None
- # Get Command Prompt properties
- cmd_properties = get_cmd_properties()
- if cmd_properties:
- print("Command Prompt Properties:")
- for name, value in cmd_properties.items():
- print(f"{name}: {value}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement