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
- Download and use Sysinternals Autologon
You should redirect the Console in order to have UI anytime
- Create New Task in Task Scheduler
- Next in General tab check "Run with highest privileges"
- Next in Triggers tab add New trigger
- Next in New Trigger dialog select "On disconnect from user session" from "Begin the task" dropdown the press OK with default settings or with the users you will login usually
- Create a switch-ui.bat file with the following content in a folder switch-ui on Desktop
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
)
- Next in Actions tab Action
- Next in New Action dialog select "Start a program" from Action dropdown
- In Settings Program/script add the full path to your file "C:\Users\%yourUsers%\Desktop\switch-ui\switch-ui.bat"
- In Start in (optional) add path to your folder with your script "C:\Users\%yourUsers%\Desktop\switch-ui"
- Press OK and finish the Task
Important: In order to test that it works.
- Get a video recorder
- Login on the machine from Remote Desktop Connection (RDC)
- Start video
- Close RDC
- Wait 2 mins
- Connect Again
- Stop Video
- Watch the video
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.