Windows: lock screen not working using keyboard shortcut --- not possible --- workaround

Asked by Liam

workaround:

using 'run('rundll32.exe user32.dll,LockWorkStation')' does the job.

BE AWARE: your script will not have any access to screen, mouse and keyboard anymore.
Unlock has to be done manually or with other means

-------------------------------------------------------------------------------------------------------------------------------

I'm trying to lock the screen after my script has run (win 10) using the following code

type('l', Key.WIN)

but this is just typing the 'l' character and not locking the screen

I've got a workaround using 'run('rundll32.exe user32.dll,LockWorkStation')' but I'm just wondering why this keyboard shortcut isn't working?

other actions using the "Windows" key seem to work fine

thanks

L

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

This is surely a restriction in/with Java AWT Robot, which is used by SikuliX to access screen content, mouse an keyboard.

If a running Java program (like IDE running a script) could do that, it would not have any access afterwards anymore.
You would have to unlock manually, to get SikuliX working again.

... but thanks for your solution: I will add it to the docs as a note for those who know what they are doing.