【发布时间】:2018-07-07 12:50:14
【问题描述】:
我正在尝试操作 macOS 的窗口。我找到了以下网址:
- Move other windows on Mac OS X using Accessibility API
- Getting Window Number through OSX Accessibility API(核心图形)
- 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?(未答复)
- How to convert a Carbon AXUIElementRef to Cocoa NSWindow(未答复)
- Setting the window level over Accessibility(未答复)
- How to create an AXUIElementRef from an NSView or NSWindow?(未答复)
这些链接允许通过 macOS 的 Accessibility API 访问应用程序的各个窗口;更具体地说,他们使用AXUIElementRef 元素重新定位窗口。
在为macOS创建应用程序时,我已经成功使用了以下代码...
@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
... 在屏幕的桌面级别放置一个窗口。我正在寻找的是一种通过自定义 Windows 管理器应用程序操作相同窗口级别属性等的方法。换句话说,我想编写一个窗口管理器,它可以操纵屏幕上其他应用程序的窗口级别。
我在我的发现中纠正了这不可能吗?可以通过 Core Graphics 完成吗?
另外,我想改变关键和焦点的应用程序,但我认为这是可以做到的。
【问题讨论】:
-
你有没有得到任何地方?
-
@m.gansrigler 我不得不解决这个问题,所以没有。 =(
-
@PLG 关于这个话题有什么消息吗?
-
@LeadDeveloper 我还没有听说过 Apple 在这方面更改 API,但我也没有积极搜索。
-
这方面有什么进展吗?我很想知道你的解决方法。我也想控制其他应用程序窗口的窗口级别,但似乎找不到相关的API。
标签: objective-c macos cocoa core-graphics accessibility