I am trying to manipulate the windows of macOS. I have found the following URLs:
- Move other windows on Mac OS X using Accessibility API
- Getting Window Number through OSX Accessibility API (Core Graphics)
- set the size and position of all windows on the screen in swift
- How to set an external application always being frontmost on OS X? (Unanswered)
- How to convert a Carbon AXUIElementRef to Cocoa NSWindow (Unanswered)
- Setting the window level over Accessibility (Unanswered)
- How to create an AXUIElementRef from an NSView or NSWindow? (Unanswered)
The links allow for accessing the various windows of an application via the Accessibility API of macOS; more specifically, they use the AXUIElementRef
element to re-position windows.
When creating an app for macOS, I have successfully used the following code ...
@implementation CustomWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
{
self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
if(self)
{
[self setLevel:kCGDesktopWindowLevel - 1];
[self setCollectionBehavior:
(NSWindowCollectionBehaviorCanJoinAllSpaces |
NSWindowCollectionBehaviorStationary |
NSWindowCollectionBehaviorIgnoresCycle)];
}
return self;
}
// ...
@end
... to put a window on the Desktop level of the screen. What I am looking for is a way to manipulate the same Window level property or the like via a custom Windows Manager application. In other words, I would like to code a windows manager that can manipulate the levels the windows of other applications on screen.
Am, I correct in my findings that this can't be done? Can it be done via Core Graphics?
In addition, I want to change the application that is key and in focus, but I think this can be done.