This application captures information about open windows on a Windows system at regular intervals. It runs in the background with a system tray icon and saves the captured data to CSV files.
This code was generated using a large language model (LLM). I take no responsibility for the code quality, security vulnerabilities, or any other issues that may arise from using this code. Use at your own risk.
- Captures information about all visible windows, including:
- Window title
- Process name
- Active (foreground) status
- Window order (z-order)
- Runs silently in the system tray
- Captures window information every minute
- Creates a new CSV file for each session
- Logs operations and errors for easy troubleshooting
- Windows operating system
- Python 3.6+
- Required Python packages (see
requirements.txtfor versions):- pywin32
- psutil
- schedule
- pystray
- Pillow
- Clone this repository or download the source code.
- Create a virtual environment:
python -m venv window_capture_env - Activate the virtual environment:
window_capture_env\Scripts\activate - Install the required packages using the
requirements.txtfile:pip install -r requirements.txt
- Ensure your virtual environment is activated.
- Run the
run_window_capture.batfile to start the application. - The application will run in the background with an icon in the system tray.
- To stop the application, right-click the system tray icon and select "Quit".
To make the Window Capture Application start automatically when you log into Windows:
- Right-click on
run_window_capture.batand select "Create shortcut". - Press
Win + Rto open the Run dialog. - Type
shell:startupand press Enter. This opens the Startup folder. - Move the shortcut you created in step 1 into this Startup folder.
Now, the application will start automatically each time you log into your Windows account.
window_capture.py: The main Python script that captures window information.run_window_capture.bat: A batch file to run the script with the correct Python environment.requirements.txt: A list of Python package dependencies.captures/: Directory where CSV files with captured data are stored.logs/: Directory containing the log file (window_capture.log).
Each capture session creates a new CSV file with the following columns:
id: Timestamp of the capture (Unix timestamp)timestamp: ISO format timestamp of when each window was capturedtitle: Window titleprocess: Name of the process that owns the windowis_active: Boolean indicating if the window was active (in the foreground)order: Z-order of the window (1 being topmost)
The application logs its operations and any errors to logs/window_capture.log. Check this file if you encounter any issues or want to monitor the application's activity.