To keep screen active (without locking) in Windows while running Selenium scripts

南楼画角 提交于 2021-01-24 11:19:11

问题


I am running my Selenium scrips in Windows machine, but during execution after some time the screen gets locked.

I have even set Never for Power & Sleep under Settings. But still my laptop screen gets locked during execution.

I want to run all my scripts for hours together without getting my laptop screen locked or in sleep mode.

How can I achieve this?


回答1:


A simple vb script will help you resolve this. Create a .vbs file and paste the below code

set wsc = CreateObject("WScript.Shell")
Do
    'one minute
    WScript.Sleep(60*1000)
    wsc.SendKeys("{NUMLOCK}")
Loop

The vbs script clicks Num Lock for every one minute and keeps the session active. Trigger that and the system will not get locked

Make sure that your Automation run will not get effected by pressing Num Lock



来源:https://stackoverflow.com/questions/52253368/to-keep-screen-active-without-locking-in-windows-while-running-selenium-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!