sunlogin_20260309122245.mov
English | 中文
CmdGrid is a lightweight Python utility designed to automatically organize your scattered Command Prompt (CMD) windows into a neat grid layout. It cleans up your desktop by minimizing all unrelated applications and ensures your terminal workspace is tidy and efficient.
- 🧹 Desktop Cleanup: Automatically minimizes all non-CMD windows (browsers, folders, etc.) to reduce distractions.
-
📐 Smart Grid Layout: Arranges all open CMD windows into a perfect
$N \times N$ grid based on the number of windows detected. - 👻 Stealth Mode: The script window itself minimizes during execution to avoid blocking your view, then automatically restores upon completion to show results.
- 🛡️ Self-Aware: Intelligently identifies and excludes its own running instance from being moved or minimized permanently.
-
⚡ Fast & Lightweight: Built with
pywin32, no heavy dependencies required.
- Python 3.x
- Windows OS (This tool uses Windows-specific APIs)
- Dependencies:
pip install pywin32
-
Clone the repository:
git clone https://github.com/firzen/CmdGrid.git cd CmdGrid -
Run the script:
- Recommended: Run as Administrator to ensure it can minimize all system windows successfully.
python arrange_cmds.py
(Or simply double-click
arrange_cmds.pyif you have Python associated, but Admin rights are preferred.) -
What happens next?
- The script window briefly disappears.
- All other apps (Chrome, Explorer, etc.) minimize to the taskbar.
- Your CMD windows snap into a grid.
- The script window reappears with a "Done!" message.
- Scans for all visible windows with the class
ConsoleWindowClass. - Identifies its own Process ID (PID) to exclude itself.
- Minimizes the script window temporarily.
- Iterates through all other visible windows and minimizes them (excluding CMDs and system trays).
- Calculates the optimal grid size (
$3\times3$ ,$4\times4$ , etc.) based on the count of CMD windows. - Restores and resizes each CMD window into the calculated grid positions.
- Restores the script window.
MIT License
CmdGrid 是一个轻量级的 Python 实用工具,旨在将您散乱的命令提示符 (CMD) 窗口自动整理成整齐的网格布局。它通过最小化所有无关应用程序来清理桌面,确保您的终端工作区整洁高效。
- 🧹 桌面清理: 自动最小化所有非 CMD 窗口(如浏览器、文件夹等),减少干扰。
-
📐 智能网格布局: 根据检测到的 CMD 窗口数量,自动将它们排列成完美的
$N \times N$ 网格。 - 👻 隐身模式: 脚本运行时会自动最小化自身窗口,避免遮挡视线;执行完毕后自动还原以显示结果。
- 🛡️ 自我识别: 智能识别并排除正在运行脚本的自身窗口,防止其被误操作或永久最小化。
-
⚡ 快速轻量: 基于
pywin32构建,无需沉重的依赖库。
- Python 3.x
- Windows 操作系统 (本工具使用 Windows 特有 API)
- 依赖安装:
pip install pywin32
-
克隆仓库:
git clone https://github.com/firzen/CmdGrid.git cd CmdGrid -
运行脚本:
- 推荐: 以管理员身份运行,以确保能成功最小化所有系统窗口。
python arrange_cmds.py
(或者直接双击
arrange_cmds.py,但建议赋予管理员权限以获得最佳效果。) -
运行效果:
- 脚本窗口会短暂消失。
- 所有其他应用(Chrome、资源管理器等)最小化到任务栏。
- 您的 CMD 窗口自动吸附到网格位置。
- 脚本窗口重新弹出,显示“完成!”提示。
- 扫描所有类名为
ConsoleWindowClass的可见窗口。 - 识别自身的进程 ID (PID) 以排除自己。
- 暂时最小化脚本窗口。
- 遍历所有其他可见窗口并将其最小化(排除 CMD 窗口和系统托盘等关键窗口)。
- 根据 CMD 窗口数量计算最佳网格大小($3\times3$,
$4\times4$ 等)。 - 还原并调整每个 CMD 窗口的大小,将其放置在计算好的网格坐标上。
- 还原脚本窗口。
MIT License
- Multiple Monitors / 多显示器: Currently supports the primary monitor's work area. 目前主要支持主显示器的工作区域。