Windows: can't control keyboard or mouse when running from task scheduler (but scheduled task runs)

Asked by Henry Ludemann

***** to make it clear

A scheduled task containing a Sikuli script to run, will work. Only testing it with the TaskScheduler-MMC-Console-Window open will not work as expected (mouse/keyboard actions blocked).

-------------------------------------------------------------------------------------------------------------

When running Sikuli X-1.0rc2 from the Windows Vista task scheduler, any 'click' or 'type' calls don't work. eg:

  type('r', KEY_WIN)

will open Window's 'run' dialog when run directly from sikuli or from the command line, but not when run from the task scheduler. It appears that sikuli cannot control the keyboard or mouse when run from the task scheduler.

I've confirmed Sikuli is actually running by;
* Calling 'popup' will correctly display the popup
* Enabling 'setShowActions' will show the flashing target in the correct location (when using 'click'), but the mouse pointer won't move to the target.

Steps to reproduce:
1. Create a script containing
      popup("I'm running, no joke")
      type('r', KEY_WIN)
2. Add a batch file to run the program. eg:
     "C:\Program Files\Sikuli X\Sikuli-IDE-w.bat" -r "C:\Users\IcyTea\Documents\test.sikuli"
3. Run the batch file to confirm it works
4. Add it to the task scheduler
  - press the windows key
  - type 'task scheduler
  - click the 'action' menu
  - name 'test sikuli'
  - keep clicking next until you can set 'start a program'. Set the path to the batch file.
  - Keep clicking next until the task is create.
  - Click on the 'task scheduler library'
  - Right click on the new 'test sikuli' task, and click on 'run'.

It will (correctly) display the popup, but will (incorrectly) not open the 'run' dialog box.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

This is a known problem: the mmc console windows block the Java Robot actions (click, type, ...)
see bug 794489

In your case the run from the task scheduler window runs the sikuli script in this context, so you have the mentioned problem.

If you are sure your script works fine, just put it in the task scheduler and it will work as requested (e.g. at login).

tested on Win7.

BTW:
use "C:\Program Files\Sikuli X\Sikuli-IDE-w.bat" as the program to run and
-r "C:\Users\IcyTea\Documents\test.sikuli" as parameter

and you do not need an extra batch file.

Revision history for this message
Henry Ludemann (misc-hl) said :
#2

Thanks, ensuring the scheduled task window was closed fixed running the job as a scheduled task. Thanks very much for your help!

Revision history for this message
Henry Ludemann (misc-hl) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
Shariq Tariq (shariqatariq) said :
#4

So does the window need to be open for the scheduled sikuli job to run? also what command do you use to kill the task scheduler?