Created
March 29, 2016 03:40
-
-
Save typcn/58e23804101b0ba1470d to your computer and use it in GitHub Desktop.
Unlock & Lock your mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern void SACLockScreenImmediate ( ); | |
SACLockScreenImmediate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
io_registry_entry_t r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler"); | |
if (r) { | |
IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanFalse); | |
IOObjectRelease(r); | |
} | |
NSString *pw = [SSKeychain passwordForService:@"login" account:@"login"]; | |
NSString *s = @"tell application \"System Events\"\n\ | |
tell application \"ScreenSaverEngine\" to quit\n\ | |
delay 0.5\n\ | |
keystroke \"%@\"\n\ | |
keystroke return\n\ | |
end tell"; | |
NSDictionary *err; | |
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:s,pw]]; | |
[script executeAndReturnError:&err]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment