禁用任务控制,空间,仪表板和任何其他外部过程 [英] Disabling Mission Control, Spaces, Dashboard and any other external process

查看:62
本文介绍了禁用任务控制,空间,仪表板和任何其他外部过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能(在短时间内)禁用并重新启用应用程序中的任务控制,空间,曝光,仪表板等应用程序的外部进程,同时仍然允许用户使用我的应用程序?

I was wondering if it was possible to (for a short period of time) disable and re-enable external processes to an application like Mission Control, Spaces, Expose, Dashboard, etc... within an application, while still allowing the user to use my application?

我发现实现此目标的一种方法是使用 NSTask 来禁用带有相应终端命令的进程.例如:

A way of accomplishing this I found was to use NSTask to disable the processes with the corresponding terminal command. For Example:

- (NSString *)runCommandWithBase:(NSString *)base arguments:(NSArray *)arguments {
//Create the task
NSTask *task = [[NSTask alloc] init];

//Setup the task
[task setLaunchPath:base];
[task setArguments:arguments];
[task setStandardInput:[NSPipe pipe]];
[task setStandardOutput:[NSPipe pipe]];

//Set file handle
NSFileHandle *file = [[NSPipe pipe] fileHandleForReading];

//Run the command
[task launch];

//Return
NSData *returnData = [file readDataToEndOfFile];
return [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];}

和:

NSString *exposeEnable = [self runCommandWithBase:@"/usr/bin/defaults" 
                                            arguments:[NSArray arrayWithObjects:@"write", @"com.apple.dock", @"mcx-expose-disabled", @"-boolean", @"NO", nil]];
    NSLog(@"%@", exposeEnable);

NSString *exposeDisable = [self runCommandWithBase:@"/usr/bin/defaults" 
                                             arguments:[NSArray arrayWithObjects:@"write", @"com.apple.dock", @"mcx-expose-disabled", @"-boolean", @"YES", nil]];
    NSLog(@"%@", exposeDisable);

禁用属性

我尝试了一下,发现它是完全不稳定的,因为任务控制(暴露)不会总是重新启用-即使控制其enabled属性的文件说它已启用(〜/Library/Preferences/com.apple.dock.plist; mcx-expose-disabled的属性).是否有另一种更简单的方法,还是应该修改应用程序的设计,以使其不需要关闭这些内容?我可以继续使用当前方法并对其进行一些修改以便它可以正常工作(例如在默认情况下关闭其他属性)吗?

I tried this and found it to be completely unstable, as mission control (expose) would not always re-enable - even though the file that controls its enabled property says it is enabled (~/Library/Preferences/com.apple.dock.plist; the property of mcx-expose-disabled). Is there another, easier way, or should I modify my application's design so it does not require these things to be shut off? Can I continue using my current method with some modifications to it so it works (like shutting off different properties in defaults)?

预先感谢

推荐答案

检查信息亭模式技术说明"文档和 NSApplicationPresentationDisableProcessSwitching 标志.

Check the "Kiosk Mode Technical Note" documentation and the NSApplicationPresentationDisableProcessSwitching flag.

这篇关于禁用任务控制,空间,仪表板和任何其他外部过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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