Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: notepad_navigator.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- This script provides a simple interface for interacting with Notepad windows on Windows operating systems.
- It allows users to move and resize Notepad windows to specific locations on the screen.
- Requirements:
- - Python 3.x
- - Windows operating system
- Functions:
- 1. move_and_resize_notepad():
- - Prompts the user to select a cell location and then moves and resizes the Notepad window accordingly.
- 2. main_menu():
- - Displays a menu for the user to choose options like moving and resizing Notepad or exiting the program.
- Usage:
- To use this script, run it in a Python environment.
- Follow the on-screen instructions to choose options from the menu.
- Additional Notes:
- - This script assumes that Notepad is available and accessible on the system.
- - It uses ctypes to interact with the Windows API for window manipulation.
- """
- import subprocess
- import time
- import ctypes
- import ctypes.wintypes
- # Define necessary Win32 API functions using ctypes
- screen = ctypes.windll.user32
- # Function to move and resize Notepad
- def move_and_resize_notepad():
- # Prompt user for cell selection
- print("\nSelect a cell to move the Notepad window:\n")
- print("\t\t | | | | | | | ")
- print("\t\t-|---|---|---|---|---|---|-")
- print("\t\t | T1| T2| T3| T4| T5| T6| ")
- print("\t\t-|---|---|---|---|---|---|-")
- print("\t\t | C1| C2| C3| C4| C5| C6| ")
- print("\t\t-|---|---|---|---|---|---|-")
- print("\t\t | B1| B2| B3| B4| B5| B6| ")
- print("\t\t-|---|---|---|---|---|---|-")
- print("\t\t | | | | | | |\n")
- choice = input("Enter your choice (e.g., T3): ").upper()
- print("\nNotepad Co-Ordinates Have Been Set!\n")
- # Validate user choice
- if (
- len(choice) == 2
- and choice[0] in ["T", "C", "B"]
- and choice[1] in ["1", "2", "3", "4", "5", "6"]
- ):
- row = choice[0] # Extract row (T, C, B)
- col = int(choice[1]) - 1 # Extract column (1-based index)
- # Calculate position based on user choice
- screen_width = screen.GetSystemMetrics(0)
- screen_height = screen.GetSystemMetrics(1)
- cell_width = screen_width // 6
- cell_height = screen_height // 3
- if row == "T": # TOP ROW
- y = 0
- elif row == "C": # CENTER ROW
- y = cell_height
- elif row == "B": # BOTTOM ROW
- y = cell_height * 2
- x = col * cell_width
- width = int(input("Enter the width of the Notepad window: "))
- height = int(input("\nEnter the height of the Notepad window: "))
- print(
- "\nNotepad Dimensions Have Been Set!\n\nOpening Notepad...\n\nMoving Notepad...\n"
- )
- # Start Notepad
- subprocess.Popen(["notepad.exe"])
- time.sleep(1) # Wait for Notepad to open
- # Move and resize window
- hwnd = screen.FindWindowW(None, "Untitled - Notepad")
- if hwnd:
- screen.SetWindowPos(hwnd, None, x, y, width, height, 0)
- print("Moved and resized Notepad Successfully!\n\n\n\n")
- else:
- print("\nNotepad window not found!\n")
- else:
- print("\nInvalid choice. Notepad window will not be moved!\n")
- # Main menu
- def main_menu():
- while True:
- print("\n\n\n\n\t\t\t:: NOTEPAD NAVIGATOR ::\n")
- print("\nChoose an option:\n")
- print("1. Move and resize Notepad")
- print("2. Exit")
- choice = input("\nEnter your choice: ")
- if choice == "1":
- move_and_resize_notepad()
- elif choice == "2":
- print("\nExiting Program...\tGoodBye!\n\n")
- break
- else:
- print("\nInvalid choice! Please enter a valid option.\n")
- if __name__ == "__main__":
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement