可可:隐藏其他应用程序和自身 [英] Cocoa: Hide other applications and self

查看:100
本文介绍了可可:隐藏其他应用程序和自身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种使应用程序与所有其他应用程序一起隐藏的方法.我目前将其隐藏其他应用程序,但我的应用程序保持打开状态.通过选择单击我的按钮并将其拖到实用程序中的应用程序"区域,可以完成此操作.然后我选择了"hideOtherApplications".

I need a way to have an application hide itself along with all other applications. I currently have it hiding other applications, but my application stays open. I accomplished this by option-clicking my button and dragging it to the "Application" area in Utilities. Then I selected "hideOtherApplications".

推荐答案

好的,因此,如果您只想显示在桌面上,则可以做自己想做的事情,然后手动订购您自己的窗户要消失.但是,如果您想与桌面进行交互,那将是行不通的.桌面是Finder的一部分,因此,如果您正在桌面上工作,则Finder将是最前端的应用程序,因此在那时无法隐藏.如果可以的话,您可以隐藏除Finder之外的所有应用程序.

OK, so, if you just want to show the desktop, you can just do what you're doing and then manually order your own windows to go away. But if you want to interact with the desktop, that won't work. The desktop is part of Finder, so if you're doing things on the desktop, Finder will be the frontmost application and thus can't be hidden at that time. If you're OK with this, you can hide all applications but Finder.

但是实际上有一个系统工具可以做到这一点.清除所有窗口,以便您可以看到桌面,这是Mission Control的功能-在Mission Control首选项中列为显示桌面".在我的系统上,它是F11.不幸的是,没有用于调用任务控制功能的公共API.不过,如果在您的小巷里,有一个私人的吧:

But there actually is a system facility for this. Clearing all the windows so you can see the desktop is a function of Mission Control — it's listed as "Show Desktop" in the Mission Control preferences. On my system, it's F11. Unfortunately, there isn't a public API for invoking Mission Control's functions. There is a private one, though, if that's up your alley:

void CoreDockSendNotification(CFStringRef, void*);

void toggleShowDesktop() {
    CoreDockSendNotification(CFSTR("com.apple.showdesktop.awake"), NULL);
}

(在所有通常的警告下,Apple不支持私有API,如果他们抓住您使用它们,并且不保证它们会正确运行,则可能会将您赶出App Store.优胜美地问世时可以正常工作,因为那只是私有API的一种方式.)

(With all the usual caveats that Apple do not support private APIs, will probably kick you out of the App Store if they catch you using them and don't guarantee they'll behave correctly, and this may or may not even work when Yosemite comes out because that's just kind of how private APIs are.)

这篇关于可可:隐藏其他应用程序和自身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