tell application "System Events" to tell the front menu bar of process "SystemUIServer"
set foundMenu to false
set menu_extras to value of attribute "AXDescription" of menu bar items
repeat with x from 1 to the length of menu_extras
if item x of menu_extras is equal to missing value then
tell menu bar item x
click
tell first menu item of front menu
if name is equal to "Lock Screen" then
set foundMenu to true
exit repeat
end if
end tell
end tell
end if
end repeat
if foundMenu is equal to false then
keystroke return
end if
end tell