操作 Mac 应用程序中的窗口
我有以下代码片段:
NSNumber* windowNumber = [entry objectForKey:(id)kCGWindowNumber];
applicationName = [entry objectForKey:(id)kCGWindowOwnerName];
通过此代码,我从所有正在运行的应用程序的窗口服务器中获取窗口编号和名称。
我最终想要做的是创建对任何 Window 的引用并操作其属性,例如,如果我有 Safari 某个实例的窗口号,我想将其设置回来或最大化或隐藏它。有可能这样做吗?关于如何开始的一些想法?
顺便说一句,我发现这种在 Apple 代码示例中检索“窗口号”和“应用程序名称”的方法称为“Son of Grab”: http://developer.apple.com/library/mac/#samplecode/SonOfGrab/Introduction/Intro.html 如果有人好奇。
I have the following code snippet:
NSNumber* windowNumber = [entry objectForKey:(id)kCGWindowNumber];
applicationName = [entry objectForKey:(id)kCGWindowOwnerName];
with this I grab the window number and the name from the window server of all Applications running.
What I want to do finally is to create a reference to whatever Window and manipulate its properties, for example if I have the window number of some instance of Safari, I would like to set it back or maximize it or maybe hide it. It is possible to do this ? some idea about how to start?
BTW I found this way of retrieve the "window number" and "application name" in an Apple Code sample Called Son of grab: http://developer.apple.com/library/mac/#samplecode/SonOfGrab/Introduction/Intro.html
if someone are curious.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我基于苹果示例 Son of scrap 并使用 QUARTZ EVENT TAPS 完成了这一任务。这是过滤事件和操作其他应用程序的正确方法,因为它充当第 508 节支持技术。
Finally I accomplished this based on the apple sample Son of grab and by using the QUARTZ EVENT TAPS. This is a right way to filter events and manipulate other applications because it serves as a section 508 enabling technology.