Run Sikuli-IDE from command line on Mac in background

Asked by cdepner

Hi,

I'm having trouble running Sikuli from the command line on Mac... well, it runs fine, but it always brings the Sikuli-IDE.app to the foreground when I run the .skl script, and so the focus in the target app is lost. This proves extremely problematic for typing, as the focus is on the Sikuli-IDE faceless app during script runtime unless I add a switchApp() command to every individual command I'm running.

A little background on that... we're using a C#-based framework for our automation, and using Sikuli to augment it in cases where we don't have a programmatic solution. When I get to one of these cases, I basically just issue a direct Sikuli command via a parameters file I import via the Sikuli.skl script. Then, I use the 'exec' command to execute the command using Sikuli. This works great for finding images, since the IDE-app is faceless, but clicking and typing is problematic because of the aforementioned focus issues.

Is there a way I can run the .skl files without having the Sikuli-IDE.app come to the foreground?

Thanks in advance,
Chris D.

Question information

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

The developers told me, that with the current version, there is no solution for that: switchApp() has to be used to give the focus to the app that you want the script to act on.
If you don't want to use switchApp(), in some cases it is sufficient to click on a neutral area or to click using target-offset, to prepare a type().

Another idea:
Maybe the approach (I did not test it yet) https://answers.launchpad.net/sikuli/+faq/1110 gives you an idea, how to build a python based backgrond process, that could be triggered somehow to process your workflows (currently your .skl's).

Revision history for this message
cdepner (cdepner) said :
#2

Thanks for the response. It would be great if sometime in the future the command-line version of the Sikuli-IDE could run as a background process, or at least not in the foreground (look at 'open -g' to see how to launch an application in the backgound - unfortunately, given the syntax for running skl files, this doesn't work currently)

For now, I'll just have to keep using custom commands prefaced with switchApp() to get the right focus.

Thanks again.

Revision history for this message
Tsung-Hsiang Chang (vgod) said :
#3

Hah, I didn't know "open -g" before you mentioned that.
I just gave a shot and confirmed that you can use "open -g" to execute a .skl in background.
Try the following command in the Terminal.

open -g /Applications/Sikuli-IDE.app --args ABSOLUTE-PATH-TO-A-SKL

Revision history for this message
cdepner (cdepner) said :
#4

Excellent! I couldn't figure out the right syntax to give the args... this will work out beautifully. I humbly request that you guys update the docs on Sikuli command line usage with this so others can benefit!

Thanks again!

- CD

Revision history for this message
Tsung-Hsiang Chang (vgod) said :
#5

Sure. I will update the docs later.
Thanks for bringing up this issue.