0

A Win10 system locks the screen after a certain time of inactivity.

I know:

  • you could change the Win10 settings or
  • install special software which claims to avoid stand-by or lock screen

However, I cannot/don't want to change settings nor install other software. Well, I could attach a mechanical device to the mouse and move it every once in a while. Hmm, seems to be too complicated.

I thought I could move the mouse by a little 7-liner Python program.

Code:

import mouse, time

for i in range(10000):
    print(i)
    mouse.move("20","20")
    time.sleep(60)
    mouse.move("150","150")
    time.sleep(60)

This moves the mouse every minute between two positions. However, if I run this Python code in a Windows console, the screen nevertheless gets locked after a while.

Maybe somebody can explain:

a) whether avoiding lock screen is possible at all by such a method or if Windows is preventing this?

b) if it could be done via a few Python lines, what would be the conditions and the code to get this to work?

theozh
  • 22,244
  • 5
  • 28
  • 72
  • https://superuser.com/a/1101640/1231330 I do not know about operating systems but you may have to read on what happens when computer sleeps. – Vishesh Mangla May 16 '21 at 19:25
  • sorry for the duplicate. Sometimes, pretty similar Q&A do not appear in the SO-search, even when you type and review your question. Anyways: this is the solution which seems to work for me: https://stackoverflow.com/a/65401303/7295599 – theozh Sep 16 '21 at 06:13

0 Answers0