How to lock a Mac lock screen without using keystrokes in the script?

Solution 1:

I’d like to go to the lock screen on my computer without using the keyboard. Any command line script will do.

I’m not sure what you mean by “Without using the keyboard” if you are willing to accept a script… which would have to be triggered using the keyboard.

If there is something specific / unusual / unique about your setup, it would be good to explain what that is.

In the meantime, if you are willing to accept a shell script, try this:

"/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession" -suspend

All one line