

Tell (menu bar item 1 of menu bar 1 where description is "Keychain menu extra")Ĭan be used in a Automator 'Run Applescript' Action in a Automator Service Workflow. This applescript code: (updated, sourced from Using AppleScript to lock screen, confirmed working in El Capitan) tell application "System Events" to tell process "SystemUIServer" Using key codes to navigate menus can be hit and miss.Īnd as much as I do not like GUI scripting because it can also be hit and miss imho it is less hit and miss in this case. Old answer for previous OS below Arondson answer goes into using some key codes to navigate the Keychain Lock Screen menu.Īll the key codes can be bypassed using GUI Scripting to Actually hit the menu items directly. This has the default keyboard short cut of crtl + cmd + Q The Lock Screen for keychain no longer is available in current version of the MacOS Mojave & High Sierra.Īpple have now add a Lock Screen Menu item in the Apple menu. Id instance = init] Ĭlang -framework Foundation main.m -o lockscreenĮxecute the program by typing. NSBundle *bundle = Ĭlass principalClass = # Do our work in the temporary directory that gets cleaned on boot You can create a small binary for locking your screen by pasting this into your terminal. This solution works perfectly as long as Apple doesn't change the relevant parts in the keychain menu plugin. Today I just had some time to play around and found a way to programmatically actually call the functionality from the keychain menu plugin. I was also looking for a solution for this. The password will be required for the login, preventing any unauthorized user from accessing your data.Note: This solution is unique in that it uses the Keychain Access menu bar status functionality, but it does not require you to enable the Show keychain status in menu bar option as the AppleScript methods do. To lock a Mac simply press the following key combination.Īs soon as you press these three buttons together, your Mac will get locked and you will see the lock screen on your computer.

All you have to do is perform a quick keyboard shortcut, after which your computer will be locked instantly. The ability to quickly lock a Mac with keyboard shortcut is available on both desktop Macs and MacBooks. While you can lock your Mac by clicking on the Apple logo from the menu bar and then clicking on the ‘Lock Screen’ option, there’s another and more convenient way. For example, if you have a Mac at your office desk and have to move away from it, you can instantly lock your computer and prevent anyone from accessing your computer and invading your privacy. Locking a Mac and instantly requiring password for login can be very useful in a variety of situations. On macOS High Sierra or later Apple has made it super simple and quick to lock your Mac.
