keyboard shortcut to lock screen doesn't work if finder menu visible
Without knowing your exact model of Mac and version of macOS, I have a different way for you to achieve the exact same thing without having to create an Automator service and setting a keyboard shortcut.

Follow these steps:


Go to Apple > System Preferences
Click on Security &amp; Privacy
Select the General tab
Tick the checkbox for requiring a password after sleep or screensaver begins (if you can't tick it, unlock the Padlock at bottom left of the window). Note: You may need to enter a password to make the change.
Now from the associated drop-down, select Immediately
Exit System Preferences


Now you can lock the screen with one of two built-in macOS keyboard shortcuts (depending on your Mac model):


Control+Shift+Eject
Control+Shift+Power Button


The above macOS shortcuts will put your display to sleep, and because of the change in your Security &amp; Privacy preferences, this will activate the password prompt upon waking it up.

Touch Bar models

If you have a 2016 MacBook Pro with Touch Bar, the above keyboard shortcuts aren't available. Instead, you can:


Go to Apple > System Preferences
Click on Keyboard
Click on the Customize Control Strip button
From here you'll see options for either a Lock Screen button or a Display Sleep button
Select one of these
Exit System Preferences


You can now lock your screen by pressing a button on the Touch Bar.