wrtype 0.1.0

A Rust implementation of wtype - a Wayland virtual keyboard tool that types text and sends key events
Documentation
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# Examples

Real-world examples demonstrating wrtype's capabilities across different scenarios.

## Basic Examples

### Simple Text Entry

```bash
# Type a URL
wrtype "https://example.com"

# Type an email address
wrtype "user@domain.com"

# Type with special characters
wrtype "Price: $29.99 (20% off!)"
```

### Unicode and International Text

```bash
# Mathematical symbols
wrtype "∫₀^∞ e^(-x²) dx = √π/2"

# International characters
wrtype "Café naïve résumé"

# Multiple scripts
wrtype "Hello नमस्ते こんにちは 안녕하세요"

# Emoji
wrtype "Great work! 🎉 Keep it up! 💪"
```

## Text Editor Automation

### Code Writing

```bash
# Write a Rust function
wrtype 'fn fibonacci(n: u32) -> u32 {
    match n {
        0 => 0,
        1 => 1,
        _ => fibonacci(n - 1) + fibonacci(n - 2),
    }
}'

# Write HTML
wrtype '<!DOCTYPE html>
<html>
<head>
    <title>Test Page</title>
</head>
<body>
    <h1>Hello, World!</h1>
</body>
</html>'
```

### Text Manipulation

```bash
# Select all and replace
wrtype -M ctrl a -m ctrl
wrtype -s 100 "New content replacing everything"

# Go to line start and add comment
wrtype -k Home "// " -k End

# Duplicate current line
wrtype -M ctrl c -m ctrl -k End -k Return -M ctrl v -m ctrl
```

### Find and Replace

```bash
# Open find dialog and search
wrtype -M ctrl f -m ctrl
wrtype -s 200 "old_function_name"
wrtype -k Escape

# Open replace dialog
wrtype -M ctrl h -m ctrl
wrtype "old_function_name" -k Tab "new_function_name"
wrtype -M alt a -m alt  # Replace All
```

## Terminal and Shell Automation

### Command Execution

```bash
# Basic commands
wrtype "ls -la" -k Return
wrtype "cd /home/user/projects" -k Return
wrtype "git status" -k Return

# Pipe commands
wrtype "ps aux | grep firefox" -k Return
wrtype "find . -name '*.rs' | wc -l" -k Return
```

### Interactive Commands

```bash
# SSH with password (be careful with this!)
wrtype "ssh user@server.com" -k Return
# Wait for password prompt...
wrtype -s 2000 "password123" -k Return

# Git operations
wrtype "git add ." -k Return
wrtype "git commit -m 'Update documentation'" -k Return
wrtype "git push origin main" -k Return
```

### Scripting and Automation

```bash
# Create and run a quick script
wrtype "echo '#!/bin/bash' > script.sh" -k Return
wrtype "echo 'echo Hello from script' >> script.sh" -k Return
wrtype "chmod +x script.sh" -k Return
wrtype "./script.sh" -k Return
```

## Web Browser Automation

### Navigation

```bash
# Open new tab
wrtype -M ctrl t -m ctrl

# Go to address bar
wrtype -M ctrl l -m ctrl
wrtype "github.com/conneroisu/wrtype" -k Return

# Search on page
wrtype -M ctrl f -m ctrl
wrtype "virtual keyboard" -k Return
```

### Form Filling

```bash
# Fill login form
wrtype "username@example.com"
wrtype -k Tab  # Move to password field
wrtype "secure_password_123"
wrtype -k Return  # Submit

# Fill contact form
wrtype "John Doe" -k Tab
wrtype "john@example.com" -k Tab  
wrtype "Subject: Important Message" -k Tab
wrtype "This is the message body with
multiple lines of content." -k Tab
wrtype -k Return  # Submit
```

## Desktop Environment Integration

### Application Launching

```bash
# Open application launcher (GNOME/KDE)
wrtype -M alt -k F2 -m alt
wrtype -s 300 "firefox" -k Return

# Or use Super key
wrtype -k Super_L
wrtype -s 200 "terminal" -k Return
```

### Window Management

```bash
# Switch windows
wrtype -M alt -k Tab -m alt

# Move between workspaces
wrtype -M ctrl -M alt -k Right -m alt -m ctrl

# Minimize window
wrtype -M alt -k F9 -m alt

# Close window
wrtype -M alt -k F4 -m alt
```

### System Operations

```bash
# Take screenshot
wrtype -k Print

# Open system settings
wrtype -M ctrl -M alt -k Delete -m alt -m ctrl

# Lock screen
wrtype -M ctrl -M alt -k l -m alt -m ctrl
```

## Development Workflows

### IDE/Editor Operations

