OS X / cocoa - 如何在锁定屏幕会话上获取事件

时间:2015-08-25 00:03:33

标签: macos cocoa sandbox

#import "AppDelegate.h"

@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *jj;

@end

@implementation AppDelegate

@synthesize jj;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskSwipe | NSEventMaskBeginGesture |  NSEventMaskGesture | NSEventMaskEndGesture handler:^(NSEvent *event) {

        NSLog(@"local");

        return event;
    }];

    [NSEvent addGlobalMonitorForEventsMatchingMask:NSEventMaskSwipe | NSEventMaskBeginGesture |     NSEventMaskGesture | NSEventMaskEndGesture handler:^(NSEvent *event) {

        NSLog(@"global");
    }];

    NSDistributedNotificationCenter* center;
    center = [NSDistributedNotificationCenter defaultCenter];

    [center addObserver:self selector:@selector(a) name:@"com.apple.screenIsLocked" object:nil];

    NSWindow* a = [[NSApplication sharedApplication] windows].firstObject;

    [a makeKeyAndOrderFront:nil];
    [a setLevel:kCGMaximumWindowLevel];
}

- (void)a {
    NSLog(@"sibar");

    [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];

    [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskSwipe | NSEventMaskBeginGesture |  NSEventMaskGesture | NSEventMaskEndGesture handler:^(NSEvent *event) {

        NSLog(@"local");

        return event;
    }];
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
    // Insert code here to tear down your application
}

@end

我想在锁定屏幕上获得触摸事件

我想开发自定义锁屏

所以我尝试在锁定屏幕上显示屏幕并获取事件

show screen is slove by     [window makeKeyAndOrderFront:nil];

但未收到活动

这是因为窗口和应用程序无法获得焦点

请帮帮我

//我将在App Store上传应用程序,因此我需要非沙箱违规解决方案

0 个答案:

没有答案