You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ windowManager, Window }=require("node-window-manager");const{
hasScreenCapturePermission,
hasPromptedForPermission
}=require('mac-screen-capture-permissions');constfs=require('fs');constpath=require("path");// Request recording permissions (required for getTitle() on macOS)if(!(hasScreenCapturePermission())){console.log('no permission')// TODO open sys. preferences// See this: https://github.com/karaggeorge/mac-screen-capture-permissions}// This method has to be called on macOS before changing the window's bounds, otherwise it will throw an error.// It will prompt an accessibility permission request dialog, if needed.windowManager.requestAccessibility();constwindow=windowManager.getActiveWindow();// Prints the currently focused window bounds.// console.log(window.getBounds());// Sets the active window's bounds.// window.setBounds({ x: 0, y: 0 });letlastAppName=null;windowManager.getWindows().forEach(window=>{if(window.isWindow()&&window.getTitle()){leticon=window.getIcon(64);letappName=path.basename(window.path);if(icon&&lastAppName!=appName){fs.writeFile('icons/'+appName.split('/')[0]+'.png',icon,'binary',(err)=>{if(err)throwerr});console.log(appName);lastAppName=appName;// Focus the requested windowif(appName=='Finder.app'){window.bringToTop();}}console.log(' |- '+window.getTitle())}// console.log(window)})
To focus a specific program
The text was updated successfully, but these errors were encountered: