从任意进程窃取 NSWindow (或 contentView)
我想从另一个进程窃取一个 NSWindow
。最好是这样,但是 NSView
,即我从 [window contentView]
获得的那个,也可以(特别是因为我认为我可以升级 。
显然,这可能没有文档记录,并且令人难以置信地没有得到 Apple(或 Mac App Store)的批准 可能可以通过Apple提供的辅助功能API来实现,但是我还没有找到一种方法来做到这一点,
我已经查看了CGWindow.h
,但它似乎没有提供我需要的东西。 我
谢谢(这是我的第一篇文章)。
被建议提供一个非恶意的原因:简单!而且,呃,对于任何人想做的事情,真的,因为这是可能的。当然,我的一位亲密朋友,一位出色的 iOS 黑客(MobileNotifier 的开发者,如果您还没有听说过,请在 Google 上搜索它)建议注入捆绑包,我说这可以设置一个分布式对象服务器,这样效果会很好。所以我们可能会尝试这种方法。
I'd like to steal an NSWindow
from another process. Preferably that, but an NSView
, that is, the one that I would get from [window contentView]
, would be fine as well (especially since I suppose that I can escalate to NSWindow
with [view window]
.
Obviously, this is likely undocumented and incredibly not approved by Apple (or the Mac App Store). From my research, it seems that this might be doable via the accessibility API that Apple provides, however I have yet to find a method to do this.
I've looked at CGWindow.h
, but it doesn't seem to provide what I need.
Thanks (this is my first SO post).
I was advised to provide a non-nefarious reason: simple! It's for debugging purposes! And, err, for anything that anyone wants to do, really, because that will be possible, of course. One of my close friends, who is a great iOS hacker (the developer of MobileNotifier, search it on Google if you haven't heard of it) has suggested injecting bundles, which I said could then set up a distributed objects server, which would then work great. So we'll probably attempt that approach.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法“窃取”窗口,但可以使用 SIMBL 或 mach_inject/override 之类的东西将您想要的任何行为添加到任意进程的窗口中。
You can't "steal" a window, but you can use something like SIMBL or mach_inject/override to add whatever behaviour you want to windows of arbitrary processes.
你不能偷窗户。自己做吧!如果你这样做了,这将是一个系统黑客/错误,苹果会发现它。偷窗户有什么好处?
You can't steal windows. Make your own! If you did, it would be a system hack/bug and Apple will find out about it. What good will stealing windows do?
尽管我不相信OP他写了一些“非恶意”的东西,因为大多数开发人员工具使用仪器API或更高级别的API来获取所需的信息,而不需要向正在运行的进程注入任何内容 - 仍然有一些基本的解释是由于,为了其他读者的利益。
“窗口”不是一回事。有多个实体与操作系统的不同部分相关,它们共同构成了“窗口”事物,每个实体都存在于不同的上下文、进程甚至硬件级别中。
你不能“窃取”一个 NSWindow 对象,因为它是一个简单的 Objective-C 对象,除了创建它的进程之外,在任何进程中都没有任何意义。
正确地说@alexy13,“创建你自己的!”,但我会扩展。 NSWindow(或 Carbon Window 对象)都通过窗口 ID(以及其他几个属性)引用 Windows 服务器窗口。原则上,您可以在不同进程中使用多个 NSWindows“包装”同一个 Windows-Server 窗口。
如果我对OP的理解正确的话,他想拍一张“被盗”窗户的照片,这是一项合法的任务,可以在不偷任何东西的情况下完成。您只需要找到该窗口的 Windows-Server ID 并调用 Window-Server API 即可获取该窗口的图片。
除此之外 - 如果你想控制“被盗”的窗口,你可以通过创建窗口的原始价格中的原始 NSWindow 来完成,通过向应用程序发送一个高级事件(最容易使用 AppleScript 完成)来移动,调整大小、关闭或您需要的任何其他控制或查询调用。
Despite I don't believe the OP that he writes something "non-malicious", as most developer tools use instrumentation APIs or higher level APIs to get needed information, without the need to inject anything to the running process - still some basic explanation is due, to the benefit of other readers.
A "Window" isn't one thing. There are several entities related to different parts of the OS that together make up the "Window" thing, each lives in different context, process, and even hardware level.
You can't "steal" an NSWindow object, because it is a simple Objective-C object, that has no meaning in any process except that one that created it.
Correctly said @alexy13, "Create your own!", but I'll extend. The NSWindow (or a Carbon Window object) both refer to a Windows-Server window, via the window ID (and several other attributes). You could, in principle, "wrap" the same Windows-Server window with several NSWindows in different processes.
If I understand the OP right, he would like to take a picture of that "stolen" window, and that is a legitimate task, that one can achieve without stealing anything. You just need to discover the Windows-Server ID of that window and call Window-Server API to get a picture of that window.
Beyond that - if you want to CONTROL the "stolen" window, you can do it via the original NSWindow in the original pricess that created the window, by sending the application a high-level event (easiest to do with AppleScript) to move, resize, close, or any other control or inquiry call you need.