Cocoa:隐藏一个应用程序 [英] Cocoa: Hide one application

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

问题描述

是否可以使用可可隐藏一个特定的应用程序?



我知道你可以使用下面的代码隐藏所有其他应用程序

  [[NSWorkspace sharedWorkspace] performSelectorOnMainThread:@selector(hideOtherApplications)withObject:NULL waitUntilDone:NO]; 

但是是否可以隐藏一个特定的应用程序,比如说Safari?

$ b

  

告诉应用程序系统事件可将进程Safari设置为false

或调用相同的applescript从可可内调用:

  NSString * source = @告诉应用程序\系统事件\ process \Safari\to false; 
NSAppleScript * script = [[NSAppleScript alloc] initWithSource:source];
[script executeAndReturnError:nil];
[script release];


Is it possible to hide one specific application using cocoa?

I know you can hide all other applications using the following code

[[NSWorkspace sharedWorkspace] performSelectorOnMainThread:@selector(hideOtherApplications) withObject:NULL waitUntilDone:NO];

But is it possible to hide just one specific application say Safari for example?

解决方案

you can do it with applescript:

tell application "System Events" to set visible of process "Safari" to false

or call the same applescript from within cocoa by calling:

NSString * source = @"tell application \"System Events\" to set visible of process \"Safari\" to false";
NSAppleScript * script = [[NSAppleScript alloc] initWithSource:source];
[script executeAndReturnError:nil];
[script release];

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

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