miniben-90 / x-win

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.
MIT License
32 stars 6 forks source link

[Feature] Subscribe function #11

Closed miniben-90 closed 10 months ago

miniben-90 commented 10 months ago

Feature subscribe to any change of active window

Thread will be started and check every 100ms if window value has changed and call a function with information of current window.

Example

import { subscribeActiveWindow, unsubscribeActiveWindow, unsubscribeAllActiveWindow } from '@miniben90/x-win';

const a = subscribeActiveWindow(activeWindow => {
  console.log('test a', activeWindow);
});

const b = subscribeActiveWindow(activeWindow => {
  console.log('test b', activeWindow);
});

const c = subscribeActiveWindow(activeWindow => {
  console.log('test c', activeWindow);
});

setTimeout(() => unsubscribeActiveWindow(c), 5000);

setTimeout(() => unsubscribeAllActiveWindow(), 10000);

Work in progress...