One more noob with a newbie question : launch scripts

Asked by efra

Hi everybody,
I'm working on a program ( ControllerMate - on Mac ) that allows to configure devices to trigger keyboard and mouse actions ( to drive video editing programs in my case ). It can launch applescript too.

Then i found Sikuli ( i began with Sikuli_ide but i don't know if i need to work on sikuliX now )
and I created a script that can find an icon and click on it ! That's all for me for the moment ;)

Now i'd like to create an applescript to run that sikuli script ( and trigger it via Controllermate )
And i'd like to run it fast enough and in background.

I searched over here and elsewhere but i am really not a programmer and failed !

If someone could help me, it would be great.
Thanks in advance

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

as a first step, you should definitely switch to version 1.1.0
http://sikulix.com

you should select options 1 and 2 to get all possibilities.

this AppleScript should do what you want: run a SikuliX script
set toberun to " -r " & "<path-to-your>script.sikuli"
set cmdPath to "<path-to-sikulix-folder>/runsikulix"
set cmd to POSIX file cmdPath
try
 alias cmd
on error
 display alert "SikuliX runsikulix not found here: " & cmdpath
end try
set cmdText to cmdPath & toberun
do shell script cmdText & " &"

On the long run, you might be the ideal candidate to use JavaScript as scripting language:
the interpreter comes with Java and the startup time for a script run is less than 1 second compared to 3 - 5 seconds for Jython/Python (that you are currently using).
The next time there will be a JavaScript script run server for Sikuli scripts, that will run scripts without any delay.
Please tell me. if you are interested. In this case I will support you in the first place, since you are testing new stuff ;-)

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

Thanks Rainman for the quick answer,

so with your help i managed to run the applescript.

And i went to sikulix but i have that kind of error now ( script still work on sikuli-ide ) even if i create a new script :
[error] FindFailed ( can not find 1427208613366.png in R[1920,120 1920x1080]@S(0) )

is there a problem with having the 2 programs ?

By the way, for sure i would be very interested for a no delay system
( i'm really a noob but why can't i launch a javascript via applescript to reduce time )
PS : what do you mean by next time there will be server...?

thanks again for your time

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

Your comment looks like you did not switch to version 1.0.1. right?
You should do so.
If you switch to version 1.1.0: purge everything, that belongs to the previous used Sikuli.

You have at least 2 monitors.
Please tell your setup.

What OSX?
What Java?

JavaScript scripts can surely be run from command line and hence from inside your AppleScript.
Come back if you really want to do that.

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

of course I meant:
Your comment looks like you did not switch to version 1.1.0 right?

Revision history for this message
efra (efra) said :
#5

Sorry if i wasn't clear, but yes i was using the 1.1
So i cleaned everything and reinstalled it.
And i put just one monitor.

So it worked ! i can trigger the applescript via Controllermate and he can find the icon and click
But it takes 8 secondes to be done ! arf !

My os is 10.9.4 and java is 7.75

Do you think it can get faster ?
When do you think you'll release the next version with java server to avoid delay ?

Anyway, thanks for your time and for that program which seems very handful

PS : i don't know how to tell my setup about the 2/3 screens

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

--- more than 1 monitor
you need to do nothing, is detected by SikuliX automatically.

But if an image is not on the Screen(0) (the one having the coordinates 0,0 top left) you have to tell it.

use(Screen(1))
click(image)

would search on the monitor assigned the id 1.

Your monitor configuration as it is seen by SikuliX:
JScreen.showMonitors()

--- elapsed time
if you start a script written in Python, it takes about 5 seconds (a bit more on your machine) to come to the point to run your script statements.
A search on the whole screen takes up to 1 second (this can be made faster down to milliseconds by telling Sikuli to look in a smaller region).
I am sorry, but the next few weeks the mentioned script run server will not be ready for use from AppleScript.

If you tell me more about your needs: maybe I have a solution for you.

Revision history for this message
efra (efra) said :
#7

> Thanks for the screen informations. In fact Sikuli was taking my native screen ( laptop ) as screen 1

> the system works nice and i can find many things to do with sikuli but the delay would be a major issue :
 ( I make it search in portion of screen but still. )

> I work with "controllermate". It drives a dedicated keyboard to trigger shortcuts and mouse position and clicks so i can simulate a video editing panel.
And, for the moment, i just want sikuli to find some icons.. and to hover or click on it ( see below ). Then i put it in an applescript that controllermate can triggers but i have to wait 8 seconds to see the result

I hope i was clear enough about my needs !
thanks again

PS I don't know anything about java ( no more than python ;) ) but i can work on it if this is a solution and for sure i can wait weeks and weeks for the run server, it seems very attractive

r=find("1427217418781.png").below(500)
t=r.find(Pattern("1427217451902.png").similar(0.48))
hover(t)

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

ok, understood.

the RunServer solution is nearly ready for experiments (the above snippet would be run instantly).

I will tell you how to use it the next days.

Revision history for this message
efra (efra) said :
#9

Thanks a lot, this seems very exiting and would be perfect !
have a good day

Revision history for this message
efra (efra) said :
#10

Thanks RaiMan, that solved my question.