Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X - How to monitor a window change event?

I'm developing a Cocoa application that shows a list of opened windows and highlights the current focused one. My problem is that I can't find a system notification to inform my app that the main (aka "focused" or "foreground") window has changed. I tried with:

    [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(wsNotificationHook:) name:NSWorkspaceDidActivateApplicationNotification object:nil];

but it monitors APPLICATION change: it isn't get fired when a change of window is executed INSIDE the same application (for example, if I pass between two Firefox windows using exposè). Is there a system-wide event that I can monitor to track a change of the main window?

Thank you in advance!

like image 609
flip79 Avatar asked Aug 27 '11 22:08

flip79


People also ask

How to bring back a window that is off screen Mac?

Force a Relaunch Forcing an app or program to relaunch on a Mac could bring the window back into view so you can access it again. Click the Apple icon located in the top left corner. Select Force Quit. Choose the off-screen application from the list and click Relaunch.

How to move a window when you can t see the title bar Mac?

Hi. On the application menu bar go to Window/Zoom, and then resize and position the window as you like. In order to make it open the same way next time you use the application, hold the Option key while closing the window. Good Luck.

How do I gather all windows to one screen on a Mac?

Show all open windows grouped by app: In Mission Control preferences, select “Group windows by application,” then enter Mission Control. Move open windows aside to show the desktop: Press Command-Mission Control , or spread your thumb and three fingers apart on the trackpad.

Can t get to the top of a window on Mac?

Fix 2 – Resolution Select the Apple Menu, then choose “System Preferences…” > “Displays“. Ensure “Scaled” is selected under “Resolution“. Choose any other setting. This should force the window for the application back on the screen where you can drag it to a safe place.


1 Answers

The closest you'll get will probably be the accessibility APIs. See here and here for similar questions with (partial) solutions.

like image 128
omz Avatar answered Oct 14 '22 08:10

omz