@miniben90/x-win 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/README.md +31 -1
- package/index.d.ts +3 -0
- package/index.js +4 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -94,6 +94,36 @@ console.log(windows);
|
|
|
94
94
|
}]
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
+
### Subscribe to get the current active window
|
|
98
|
+
|
|
99
|
+
Thread will be start to check every `100ms` for a new active window (checking window title, window id and process id).
|
|
100
|
+
|
|
101
|
+
* `subscribeActiveWindow`: Create a subscription with a callback function
|
|
102
|
+
* `unsubscribeActiveWindow`: Remove a specific subscription
|
|
103
|
+
* `unsubscribeAllActiveWindow`: Remove all threads
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } from '@miniben90/x-win';
|
|
108
|
+
|
|
109
|
+
const a = subscribeActiveWindow(activeWindow => {
|
|
110
|
+
console.log('test a', activeWindow);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const b = subscribeActiveWindow(activeWindow => {
|
|
114
|
+
console.log('test b', activeWindow);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
const c = subscribeActiveWindow(activeWindow => {
|
|
119
|
+
console.log('test c', activeWindow);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
setTimeout(() => unsubscribeActiveWindow(c), 5000);
|
|
123
|
+
|
|
124
|
+
setTimeout(() => unsubscribeAllActiveWindow(), 10000);
|
|
125
|
+
```
|
|
126
|
+
|
|
97
127
|
# Linux
|
|
98
128
|
|
|
99
129
|
Dependencies are required to be installed for development purposes.
|
|
@@ -103,7 +133,7 @@ sudo apt install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0
|
|
|
103
133
|
```
|
|
104
134
|
|
|
105
135
|
> ⚠️**Warning**
|
|
106
|
-
> Recovery url is not available
|
|
136
|
+
> Recovery url is not available on linux
|
|
107
137
|
|
|
108
138
|
# Darwin
|
|
109
139
|
|
package/index.d.ts
CHANGED
|
@@ -41,3 +41,6 @@ export interface WindowInfo {
|
|
|
41
41
|
}
|
|
42
42
|
export function activeWindow(): WindowInfo
|
|
43
43
|
export function openWindows(): Array<WindowInfo>
|
|
44
|
+
export function subscribeActiveWindow(callback: (info: WindowInfo) => void): number
|
|
45
|
+
export function unsubscribeActiveWindow(threadId: number): void
|
|
46
|
+
export function unsubscribeAllActiveWindow(): void
|
package/index.js
CHANGED
|
@@ -281,7 +281,10 @@ if (!nativeBinding) {
|
|
|
281
281
|
throw new Error(`Failed to load native binding`)
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
const { activeWindow, openWindows } = nativeBinding
|
|
284
|
+
const { activeWindow, openWindows, subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } = nativeBinding
|
|
285
285
|
|
|
286
286
|
module.exports.activeWindow = activeWindow
|
|
287
287
|
module.exports.openWindows = openWindows
|
|
288
|
+
module.exports.subscribeActiveWindow = subscribeActiveWindow
|
|
289
|
+
module.exports.unsubscribeActiveWindow = unsubscribeActiveWindow
|
|
290
|
+
module.exports.unsubscribeAllActiveWindow = unsubscribeAllActiveWindow
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miniben90/x-win",
|
|
3
3
|
"description": "This package allows you to retrieve precise information about active and open windows on Windows, MacOS, and Linux. You can obtain the position, size, title, and other memory of windows.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
},
|
|
62
62
|
"packageManager": "yarn@4.0.2",
|
|
63
63
|
"optionalDependencies": {
|
|
64
|
-
"@miniben90/x-win-win32-x64-msvc": "1.
|
|
65
|
-
"@miniben90/x-win-darwin-x64": "1.
|
|
66
|
-
"@miniben90/x-win-linux-x64-gnu": "1.
|
|
67
|
-
"@miniben90/x-win-darwin-arm64": "1.
|
|
68
|
-
"@miniben90/x-win-win32-arm64-msvc": "1.
|
|
69
|
-
"@miniben90/x-win-win32-ia32-msvc": "1.
|
|
70
|
-
"@miniben90/x-win-darwin-universal": "1.
|
|
64
|
+
"@miniben90/x-win-win32-x64-msvc": "1.5.0",
|
|
65
|
+
"@miniben90/x-win-darwin-x64": "1.5.0",
|
|
66
|
+
"@miniben90/x-win-linux-x64-gnu": "1.5.0",
|
|
67
|
+
"@miniben90/x-win-darwin-arm64": "1.5.0",
|
|
68
|
+
"@miniben90/x-win-win32-arm64-msvc": "1.5.0",
|
|
69
|
+
"@miniben90/x-win-win32-ia32-msvc": "1.5.0",
|
|
70
|
+
"@miniben90/x-win-darwin-universal": "1.5.0"
|
|
71
71
|
}
|
|
72
72
|
}
|