检测mac上的全屏 [英] detecting fullscreen on mac

查看:170
本文介绍了检测mac上的全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Mac编写一个IM客户端(在python,但Objective C / Cocoa解决方案在这里很好)。我想要检测用户是否正在观看电影或在前台播放游戏,或者执行占用整个屏幕的其他操作。如果是,我将不会在新的IM进来时播放声音,但如果没有,我将播放声音。

I am writing an IM client for Mac (in python, but an Objective C / Cocoa solution here is fine). I want to detect whether or not the user is currently watching a movie or playing a game in the foreground, or doing anything else that takes up the entire screen. If so, I won't play a sound when a new IM comes in, but if not, I will play the sound.

如何检测这个?有什么方法获得前景窗口与applescript,看看它的尺寸?还是有其他API调用?

How can I detect this? Is there some way to get the foreground window with applescript and look at its dimensions? Or is there some other API call?

谢谢。

推荐答案

要检查全屏,请调用 CGDisplayIsCaptured(screenID)在每个屏幕上。

To check for full-screen, call CGDisplayIsCaptured(screenID) on each screen.

但我不知道如果你检查正确的事情。有一件事,我可以有一个屏幕捕获(全屏)和第二个屏幕未捕获,你想在这种情况下做什么?

But I'm not sure if you're checking the right thing. For one thing, I could have one screen captured ("full screen") and a second screen uncaptured, what do you want to do in this case?

全屏真的意味着什么吗?如果我使用GarageBand来处理一首歌曲,我可能不想听到随机的声音,不管是否是全屏的。或者我可以运行Windows VM全屏,但仍希望通知IM。

Also, does fullscreen really mean anything? If I'm using GarageBand to work on a song, I probably don't want to hear random sounds, regardless of whether or not anything's full screen. Or I could be running a Windows VM full-screen, but still want to be notified of IMs.

这篇关于检测mac上的全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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