toDoc! [HowTo] Running Sikuli on Remote Desktop Connection

Asked by Maxo K.

I have recently installed Sikuli and find it very interesting.

I have written a script, which does several operations throughout the browser. The problem occurs when running the script on my windows 2003 remote server using Remote Desktop. Whenever I run it and I am connected to the Remote Desktop, it is working fine without any problems, but whenever I disconnect from Remote Desktop, it stops. After I relogin back via Remote Desktop I receive an error that "image" not found. I have tried many things, but could not really find why this happens. I have done lots of testing and whenever I am on the remote desktop connection watching, it works very well without any problems.

Maybe someone has similar experience.

Question information

English Edit question
SikuliX Edit question
RaiMan Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :

If the remote system is running without a monitor ("headless"), you do not have an active screen and Sikuli is not able to screencapture anything.
The remote desktop connection enables a screen, so it runs.

Look at a Sikuli screenshot taken on a headless machine: it will be black.

The problem is known. There are some ideas about using some VNC stuff, but I do not know the actual plans.


Revision history for this message
Maxo K. (malkhaz) said :

Thanks a lot RaiMan. I will be looking into this. Hopefully we can find some solution one day.

Revision history for this message
Maxo K. (malkhaz) said :

Thanks RaiMan, that solved my question.

Revision history for this message
Maxo K. (malkhaz) said :

Just a short update. I have tried using VNC Server (RealVNC) on the remote server and sikuli worked perfectly.

Just several issues to consider:

1) Make sure that you edit: VNC Server (Service) Configuration and go to Desktop Tab and make sure that "When last client disconnects" - "Do Nothing" is checked.
2) Disable the auto log off in Terminal Services
3) Disable any screensaver

Revision history for this message
Jason Antic (jsa169) said :

For those curious, there's another way to get a "head" on your machine if you happen to run on vms like I do at work (we have 4 of them for automation)- move the vm image to a machine with a monitor on it. I'm not sure if this will work with all virtualization software, but I can tell you that I've tested it with Vmware Workstation 7 and it works great. You can minimize the vms, lock your host machine (just keep the vms from going to screen saver, etc)- Sikuli still works under these conditions. I've tested this on Linux and Windows vms.

I've found this to be the most cost effective, robust and simple solution for my purposes, which is to run automation on these vms for hours overnight.

Revision history for this message
Min-cheng HUANG (mhuang-a) said :

Hi all,

Currently, I am facing the same problem...

I am using Java to start an Amazon EC2 instance (WIN2008 server). So, when the EC2 instance starts, it will run the scripts to run the testing and close the instance after finishing the task.

However, this will be successful only when I use remote desktop connection to log on that machine. Otherwise, the sikuli will fail. (Raiman pointed out this issue pretty precisely.)

Just wondering any other good solution to solve this solution, or I need to use VNC to connect every instance I start...

Any idea is appreciated~ Thanks.

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


what about the above mentioned VNC solution?

(sorry, if this is a silly question - but I have no experience with Amazon EC2)

Revision history for this message
Min-cheng HUANG (mhuang-a) said :


No worry, I will contact with Maxo. :)

Revision history for this message
Min-cheng HUANG (mhuang-a) said :

Few Update:

It's kind of weird. First, I tried to use VNC into the remote machine and Sikuli works fine on the remote machine.

But, suddenly, I found it also works even I didn't vnc into the remote machine. So, I got confused right now about the question whether Sikuli can work in a headless environment.

However, it is still great that I don't need to vnc into machines anymore.
Keep updating...

Revision history for this message
sameer bahadur (sbahadur0) said :

In ubuntu 12.04 and similar platforms you may use
"gnome-screensaver-command -d" just prior to starting the silkuli scripts, deactivating screensaver.
If your test continues for a long time : in another shell - periodically using "gnome-screensaver-command -q" to query and then to deactivate screensaver. But this may still leave holes when the screensaver auto-activation happens and your query is not yet timed.
A hack could to Activate and Deactivate immediately to reset the screensaver timer periodically while testing. "g... -a ; g... -d" (not tested by me yet)

Revision history for this message
sameer bahadur (sbahadur0) said :

another scritable command to reset screensaver timer in ubuntu from

dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.SimulateUserActivity

Revision history for this message
Pallavi (plaxmeshwar) said :

I am trying to run sikuli on windows RDP machine , sikuli scripts fails sometimes , it fails to click images.
If i run the same script on my desktop , it works completely fine.Please let me know if there is any solution for this.

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

no idea.
You have to do some debugging on your own (are the images found? is clicking allowed? some timing problem? …)

Revision history for this message
Pallavi (plaxmeshwar) said :

Yes images are found , but it fails to click sometimes, say out of 5 times , 3 times it fails to click the image, hence scripts failing in rdp.
I have added enough sleep in the script.

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

no idea.

You have to do some more tests and debugging.

Revision history for this message
Adam (enalmada) said :

For those looking to automate on ec2 windows machines, this worked for me:

In summary, I used RDC to connect, put this in a batch file, double clicked it, and sikulix started working remotely (kicking me out of RDC). Note that ec2 windows machines default to 1024x768 when tscon takes over which may be too small so TightVnc can be used to increase the resolution to 1280x1024 before running.

tscon.exe 0 /dest:console
tscon.exe 1 /dest:console
tscon.exe 2 /dest:console
tscon.exe 3 /dest:console
START /DC:\Sikulix /WAIT /B C:\Sikulix\runsikulix.cmd -d 3 -r C:\test.sikuli -f C:\Sikulix\log.txt -d C:\Sikulix\userlog.txt

Revision history for this message
sunny sachdeva (sunalps2000) said :

HI Adam,

I am using sikulix as a maven dependency . Do you think the above solution would work in this case as well.