How to make options and link different sikuli scripts together.

Asked by Mike

Hi, i've been looking everywhere but can not find the information i am looking for or how to do it?

I wish to make the macros, but also add like a window box with options. So when i want to start a macro i can deicide wish one i want to do. i.e

A game i play is the same but with different lvls and different fleets. I would like to make options like Mission select 1-30, fleets 1-15 and then option on how many times to repeat.

I've done the macro and works great, but would like to know how i could use those macros and add them into a windows options that opens before you run the script. So you select what you want, then once done you could click on start and it'll select the right macro to do as you selected.

Could someone please point me in the right direction on how to do this with sikuli. Also is it possible to turn it into a .exe so its completed and can be installed onto another computer or do you have to have sikuli installed to run the macro.

Question information

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

--1. .exe and run on other computer (supposing we are talking about windows)

On the client PC you need:
- sikuli-script.jar
- the contents of the libs directory
- path to the libs directory in system path
- path-to-java/jre6/bin in system path
- path to sikuli-script.jar in Java class path

This is possible to pack in an .exe, that contains an installer (look for available software in the net).

If you are an experienced Java programmer, you might pack everything in one jar and write an installer with Java.

To run a Sikuli script in such an environment:
java -jar path-to-some-dir/sikuli-script.jar path-to-some-dir/your-script.sikuli

--2. interactively select options for a script run

currently the only feature, that is available in Sikuli, is the input() function.
Should be enough if it is for you.

If you want a more comfortable frontend, you either have to switch to Java programming or use some Software, that allows to design and handle option dialogs and finally run your Sikuli script from command line (options as parameters or read from a file).

If you have different scripts (or macros as you say), that should be run depending on the selected options, just make a main script that gets the options and dispatches the macro to run (which itself are packed in on or more .sikuli, that can be imported or run using execfile())

example with input()

text = \
"headline\n" \
"=========\n" \
"subtext\n" \
"subtext\n" \
"subtext\n" \
"subtext\n" \
"subtext\n" \
"subtext\n" \
"subtext\n" \
"==================\n" \
"please enter a number"

num = None
while not num:
    answer = input(text)
    try:
        num = int(answer)
    except:
        print "Error: not a number", answer
    if not (num > 0 and num < 16):
        print "Error: number not in range", answer
        num = None
print "Selected:", num

Can you help with this problem?

Provide an answer of your own, or ask Mike for more information if necessary.

To post a message you must log in.