1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236# Remote Window Controller
A Python application that allows you to remotely control application windows, capture screenshots, and automatically navigate through content by detecting changes between screenshots.
## Features
- **Window Selection**: Browse and select from a list of available application windows
- **Automatic Navigation**: Maximize selected window and send forward arrow key presses
- **Screenshot Capture**: Automatically capture screenshots at configurable intervals
- **Change Detection**: Compare consecutive screenshots to detect when content changes
- **Smart Loop Control**: Automatically stop when no more changes are detected
- **GUI Interface**: User-friendly graphical interface with real-time status updates
- **Configurable Delay**: Adjustable delay between key presses and screenshot captures
## Installation
### Prerequisites
- **Python 3.11** (managed by mise, requires Python 3.8+)
- **mise** (development environment manager)
- **uv** (ultra-fast Python package manager)
### Quick Start
1. **Clone or download** this repository to your local machine
2. **Install mise** (if not already installed):
```bash
# Windows (PowerShell)
powershell -c "irm https://mise.jdx.dev/install.ps1 | iex"
# macOS/Linux
curl https://mise.jdx.dev/install.sh | sh
```
3. **Install Python version and uv**:
```bash
# Install Python 3.11 and uv (mise will read .mise.toml)
mise install
# Install uv if not already installed
mise use uv@latest
```
4. **Install dependencies**:
```bash
uv sync
```
5. **Run the application**:
```bash
uv run python -m remote_window_controller
```
### Alternative Installation Methods
**Using the provided batch file (Windows):**
```bash
install.bat
```
**Manual installation with pip (fallback):**
```bash
pip install pygetwindow pyautogui Pillow opencv-python numpy scikit-image
```
**Development setup with linting:**
```bash
# Install with development dependencies
uv sync --extra dev
# Run linting
uv run ruff check .
# Run formatting
uv run black .
# Run tests
uv run pytest
```
**Using mise for development environment:**
```bash
# Install mise and Python version
mise install
# Activate the environment
mise activate
# Install dependencies
uv sync
```
## Usage
### GUI Mode (Recommended)
1. **Launch the application** - The GUI will open automatically
2. **Select Output Directory** - Click "Browse" to choose where screenshots will be saved
3. **Set Delay** - Configure the delay between key presses (default: 1.0 seconds)
4. **Refresh Windows** - Click "Refresh Windows" to get the current list of available windows
5. **Select Window** - Choose the window you want to control from the list
6. **Start Control** - Click "Start Control" to begin the automation process
### Command Line Mode
If the GUI fails to start, the application will automatically fall back to command line mode:
1. Run `uv run python -m remote_window_controller`
2. Follow the prompts to:
- Select a window by number
- Enter output directory path
- Set delay in seconds
## How It Works
1. **Window Selection**: The application lists all available windows with titles
2. **Maximization**: Selected window is maximized using F11 key
3. **Initial Capture**: First screenshot is captured and saved
4. **Navigation Loop**:
- Send forward arrow key press
- Wait for configured delay
- Capture new screenshot
- Compare with previous screenshot
- If different: save image and continue loop
- If same: exit fullscreen and stop
5. **Cleanup**: Window exits fullscreen mode and returns to normal view
## Output Files
Screenshots are saved in the specified output directory with sequential naming:
- `capture_0000.png` - Initial screenshot
- `capture_0001.png` - After first key press
- `capture_0002.png` - After second key press
- And so on...
## Configuration
- **Delay**: Adjustable from 0.1 to 10.0 seconds
- **Output Directory**: Any writable directory on your system
- **Image Comparison**: Uses structural similarity index (SSIM) with 95% threshold
## Requirements
- Python 3.7 or higher
- Windows operating system (for window control functionality)
- Sufficient disk space for screenshot storage
## Troubleshooting
### Common Issues
1. **"No windows found"**: Make sure you have applications open with visible windows
2. **"Failed to select window"**: The window might be minimized or not accessible
3. **Permission errors**: Ensure the output directory is writable
4. **GUI not starting**: The application will automatically fall back to command line mode
### Tips
- Make sure the target application is visible and not minimized
- Use a reasonable delay (1-2 seconds) to allow content to load
- Ensure sufficient disk space for screenshots
- Close unnecessary applications to reduce the window list clutter
### Screenshot Troubleshooting
If you're getting black screenshots instead of window content:
1. **Run as Administrator**: Right-click and "Run as administrator"
2. **Check Display Settings**: Ensure your display scaling is set to 100%
3. **Disable Hardware Acceleration**: Some applications block screenshots when hardware acceleration is enabled
4. **Try Different Applications**: Some applications (like games or video players) may block screenshots
5. **Check Windows Privacy Settings**: Go to Settings > Privacy > Camera and ensure apps can access camera (affects some screenshot methods)
The application will automatically test screenshot capability and warn you if there are issues.
## Dependencies
- `pygetwindow`: Window enumeration and control
- `pyautogui`: Screenshot capture and key simulation
- `Pillow`: Image processing
- `opencv-python`: Image comparison
- `scikit-image`: Structural similarity calculations
- `numpy`: Numerical operations
- `tkinter`: GUI interface (included with Python)
## Development Environment
This project uses **mise** for development environment management and **uv** for package management:
### mise Configuration
The `.mise.toml` file specifies:
- **Python 3.11** as the required Python version
- **Environment variables** for the project
- **Tool management** for consistent development setup
### mise Commands
- **Install tools**: `mise install`
- **Activate environment**: `mise activate`
- **Check current tools**: `mise list`
- **Update tools**: `mise upgrade`
### uv Package Management
- **Install dependencies**: `uv sync`
- **Add new dependency**: `uv add package-name`
- **Remove dependency**: `uv remove package-name`
- **Run with dependencies**: `uv run python script.py`
- **Update dependencies**: `uv sync --upgrade`
### Benefits
**mise:**
- **Consistent environments** across team members
- **Automatic tool installation** and version management
- **Fast switching** between project environments
- **Cross-platform compatibility**
**uv:**
- **10-100x faster** than pip for dependency resolution
- **Reproducible builds** with lock files
- **Better dependency resolution** with conflict detection
- **Virtual environment management** built-in
**ruff (replaces flake8):**
- **10-100x faster** than flake8 for linting
- **Python 3.11+ compatible** with modern tooling
- **Built-in import sorting** (replaces isort)
- **Comprehensive rule set** covering style, bugs, and complexity
## License
This project is open source and available under the MIT License.