I had written some automation code for our site in which used sikuli
for image automation. But sometimes I found that my computer screen locked in between, and that's why many of the test cases failed. So I want to write some python code to keep the screen unlocked.
Here is the code patch which I wrote for locking the screen and now I am searching for how to unlock the screen:
import os
winpath = os.environ["windir"]
os.system(winpath + r'\system32\rundll32 user32.dll, LockWorkStation')
Note: I have already adjusted all the monitor settings which cause screen locking.
To work properly Sikuli need UI. This means the user should be logged in. Below are the steps on how to achieve that:
Use Autologon
You should redirect the Console in order to have UI anytime
echo ################################################### >> %USERPROFILE%\Desktop\rdc_switch_log.log
date /t >> %USERPROFILE%\Desktop\rdc_switch_log.log time /t >> %USERPROFILE%\Desktop\rdc_switch_log.log
timeout 3
query session >> %USERPROFILE%\Desktop\rdc_switch_log.log
query session > %localappdata%\log.txt
findstr "rdp" %localappdata%\log.txt| findstr "Active"
if %errorlevel%==0 (
echo You are in RDP session. Do nothing! >>%localappdata%\log.txt
)
else (
tscon 1 /dest:console
tscon 2 /dest:console
tscon 3 /dest:console
tscon 4 /dest:console
)
Important: In order to test that it works.
You should have a black video recorded only when you Close RDC and when you connect back with RDC for a few seconds it depends on how fast is your machine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.