Skip to content

Instantly share code, notes, and snippets.

@lyokato
Created November 22, 2016 02:49
Show Gist options
  • Save lyokato/2b46f514e35a3fa195695aa425fe3da7 to your computer and use it in GitHub Desktop.
Save lyokato/2b46f514e35a3fa195695aa425fe3da7 to your computer and use it in GitHub Desktop.
LockScreen AppleScript
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
my lockscrn()
on lockscrn()
set bundle to current application's NSBundle's bundleWithPath:"/Applications/Utilities/Keychain Access.app/Contents/Resources/Keychain.menu/"
bundle's load
set aClass to bundle's classNamed:"AppleKeychainExtra"
set aObj to aClass's alloc
set aKeyChain to aObj's init
aKeyChain's performSelector:"_lockScreenMenuHit:" withObject:(null) afterDelay:0.0
delay 0.1
end lockscrn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment