objective c - Mac OS X -- receive notification when frontmost window changes -
i wondering whether there way in mac os x receive notification when frontmost window switches different window -- either objective-c solution, or python, or applescript, or else. want @ whole system, not within application. app trying keep track of file user working on, , have polling solution gets frontmost app , frontmost window every running applescript, simplify life if run check when knew frontmost window had changed.
i've looked @ nsdistributednotificationcenter , global event monitors nsevents, both useful in different ways, don't seem able give me specific front-window-change notification i'm ideally looking for.
any ideas on directions should try, or whether possible, appreciated!
i don't know of way notification when window changes, in objective-c can notification when things happen @ application level. might you.
you want register nsworkspace notifications...
[[[nsworkspace sharedworkspace] notificationcenter] addobserver:self selector:@selector(nsworkspacenotification:) name:nil object:nil];
look @ bottom of nsworkspace class documentation notifications. are: nsworkspacedidlaunchapplicationnotification, nsworkspacedidactivateapplicationnotification, nsworkspacediddeactivateapplicationnotification, nsworkspacedidhideapplicationnotification, nsworkspacedidunhideapplicationnotification. there may others.
good luck.
Comments
Post a Comment