node-mac-recorder 1.4.0 โ 1.5.0
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/WINDOW_SELECTOR_README.md +4 -3
- package/debug-test.js +95 -0
- package/default-auto-front-test.js +86 -0
- package/package.json +1 -1
- package/src/window_selector.mm +23 -9
- package/window-selector.js +4 -1
|
@@ -334,15 +334,15 @@ if (!permissions.screenRecording) {
|
|
|
334
334
|
|
|
335
335
|
## ๐ Geliลmiล รrnekler
|
|
336
336
|
|
|
337
|
-
### Auto Bring-to-Front (Otomatik Focus)
|
|
337
|
+
### Auto Bring-to-Front (DEFAULT - Otomatik Focus)
|
|
338
338
|
```javascript
|
|
339
339
|
const WindowSelector = require('./window-selector');
|
|
340
340
|
|
|
341
341
|
async function autoBringToFront() {
|
|
342
342
|
const selector = new WindowSelector();
|
|
343
343
|
|
|
344
|
-
//
|
|
345
|
-
selector.setBringToFrontEnabled(
|
|
344
|
+
// Auto bring-to-front varsayฤฑlan olarak AรIK
|
|
345
|
+
// (Kapatmak iรงin: selector.setBringToFrontEnabled(false))
|
|
346
346
|
|
|
347
347
|
selector.on('windowEntered', (window) => {
|
|
348
348
|
console.log(`๐ Auto-focused: ${window.appName} - "${window.title}"`);
|
|
@@ -350,6 +350,7 @@ async function autoBringToFront() {
|
|
|
350
350
|
|
|
351
351
|
await selector.startSelection();
|
|
352
352
|
console.log('๐ฑ๏ธ Move cursor over windows - they will come to front automatically!');
|
|
353
|
+
console.log('๐ก Only the specific window focuses, not all windows of the app');
|
|
353
354
|
}
|
|
354
355
|
```
|
|
355
356
|
|
package/debug-test.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const WindowSelector = require('./window-selector');
|
|
4
|
+
|
|
5
|
+
async function debugTest() {
|
|
6
|
+
console.log('๐ Debug Window Selector Test');
|
|
7
|
+
console.log('==============================\n');
|
|
8
|
+
|
|
9
|
+
const selector = new WindowSelector();
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
// ฤฐzinleri kontrol et
|
|
13
|
+
console.log('๐ Checking permissions...');
|
|
14
|
+
const permissions = await selector.checkPermissions();
|
|
15
|
+
console.log('Permissions:', JSON.stringify(permissions, null, 2));
|
|
16
|
+
|
|
17
|
+
if (!permissions.screenRecording || !permissions.accessibility) {
|
|
18
|
+
console.log('\nโ MISSING PERMISSIONS!');
|
|
19
|
+
console.log('Please enable in System Preferences > Security & Privacy:');
|
|
20
|
+
console.log(' โ Screen Recording - Add Terminal/your IDE');
|
|
21
|
+
console.log(' โ Accessibility - Add Terminal/your IDE');
|
|
22
|
+
console.log('\nAfter enabling permissions, restart this test.');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
console.log('โ
Permissions OK\n');
|
|
27
|
+
|
|
28
|
+
// Debug mode ile baลlat
|
|
29
|
+
console.log('๐ Starting selection with debug info...');
|
|
30
|
+
await selector.startSelection();
|
|
31
|
+
|
|
32
|
+
let windowCount = 0;
|
|
33
|
+
|
|
34
|
+
selector.on('windowEntered', (window) => {
|
|
35
|
+
windowCount++;
|
|
36
|
+
console.log(`\n[${windowCount}] ๐ฏ WINDOW DETECTED:`);
|
|
37
|
+
console.log(` App: ${window.appName}`);
|
|
38
|
+
console.log(` Title: "${window.title}"`);
|
|
39
|
+
console.log(` ID: ${window.id}`);
|
|
40
|
+
console.log(` Position: (${window.x}, ${window.y})`);
|
|
41
|
+
console.log(` Size: ${window.width} ร ${window.height}`);
|
|
42
|
+
console.log(` ๐ Should auto-focus now...`);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
selector.on('windowLeft', (window) => {
|
|
46
|
+
console.log(`\n๐ช LEFT WINDOW: ${window.appName} - "${window.title}"`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
selector.on('error', (error) => {
|
|
50
|
+
console.error('\nโ ERROR:', error.message);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
console.log('๐ Test Instructions:');
|
|
54
|
+
console.log(' 1. Move cursor over different application windows');
|
|
55
|
+
console.log(' 2. You should see:');
|
|
56
|
+
console.log(' - Blue overlay rectangle around windows');
|
|
57
|
+
console.log(' - "Select Window" button in center');
|
|
58
|
+
console.log(' - Windows automatically coming to front');
|
|
59
|
+
console.log(' 3. If overlay not visible, check permissions');
|
|
60
|
+
console.log(' 4. Press Ctrl+C to exit\n');
|
|
61
|
+
console.log('๐ฑ๏ธ START MOVING CURSOR NOW...\n');
|
|
62
|
+
|
|
63
|
+
// Status monitoring
|
|
64
|
+
let statusCount = 0;
|
|
65
|
+
setInterval(() => {
|
|
66
|
+
statusCount++;
|
|
67
|
+
const status = selector.getStatus();
|
|
68
|
+
|
|
69
|
+
if (statusCount % 50 === 0) { // Every 5 seconds
|
|
70
|
+
console.log(`โฑ๏ธ Status Check #${statusCount/50}:`);
|
|
71
|
+
console.log(` - Selecting: ${status.isSelecting}`);
|
|
72
|
+
console.log(` - Windows found: ${status.nativeStatus?.windowCount || 0}`);
|
|
73
|
+
console.log(` - Overlay active: ${status.nativeStatus?.hasOverlay || false}`);
|
|
74
|
+
if (status.nativeStatus?.currentWindow) {
|
|
75
|
+
console.log(` - Current: ${status.nativeStatus.currentWindow.appName}`);
|
|
76
|
+
}
|
|
77
|
+
console.log('');
|
|
78
|
+
}
|
|
79
|
+
}, 100);
|
|
80
|
+
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('โ Fatal Error:', error.message);
|
|
83
|
+
console.error(error.stack);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Handle Ctrl+C gracefully
|
|
88
|
+
process.on('SIGINT', async () => {
|
|
89
|
+
console.log('\n\n๐ Stopping debug test...');
|
|
90
|
+
process.exit(0);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (require.main === module) {
|
|
94
|
+
debugTest();
|
|
95
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const WindowSelector = require('./window-selector');
|
|
4
|
+
|
|
5
|
+
async function testDefaultAutoBringToFront() {
|
|
6
|
+
console.log('๐ Default Auto Bring-To-Front Test');
|
|
7
|
+
console.log('====================================\n');
|
|
8
|
+
|
|
9
|
+
const selector = new WindowSelector();
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
console.log('๐ Starting window selector with DEFAULT auto bring-to-front...');
|
|
13
|
+
console.log('(Auto bring-to-front is now enabled by default)\n');
|
|
14
|
+
|
|
15
|
+
console.log('๐ Instructions:');
|
|
16
|
+
console.log(' โข Move cursor over different windows');
|
|
17
|
+
console.log(' โข Each window should automatically come to front');
|
|
18
|
+
console.log(' โข Only the specific window should focus (not whole app)');
|
|
19
|
+
console.log(' โข Press D to disable auto mode');
|
|
20
|
+
console.log(' โข Press E to re-enable auto mode');
|
|
21
|
+
console.log(' โข Press Ctrl+C to exit\n');
|
|
22
|
+
|
|
23
|
+
let windowCount = 0;
|
|
24
|
+
let lastWindowId = null;
|
|
25
|
+
|
|
26
|
+
selector.on('windowEntered', (window) => {
|
|
27
|
+
if (window.id !== lastWindowId) {
|
|
28
|
+
windowCount++;
|
|
29
|
+
console.log(`[${windowCount}] ๐ฏ WINDOW: ${window.appName} - "${window.title}"`);
|
|
30
|
+
console.log(` ๐ Position: (${window.x}, ${window.y})`);
|
|
31
|
+
console.log(` ๐ Size: ${window.width} ร ${window.height}`);
|
|
32
|
+
console.log(` ๐ Should auto-focus THIS specific window only!`);
|
|
33
|
+
lastWindowId = window.id;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
selector.on('windowLeft', (window) => {
|
|
38
|
+
console.log(`๐ช Left: ${window.appName} - "${window.title}"\n`);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Keyboard controls
|
|
42
|
+
const readline = require('readline');
|
|
43
|
+
readline.emitKeypressEvents(process.stdin);
|
|
44
|
+
if (process.stdin.isTTY) {
|
|
45
|
+
process.stdin.setRawMode(true);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
process.stdin.on('keypress', async (str, key) => {
|
|
49
|
+
if (key.name === 'd') {
|
|
50
|
+
console.log('\n๐ Disabling auto bring-to-front...');
|
|
51
|
+
selector.setBringToFrontEnabled(false);
|
|
52
|
+
console.log(' โ
Auto mode OFF - Windows will not auto-focus');
|
|
53
|
+
} else if (key.name === 'e') {
|
|
54
|
+
console.log('\n๐ Enabling auto bring-to-front...');
|
|
55
|
+
selector.setBringToFrontEnabled(true);
|
|
56
|
+
console.log(' โ
Auto mode ON - Windows will auto-focus again');
|
|
57
|
+
} else if (key.ctrl && key.name === 'c') {
|
|
58
|
+
console.log('\n\n๐ Stopping...');
|
|
59
|
+
console.log(`๐ Total windows encountered: ${windowCount}`);
|
|
60
|
+
await selector.cleanup();
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await selector.startSelection();
|
|
66
|
+
|
|
67
|
+
// Status update every 10 seconds
|
|
68
|
+
setInterval(() => {
|
|
69
|
+
console.log(`\nโฑ๏ธ Status: ${windowCount} windows encountered so far`);
|
|
70
|
+
console.log(' (Continue moving cursor over windows to test auto-focus)');
|
|
71
|
+
}, 10000);
|
|
72
|
+
|
|
73
|
+
// Keep running
|
|
74
|
+
setInterval(() => {}, 1000);
|
|
75
|
+
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error('โ Error:', error.message);
|
|
78
|
+
console.error(error.stack);
|
|
79
|
+
} finally {
|
|
80
|
+
await selector.cleanup();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (require.main === module) {
|
|
85
|
+
testDefaultAutoBringToFront();
|
|
86
|
+
}
|
package/package.json
CHANGED
package/src/window_selector.mm
CHANGED
|
@@ -35,8 +35,8 @@ bool bringWindowToFront(int windowId);
|
|
|
35
35
|
self = [super initWithFrame:frameRect];
|
|
36
36
|
if (self) {
|
|
37
37
|
self.wantsLayer = YES;
|
|
38
|
-
self.layer.backgroundColor = [[NSColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:0.
|
|
39
|
-
self.layer.borderColor = [[NSColor colorWithRed:
|
|
38
|
+
self.layer.backgroundColor = [[NSColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:0.6] CGColor];
|
|
39
|
+
self.layer.borderColor = [[NSColor colorWithRed:0.0 green:0.4 blue:0.8 alpha:0.9] CGColor];
|
|
40
40
|
self.layer.borderWidth = 5.0;
|
|
41
41
|
self.layer.cornerRadius = 8.0;
|
|
42
42
|
}
|
|
@@ -49,11 +49,11 @@ bool bringWindowToFront(int windowId);
|
|
|
49
49
|
if (!self.windowInfo) return;
|
|
50
50
|
|
|
51
51
|
// Background with transparency
|
|
52
|
-
[[NSColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:0.
|
|
52
|
+
[[NSColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:0.6] setFill];
|
|
53
53
|
NSRectFill(dirtyRect);
|
|
54
54
|
|
|
55
55
|
// Border
|
|
56
|
-
[[NSColor colorWithRed:
|
|
56
|
+
[[NSColor colorWithRed:0.0 green:0.4 blue:0.8 alpha:0.9] setStroke];
|
|
57
57
|
NSBezierPath *border = [NSBezierPath bezierPathWithRoundedRect:self.bounds xRadius:8 yRadius:8];
|
|
58
58
|
[border setLineWidth:3.0];
|
|
59
59
|
[border stroke];
|
|
@@ -67,14 +67,14 @@ bool bringWindowToFront(int windowId);
|
|
|
67
67
|
[style setAlignment:NSTextAlignmentCenter];
|
|
68
68
|
|
|
69
69
|
NSDictionary *attributes = @{
|
|
70
|
-
NSFontAttributeName: [NSFont systemFontOfSize:
|
|
70
|
+
NSFontAttributeName: [NSFont systemFontOfSize:21 weight:NSFontWeightMedium],
|
|
71
71
|
NSForegroundColorAttributeName: [NSColor whiteColor],
|
|
72
72
|
NSParagraphStyleAttributeName: style,
|
|
73
73
|
NSStrokeColorAttributeName: [NSColor blackColor],
|
|
74
74
|
NSStrokeWidthAttributeName: @(-2.0)
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
NSRect textRect = NSMakeRect(10, self.bounds.size.height -
|
|
77
|
+
NSRect textRect = NSMakeRect(10, self.bounds.size.height - 90, self.bounds.size.width - 20, 80);
|
|
78
78
|
[infoText drawInRect:textRect withAttributes:attributes];
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -445,12 +445,26 @@ Napi::Value StartWindowSelection(const Napi::CallbackInfo& info) {
|
|
|
445
445
|
g_overlayView = [[WindowSelectorOverlayView alloc] initWithFrame:initialFrame];
|
|
446
446
|
[g_overlayWindow setContentView:g_overlayView];
|
|
447
447
|
|
|
448
|
-
// Create select button
|
|
449
|
-
g_selectButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0,
|
|
448
|
+
// Create select button with blue theme
|
|
449
|
+
g_selectButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 140, 50)];
|
|
450
450
|
[g_selectButton setTitle:@"Select Window"];
|
|
451
451
|
[g_selectButton setButtonType:NSButtonTypeMomentaryPushIn];
|
|
452
452
|
[g_selectButton setBezelStyle:NSBezelStyleRounded];
|
|
453
|
-
[g_selectButton setFont:[NSFont systemFontOfSize:
|
|
453
|
+
[g_selectButton setFont:[NSFont systemFontOfSize:16 weight:NSFontWeightSemibold]];
|
|
454
|
+
|
|
455
|
+
// Blue themed button styling
|
|
456
|
+
[g_selectButton setWantsLayer:YES];
|
|
457
|
+
[g_selectButton.layer setBackgroundColor:[[NSColor colorWithRed:0.0 green:0.4 blue:0.8 alpha:0.9] CGColor]];
|
|
458
|
+
[g_selectButton.layer setCornerRadius:8.0];
|
|
459
|
+
[g_selectButton.layer setBorderColor:[[NSColor colorWithRed:0.0 green:0.3 blue:0.7 alpha:1.0] CGColor]];
|
|
460
|
+
[g_selectButton.layer setBorderWidth:2.0];
|
|
461
|
+
[g_selectButton setContentTintColor:[NSColor whiteColor]];
|
|
462
|
+
|
|
463
|
+
// Add shadow for better visibility
|
|
464
|
+
[g_selectButton.layer setShadowColor:[[NSColor blackColor] CGColor]];
|
|
465
|
+
[g_selectButton.layer setShadowOffset:NSMakeSize(0, -2)];
|
|
466
|
+
[g_selectButton.layer setShadowRadius:4.0];
|
|
467
|
+
[g_selectButton.layer setShadowOpacity:0.3];
|
|
454
468
|
|
|
455
469
|
// Create delegate for button action and timer
|
|
456
470
|
g_delegate = [[WindowSelectorDelegate alloc] init];
|
package/window-selector.js
CHANGED
|
@@ -240,7 +240,10 @@ class WindowSelector extends EventEmitter {
|
|
|
240
240
|
setBringToFrontEnabled(enabled) {
|
|
241
241
|
try {
|
|
242
242
|
nativeBinding.setBringToFrontEnabled(enabled);
|
|
243
|
-
|
|
243
|
+
// Only log if explicitly setting, not on startup
|
|
244
|
+
if (arguments.length > 0) {
|
|
245
|
+
console.log(`๐ Auto bring-to-front: ${enabled ? 'ENABLED' : 'DISABLED'}`);
|
|
246
|
+
}
|
|
244
247
|
} catch (error) {
|
|
245
248
|
throw new Error(`Failed to set bring to front: ${error.message}`);
|
|
246
249
|
}
|