```bash
# Open file in VS Code
wrtype -M ctrl o -m ctrl
wrtype -s 300 "src/main.rs" -k Return

# Format code
wrtype -M ctrl -M shift i -m shift -m ctrl

# Open terminal in IDE
wrtype -M ctrl -k grave -m ctrl  # Ctrl+`

# Run program
wrtype -k F5
```

### Git Workflows

```bash
# Interactive git add
wrtype "git add -p" -k Return
# For each hunk:
wrtype "y" -k Return  # Accept
# or
wrtype "n" -k Return  # Skip
# or  
wrtype "s" -k Return  # Split

# Interactive rebase
wrtype "git rebase -i HEAD~3" -k Return
# Edit commits in editor...
wrtype ":wq" -k Return  # Save and exit vim
```

## System Administration

### Package Management

```bash
# Update system (Debian/Ubuntu)
wrtype "sudo apt update && sudo apt upgrade" -k Return
# Enter password when prompted
wrtype -s 2000 "password" -k Return

# Install package
wrtype "sudo apt install htop" -k Return
wrtype "y" -k Return  # Confirm installation
```

### Log Analysis

```bash
# View system logs
wrtype "sudo journalctl -f" -k Return

# Search logs
wrtype "sudo journalctl | grep error" -k Return

# Check disk usage
wrtype "df -h" -k Return
wrtype "du -sh /*" -k Return
```

## Data Processing

### Working with Files

```bash
# Process CSV data
wrtype "cut -d, -f1,3 data.csv | head -10" -k Return

# Search and count
wrtype "grep -r 'TODO' src/ | wc -l" -k Return

# File manipulation
wrtype "find . -name '*.tmp' -delete" -k Return
```

### Text Processing with Pipes

```bash
# Complex pipeline
cat data.txt | wrtype --stdin -d 10
# This types the file content slowly

# Process and type result
echo "ls -la | grep .rs | awk '{print \$9}'" | bash | wrtype --stdin
```

## Testing and QA

### Automated Testing

```bash
# Fill test form
wrtype "test@example.com" -k Tab
wrtype "Test User" -k Tab  
wrtype "123 Test Street" -k Tab
wrtype "Test City" -k Tab
wrtype -k Return  # Submit

# Verify success message appears
# (you'd check this visually or with other tools)
```

### Load Testing

```bash
# Rapid form submission (be careful!)
for i in {1..10}; do
    wrtype "user$i@test.com" -k Tab
    wrtype "password123" -k Tab
    wrtype -k Return
    sleep 1
done
```

## Creative and Entertainment

### Gaming Automation

```bash
# Chat messages
wrtype -k Enter "GG everyone!" -k Return
wrtype -k Enter "/dance" -k Return

# Repeated actions (be mindful of game rules)
wrtype -k space -s 100 -k space -s 100 -k space
```

### Streaming and Content Creation

```bash
# Type chat responses
wrtype "Thanks for following! Welcome to the stream!"

# Add timestamps to content
wrtype "$(date): Starting new section" -k Return
```

## Accessibility and Assistive Technology

### Voice-to-Text Integration

```bash
# Simulate voice command result
# (This would typically be triggered by voice recognition software)
wrtype "Open calculator application"
wrtype -k Return
```

### Macro Replacement

```bash
# Expand abbreviations
# When user types "addr", expand to full address
wrtype -M ctrl a -m ctrl  # Select "addr"
wrtype "123 Main Street, Anytown, ST 12345"
```

## Advanced Patterns

### Conditional Text Entry

```bash
# Check if file exists, then type result
if [ -f "config.txt" ]; then
    wrtype "Config file found" -k Return
else
    wrtype "Config file missing" -k Return
fi
```

### Dynamic Content Generation

```bash
# Type current date and time
wrtype "Report generated on: $(date '+%Y-%m-%d %H:%M:%S')" -k Return

# Type system information
wrtype "System: $(uname -a)" -k Return
wrtype "User: $(whoami)" -k Return
wrtype "Directory: $(pwd)" -k Return
```

### Error Recovery

```bash
# Safe automation with error handling
if wrtype -M ctrl c -m ctrl 2>/dev/null; then
    echo "Successfully sent Ctrl+C"
else
    echo "Failed to send keyboard input"
    # Handle error...
fi
```

## Tips for Effective Usage

1. **Test in Safe Environment**: Always test automation scripts in non-production environments first.

2. **Add Appropriate Delays**: GUI applications need time to process input - use `-s` for timing.

3. **Handle Focus**: Ensure the target application has keyboard focus before sending input.

4. **Error Handling**: Wrap critical operations in error checking.

5. **Documentation**: Comment your automation scripts for future maintenance.

6. **Security**: Be careful with passwords and sensitive data in scripts.

These examples demonstrate wrtype's versatility across different domains. Adapt them to your specific needs and always consider the security and ethical implications of automation.