Lock screen by API in macOS

后端 未结 8 1885
梦如初夏
梦如初夏 2020-12-12 16:49

Is there an API, that can lock the screen as the menu bar entry you can add from Keychain preferences?

This Keychain function is (was) lock

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 17:31

    I don't see anything documented as such, but the menu uses the ScreenSaver framework, which defines this:

    @interface ScreenSaverDefaults : NSUserDefaults 
    {
    @private
        NSMutableDictionary     *_defaults;
        NSMutableDictionary     *_registeredDefaults;
        NSString                *_userName;
        NSString                *_domainName;
        BOOL                    _dirty;
        BOOL                    _screenLockPrefChanged;
    }
    
    + (id) defaultsForModuleWithName:(NSString *)inModuleName;
    
    @end
    

提交回复
热议问题