node-mac-recorder 2.16.10 → 2.16.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +1 -1
- package/CLAUDE.md +51 -3
- package/package.json +1 -1
- package/src/mac_recorder.mm +49 -57
- package/bring-to-front-test.js +0 -159
- package/capture-test.js +0 -87
- package/cursor-test.js +0 -22
- package/debug-test.js +0 -95
- package/default-auto-front-test.js +0 -86
- package/final-multi-display-test.js +0 -74
- package/list-test.js +0 -46
- package/quick-cursor-test.js +0 -20
- package/quick-screen-test.js +0 -34
- package/quick-test.js +0 -35
- package/system-sound-test.js +0 -46
- package/test-audio-controls.js +0 -104
- package/test-both.js +0 -46
- package/test-console-logs.js +0 -81
- package/test-coordinate-debug.js +0 -25
- package/test-cursor-visible.js +0 -41
- package/test-electron-detection.js +0 -44
- package/test-final-coordinate-fix.js +0 -38
- package/test-hybrid.js +0 -53
- package/test-macos14-forced.js +0 -107
- package/test-macos14.js +0 -56
- package/test-multi-display-overlay.js +0 -185
- package/test-multi-screen-selection.js +0 -171
- package/test-multidisplay-fix.js +0 -120
- package/test-native-cursor.js +0 -31
- package/test-overlay-tracking.js +0 -175
- package/test-primary-live.js +0 -17
- package/test-primary-window-debug.js +0 -33
- package/test-quick.js +0 -55
- package/test-real-screen-ids.js +0 -32
- package/test-screencapture-only.js +0 -50
- package/test-screencapture-pure.js +0 -69
- package/test-screencapture.js +0 -52
- package/test-system-audio.js +0 -104
- package/test-window-selector-fix.js +0 -88
- package/window-selector-test.js +0 -160
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const MacRecorder = require('./index');
|
|
2
|
-
|
|
3
|
-
console.log('🎯 Testing PURE ScreenCaptureKit (No AVFoundation)');
|
|
4
|
-
|
|
5
|
-
async function testScreenCaptureKitOnly() {
|
|
6
|
-
const recorder = new MacRecorder();
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
const outputPath = './test-output/screencapturekit-only-test.mov';
|
|
10
|
-
|
|
11
|
-
console.log('📹 Starting ScreenCaptureKit-only recording...');
|
|
12
|
-
const success = await recorder.startRecording(outputPath, {
|
|
13
|
-
captureCursor: true,
|
|
14
|
-
includeMicrophone: false,
|
|
15
|
-
includeSystemAudio: false
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
if (success) {
|
|
19
|
-
console.log('✅ Recording started successfully');
|
|
20
|
-
|
|
21
|
-
// Record for 5 seconds
|
|
22
|
-
console.log('⏱️ Recording for 5 seconds...');
|
|
23
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
24
|
-
|
|
25
|
-
console.log('🛑 Stopping recording...');
|
|
26
|
-
await recorder.stopRecording();
|
|
27
|
-
|
|
28
|
-
// Check if file exists and has content
|
|
29
|
-
const fs = require('fs');
|
|
30
|
-
if (fs.existsSync(outputPath)) {
|
|
31
|
-
const stats = fs.statSync(outputPath);
|
|
32
|
-
console.log(`✅ Video file created: ${outputPath} (${stats.size} bytes)`);
|
|
33
|
-
|
|
34
|
-
if (stats.size > 1000) {
|
|
35
|
-
console.log('✅ ScreenCaptureKit-only recording successful');
|
|
36
|
-
} else {
|
|
37
|
-
console.log('⚠️ File size is very small');
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
console.log('❌ Video file not found');
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
console.log('❌ Failed to start recording');
|
|
44
|
-
}
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.log('❌ Error during test:', error.message);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
testScreenCaptureKitOnly().catch(console.error);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const MacRecorder = require('./index');
|
|
2
|
-
|
|
3
|
-
// Simulate Electron environment
|
|
4
|
-
process.env.ELECTRON_RUN_AS_NODE = '1';
|
|
5
|
-
|
|
6
|
-
console.log('🎯 Testing PURE ScreenCaptureKit (Ultra-Safe for Electron)');
|
|
7
|
-
|
|
8
|
-
async function testPureScreenCaptureKit() {
|
|
9
|
-
const recorder = new MacRecorder();
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
const outputPath = './test-output/screencapturekit-pure-test.mov';
|
|
13
|
-
|
|
14
|
-
console.log('📹 Starting PURE ScreenCaptureKit recording...');
|
|
15
|
-
const result = await recorder.startRecording(outputPath, {
|
|
16
|
-
captureCursor: true,
|
|
17
|
-
includeMicrophone: false,
|
|
18
|
-
includeSystemAudio: false
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (result) {
|
|
22
|
-
console.log('✅ Recording started successfully');
|
|
23
|
-
|
|
24
|
-
// Record for 10 seconds to get more frames
|
|
25
|
-
console.log('⏱️ Recording for 10 seconds...');
|
|
26
|
-
await new Promise(resolve => setTimeout(resolve, 10000));
|
|
27
|
-
|
|
28
|
-
console.log('🛑 Stopping recording...');
|
|
29
|
-
await recorder.stopRecording();
|
|
30
|
-
|
|
31
|
-
// Check if file exists and has content
|
|
32
|
-
const fs = require('fs');
|
|
33
|
-
if (fs.existsSync(outputPath)) {
|
|
34
|
-
const stats = fs.statSync(outputPath);
|
|
35
|
-
console.log(`✅ Video file created: ${outputPath} (${stats.size} bytes)`);
|
|
36
|
-
|
|
37
|
-
if (stats.size > 10000) {
|
|
38
|
-
console.log('✅ PURE ScreenCaptureKit successful - Real video!');
|
|
39
|
-
|
|
40
|
-
// Try to get more info about the video
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
const { spawn } = require('child_process');
|
|
43
|
-
const ffprobe = spawn('ffprobe', ['-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', outputPath]);
|
|
44
|
-
let output = '';
|
|
45
|
-
ffprobe.stdout.on('data', (data) => output += data);
|
|
46
|
-
ffprobe.on('close', () => {
|
|
47
|
-
try {
|
|
48
|
-
const info = JSON.parse(output);
|
|
49
|
-
console.log(`🎞️ Video info: ${info.format.duration}s, ${info.streams[0].nb_frames} frames`);
|
|
50
|
-
} catch (e) {
|
|
51
|
-
console.log('📊 Video analysis failed, but file exists');
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}, 1000);
|
|
55
|
-
} else {
|
|
56
|
-
console.log('⚠️ File size is very small - may not have content');
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
console.log('❌ Video file not found');
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
console.log('❌ Failed to start recording');
|
|
63
|
-
}
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.log('❌ Error during test:', error.message);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
testPureScreenCaptureKit().catch(console.error);
|
package/test-screencapture.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const MacRecorder = require('./index');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
|
|
4
|
-
async function testScreenCaptureKit() {
|
|
5
|
-
const recorder = new MacRecorder();
|
|
6
|
-
|
|
7
|
-
console.log('🔍 Testing ScreenCaptureKit Integration');
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
// Check if we can start recording
|
|
11
|
-
const outputPath = './test-output/screencapturekit-test.mov';
|
|
12
|
-
|
|
13
|
-
console.log('📹 Starting recording with ScreenCaptureKit...');
|
|
14
|
-
const success = await recorder.startRecording(outputPath, {
|
|
15
|
-
captureCursor: true,
|
|
16
|
-
includeMicrophone: false,
|
|
17
|
-
includeSystemAudio: false
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
if (success) {
|
|
21
|
-
console.log('✅ Recording started successfully');
|
|
22
|
-
|
|
23
|
-
// Record for 5 seconds
|
|
24
|
-
console.log('⏱️ Recording for 5 seconds...');
|
|
25
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
26
|
-
|
|
27
|
-
console.log('🛑 Stopping recording...');
|
|
28
|
-
await recorder.stopRecording();
|
|
29
|
-
|
|
30
|
-
// Check if file exists and has content
|
|
31
|
-
if (fs.existsSync(outputPath)) {
|
|
32
|
-
const stats = fs.statSync(outputPath);
|
|
33
|
-
console.log(`✅ Video file created: ${outputPath} (${stats.size} bytes)`);
|
|
34
|
-
|
|
35
|
-
if (stats.size > 1000) {
|
|
36
|
-
console.log('✅ File size looks good - recording likely successful');
|
|
37
|
-
} else {
|
|
38
|
-
console.log('⚠️ File size is very small - recording may have failed');
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
console.log('❌ Video file not found');
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
console.log('❌ Failed to start recording');
|
|
45
|
-
}
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.log('❌ Error during test:', error.message);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Run test
|
|
52
|
-
testScreenCaptureKit().catch(console.error);
|
package/test-system-audio.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
const MacRecorder = require('./index');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
async function testSystemAudio() {
|
|
5
|
-
const recorder = new MacRecorder();
|
|
6
|
-
|
|
7
|
-
console.log('🎵 Sistem Sesi Yakalama Testi Başlıyor...\n');
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
// Önce izinleri kontrol et
|
|
11
|
-
const permissions = await recorder.checkPermissions();
|
|
12
|
-
console.log('📋 İzinler:', permissions);
|
|
13
|
-
|
|
14
|
-
if (!permissions.screenRecording) {
|
|
15
|
-
console.log('❌ Ekran kayıt izni gerekli. System Preferences > Security & Privacy > Screen Recording');
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Mevcut ses cihazlarını listele
|
|
20
|
-
console.log('\n🎤 Mevcut Ses Cihazları:');
|
|
21
|
-
const audioDevices = await recorder.getAudioDevices();
|
|
22
|
-
audioDevices.forEach((device, index) => {
|
|
23
|
-
console.log(`${index + 1}. ${device.name}`);
|
|
24
|
-
if (device.id) console.log(` ID: ${device.id}`);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Sistem sesi cihazı ara
|
|
28
|
-
const systemAudioDevice = audioDevices.find(device =>
|
|
29
|
-
device.name.toLowerCase().includes('blackhole') ||
|
|
30
|
-
device.name.toLowerCase().includes('soundflower') ||
|
|
31
|
-
device.name.toLowerCase().includes('loopback') ||
|
|
32
|
-
device.name.toLowerCase().includes('aggregate') ||
|
|
33
|
-
device.name.toLowerCase().includes('imobie')
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
console.log('\n=== Test 1: Sistem Sesi KAPALI ===');
|
|
37
|
-
const outputPath1 = path.join(__dirname, 'test-output', 'no-system-audio.mov');
|
|
38
|
-
|
|
39
|
-
await recorder.startRecording(outputPath1, {
|
|
40
|
-
includeSystemAudio: false, // Sistem sesi kapalı
|
|
41
|
-
includeMicrophone: false,
|
|
42
|
-
captureCursor: true,
|
|
43
|
-
captureArea: { x: 0, y: 0, width: 400, height: 300 } // Küçük alan
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
console.log('🔴 5 saniye kayıt yapılıyor (sistem sesi KAPALI)...');
|
|
47
|
-
console.log('💡 Şimdi müzik çal veya YouTube video aç - ses KAYIT EDİLMEMELİ');
|
|
48
|
-
|
|
49
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
50
|
-
await recorder.stopRecording();
|
|
51
|
-
console.log(`✅ Kayıt tamamlandı: ${outputPath1}`);
|
|
52
|
-
|
|
53
|
-
// 2 saniye bekle
|
|
54
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
55
|
-
|
|
56
|
-
console.log('\n=== Test 2: Sistem Sesi AÇIK ===');
|
|
57
|
-
const outputPath2 = path.join(__dirname, 'test-output', 'with-system-audio.mov');
|
|
58
|
-
|
|
59
|
-
const options2 = {
|
|
60
|
-
includeSystemAudio: true, // Sistem sesi açık
|
|
61
|
-
includeMicrophone: false,
|
|
62
|
-
captureCursor: true,
|
|
63
|
-
captureArea: { x: 0, y: 0, width: 400, height: 300 }
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// Eğer sistem sesi cihazı varsa onu kullan
|
|
67
|
-
if (systemAudioDevice) {
|
|
68
|
-
options2.systemAudioDeviceId = systemAudioDevice.id;
|
|
69
|
-
console.log(`🎯 Kullanılan sistem sesi cihazı: ${systemAudioDevice.name}`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
await recorder.startRecording(outputPath2, options2);
|
|
73
|
-
|
|
74
|
-
console.log('🔴 5 saniye kayıt yapılıyor (sistem sesi AÇIK)...');
|
|
75
|
-
console.log('🎵 Şimdi müzik çal veya YouTube video aç - ses KAYIT EDİLMELİ');
|
|
76
|
-
|
|
77
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
78
|
-
await recorder.stopRecording();
|
|
79
|
-
console.log(`✅ Kayıt tamamlandı: ${outputPath2}`);
|
|
80
|
-
|
|
81
|
-
console.log('\n=== 🎉 TEST TAMAMLANDI ===');
|
|
82
|
-
console.log('📁 Kayıtları karşılaştır:');
|
|
83
|
-
console.log(`1. ${outputPath1} (sistem sesi YOK)`);
|
|
84
|
-
console.log(`2. ${outputPath2} (sistem sesi VAR)`);
|
|
85
|
-
|
|
86
|
-
if (!systemAudioDevice) {
|
|
87
|
-
console.log('\n⚠️ Sistem sesi cihazı bulunamadı!');
|
|
88
|
-
console.log('💡 Daha iyi sistem sesi yakalama için şunları yükle:');
|
|
89
|
-
console.log(' • BlackHole: https://github.com/ExistentialAudio/BlackHole');
|
|
90
|
-
console.log(' • Soundflower: https://github.com/mattingalls/Soundflower');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
console.log('\n🔍 Kayıtları test etmek için:');
|
|
94
|
-
console.log('1. Dosyaları QuickTime Player ile aç');
|
|
95
|
-
console.log('2. İlk kayıtta ses olmamalı');
|
|
96
|
-
console.log('3. İkinci kayıtta sistem sesi olmalı');
|
|
97
|
-
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error('❌ Test hatası:', error.message);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Testi çalıştır
|
|
104
|
-
testSystemAudio();
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
const MacRecorder = require('./index');
|
|
2
|
-
const WindowSelector = MacRecorder.WindowSelector;
|
|
3
|
-
|
|
4
|
-
async function testWindowSelector() {
|
|
5
|
-
console.log('🪟 Testing FIXED window selector multi-display...');
|
|
6
|
-
|
|
7
|
-
const recorder = new MacRecorder();
|
|
8
|
-
const displays = await recorder.getDisplays();
|
|
9
|
-
|
|
10
|
-
console.log('📊 Display setup:');
|
|
11
|
-
displays.forEach((display, index) => {
|
|
12
|
-
console.log(` ${display.name}: ${display.resolution} at (${display.x}, ${display.y}) ${display.isPrimary ? '[PRIMARY]' : ''}`);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const selector = new WindowSelector();
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
console.log('\n🔍 Starting window selection...');
|
|
19
|
-
console.log(' - Test windows on BOTH displays');
|
|
20
|
-
console.log(' - Check if buttons appear correctly positioned');
|
|
21
|
-
console.log(' - Primary display should now work correctly');
|
|
22
|
-
|
|
23
|
-
await selector.startSelection();
|
|
24
|
-
|
|
25
|
-
// Let it run for 20 seconds for thorough testing
|
|
26
|
-
await new Promise(resolve => setTimeout(resolve, 20000));
|
|
27
|
-
|
|
28
|
-
console.log('🛑 Stopping window selection...');
|
|
29
|
-
await selector.stopSelection();
|
|
30
|
-
|
|
31
|
-
console.log('✅ Window selector test completed!');
|
|
32
|
-
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.log(`❌ Window selector test failed: ${error.message}`);
|
|
35
|
-
console.log(error.stack);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function testSecondaryDisplayRecording() {
|
|
40
|
-
console.log('\n🎥 Testing secondary display recording...');
|
|
41
|
-
|
|
42
|
-
const recorder = new MacRecorder();
|
|
43
|
-
const displays = await recorder.getDisplays();
|
|
44
|
-
|
|
45
|
-
const secondaryDisplay = displays.find(d => !d.isPrimary);
|
|
46
|
-
if (!secondaryDisplay) {
|
|
47
|
-
console.log('⚠️ No secondary display found');
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log(`🖥️ Testing recording on ${secondaryDisplay.name} (ID: ${secondaryDisplay.id})`);
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
const outputPath = `./test-output/secondary-display-fix-test.mov`;
|
|
55
|
-
|
|
56
|
-
await recorder.startRecording(outputPath, {
|
|
57
|
-
displayId: secondaryDisplay.id,
|
|
58
|
-
captureCursor: true,
|
|
59
|
-
includeMicrophone: false,
|
|
60
|
-
includeSystemAudio: false
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
console.log('✅ Recording started on secondary display');
|
|
64
|
-
|
|
65
|
-
// Record for 3 seconds
|
|
66
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
67
|
-
|
|
68
|
-
await recorder.stopRecording();
|
|
69
|
-
console.log('✅ Recording completed on secondary display');
|
|
70
|
-
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.log(`❌ Secondary display recording failed: ${error.message}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function runTests() {
|
|
77
|
-
try {
|
|
78
|
-
await testWindowSelector();
|
|
79
|
-
await testSecondaryDisplayRecording();
|
|
80
|
-
|
|
81
|
-
console.log('\n🎉 All tests completed!');
|
|
82
|
-
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.log(`❌ Test suite failed: ${error.message}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
runTests();
|
package/window-selector-test.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const WindowSelector = require('./window-selector');
|
|
4
|
-
const readline = require('readline');
|
|
5
|
-
|
|
6
|
-
async function main() {
|
|
7
|
-
console.log('🔍 Window Selector Test');
|
|
8
|
-
console.log('=======================\n');
|
|
9
|
-
|
|
10
|
-
const selector = new WindowSelector();
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
// Permissions kontrolü
|
|
14
|
-
console.log('1️⃣ Checking permissions...');
|
|
15
|
-
const permissions = await selector.checkPermissions();
|
|
16
|
-
console.log('Permissions:', permissions);
|
|
17
|
-
|
|
18
|
-
if (!permissions.screenRecording || !permissions.accessibility) {
|
|
19
|
-
console.warn('⚠️ Warning: Some permissions missing. Go to System Preferences > Security & Privacy');
|
|
20
|
-
console.warn(' - Privacy > Screen Recording: Enable for Terminal/Node');
|
|
21
|
-
console.warn(' - Privacy > Accessibility: Enable for Terminal/Node');
|
|
22
|
-
console.log();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Event listener'ları ayarla
|
|
26
|
-
selector.on('selectionStarted', () => {
|
|
27
|
-
console.log('✅ Window selection started');
|
|
28
|
-
console.log('🖱️ Move your cursor over windows to highlight them');
|
|
29
|
-
console.log('🎯 Click "Select Window" button to choose a window');
|
|
30
|
-
console.log('❌ Press Ctrl+C to cancel\n');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
selector.on('windowEntered', (window) => {
|
|
34
|
-
console.log(`🏠 Entered window: "${window.title}" - ${window.appName}`);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
selector.on('windowLeft', (window) => {
|
|
38
|
-
console.log(`🚪 Left window: "${window.title}" - ${window.appName}`);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
selector.on('windowSelected', (windowInfo) => {
|
|
42
|
-
console.log('\n🎉 Window Selected!');
|
|
43
|
-
console.log('==================');
|
|
44
|
-
console.log(`Title: "${windowInfo.title}"`);
|
|
45
|
-
console.log(`Application: ${windowInfo.appName}`);
|
|
46
|
-
console.log(`Position: (${windowInfo.x}, ${windowInfo.y})`);
|
|
47
|
-
console.log(`Size: ${windowInfo.width} x ${windowInfo.height}`);
|
|
48
|
-
console.log(`Screen ID: ${windowInfo.screenId}`);
|
|
49
|
-
console.log(`Screen Position: (${windowInfo.screenX}, ${windowInfo.screenY})`);
|
|
50
|
-
console.log(`Screen Size: ${windowInfo.screenWidth} x ${windowInfo.screenHeight}`);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
selector.on('selectionStopped', () => {
|
|
54
|
-
console.log('🛑 Window selection stopped');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
selector.on('error', (error) => {
|
|
58
|
-
console.error('❌ Error:', error.message);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// Ctrl+C handler
|
|
62
|
-
process.on('SIGINT', async () => {
|
|
63
|
-
console.log('\n\n🛑 Stopping window selection...');
|
|
64
|
-
await selector.cleanup();
|
|
65
|
-
process.exit(0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
console.log('2️⃣ Testing window selection...\n');
|
|
69
|
-
|
|
70
|
-
// Seçim başlat
|
|
71
|
-
const selectedWindow = await selector.selectWindow();
|
|
72
|
-
|
|
73
|
-
if (selectedWindow) {
|
|
74
|
-
console.log('\n✨ Final result:');
|
|
75
|
-
console.log(JSON.stringify(selectedWindow, null, 2));
|
|
76
|
-
|
|
77
|
-
// Ek bilgiler
|
|
78
|
-
console.log('\n📊 Additional Analysis:');
|
|
79
|
-
console.log(`Window area: ${selectedWindow.width * selectedWindow.height} pixels`);
|
|
80
|
-
console.log(`Aspect ratio: ${(selectedWindow.width / selectedWindow.height).toFixed(2)}`);
|
|
81
|
-
|
|
82
|
-
// Window bounds relative to screen
|
|
83
|
-
const relativeX = selectedWindow.x - selectedWindow.screenX;
|
|
84
|
-
const relativeY = selectedWindow.y - selectedWindow.screenY;
|
|
85
|
-
console.log(`Relative position on screen: (${relativeX}, ${relativeY})`);
|
|
86
|
-
|
|
87
|
-
if (relativeX < 0 || relativeY < 0 ||
|
|
88
|
-
relativeX + selectedWindow.width > selectedWindow.screenWidth ||
|
|
89
|
-
relativeY + selectedWindow.height > selectedWindow.screenHeight) {
|
|
90
|
-
console.log('⚠️ Window extends beyond screen boundaries (multi-monitor setup)');
|
|
91
|
-
} else {
|
|
92
|
-
console.log('✅ Window is fully contained within its screen');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
} catch (error) {
|
|
97
|
-
console.error('❌ Test failed:', error.message);
|
|
98
|
-
console.error(error.stack);
|
|
99
|
-
} finally {
|
|
100
|
-
await selector.cleanup();
|
|
101
|
-
console.log('\n🧹 Cleanup completed');
|
|
102
|
-
process.exit(0);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Alternative test function for programmatic testing
|
|
107
|
-
async function testWindowSelectorAPI() {
|
|
108
|
-
console.log('🧪 API Test Mode');
|
|
109
|
-
console.log('===============\n');
|
|
110
|
-
|
|
111
|
-
const selector = new WindowSelector();
|
|
112
|
-
|
|
113
|
-
try {
|
|
114
|
-
// Test 1: Status before selection
|
|
115
|
-
console.log('Test 1: Initial status');
|
|
116
|
-
const initialStatus = selector.getStatus();
|
|
117
|
-
console.log('Initial status:', initialStatus);
|
|
118
|
-
console.assert(!initialStatus.isSelecting, 'Should not be selecting initially');
|
|
119
|
-
console.assert(!initialStatus.hasSelectedWindow, 'Should not have selected window initially');
|
|
120
|
-
console.log('✅ Initial status test passed\n');
|
|
121
|
-
|
|
122
|
-
// Test 2: Start selection
|
|
123
|
-
console.log('Test 2: Start selection');
|
|
124
|
-
await selector.startSelection();
|
|
125
|
-
const selectingStatus = selector.getStatus();
|
|
126
|
-
console.log('Selecting status:', selectingStatus);
|
|
127
|
-
console.assert(selectingStatus.isSelecting, 'Should be selecting after start');
|
|
128
|
-
console.log('✅ Start selection test passed\n');
|
|
129
|
-
|
|
130
|
-
// Wait a bit to let user move cursor
|
|
131
|
-
console.log('Move your cursor over different windows for 3 seconds...');
|
|
132
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
133
|
-
|
|
134
|
-
// Test 3: Stop selection
|
|
135
|
-
console.log('Test 3: Stop selection');
|
|
136
|
-
await selector.stopSelection();
|
|
137
|
-
const stoppedStatus = selector.getStatus();
|
|
138
|
-
console.log('Stopped status:', stoppedStatus);
|
|
139
|
-
console.assert(!stoppedStatus.isSelecting, 'Should not be selecting after stop');
|
|
140
|
-
console.log('✅ Stop selection test passed\n');
|
|
141
|
-
|
|
142
|
-
console.log('🎉 All API tests passed!');
|
|
143
|
-
|
|
144
|
-
} catch (error) {
|
|
145
|
-
console.error('❌ API test failed:', error.message);
|
|
146
|
-
throw error;
|
|
147
|
-
} finally {
|
|
148
|
-
await selector.cleanup();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Parse command line arguments
|
|
153
|
-
const args = process.argv.slice(2);
|
|
154
|
-
const testMode = args.includes('--api-test') ? 'api' : 'interactive';
|
|
155
|
-
|
|
156
|
-
if (testMode === 'api') {
|
|
157
|
-
testWindowSelectorAPI().catch(console.error);
|
|
158
|
-
} else {
|
|
159
|
-
main().catch(console.error);
|
|
160
|
-
}
|