Skip to content

Commit 2ee7283

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 62f574c + e3039d3 commit 2ee7283

File tree

1 file changed

+85
-1
lines changed

1 file changed

+85
-1
lines changed

README.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,86 @@
11
# sikulix4python
2-
Use SikuliX from real Python via py4j
2+
Use SikuliX from real [Python via py4j](https://www.py4j.org) (but no need to know, how it works ;-)
3+
4+
**under development -- no guarentee for anything :-)**
5+
6+
... but you might post issues (questions, bugs, ideas, requests, ...)
7+
8+
**What you need**
9+
- the latest 1.1.4 sikulixapi.jar (https://raiman.github.io/SikuliX1/downloads.html)
10+
- a Python installation 2.7 up to 3.7 (3.7 recommended)
11+
- a mature Python IDE (I use IntelliJ's PyCharm) or just a Python REPL.
12+
13+
**How to test**
14+
15+
Currently it is recommended, to fork this project and work in the project context.
16+
17+
But this should also be possible:
18+
- copy the folder ``sikulix4python`` from inside the project to a place, where your Python will find it, when imported
19+
20+
In both cases:
21+
- put ``from sikulix4phyton import *`` at the beginning of your test script
22+
- use stuff from ``sxundotted`` just as is
23+
- use stuff from ``sxclasses`` to access features of the SikuliX API classes like Region, Screen, Location ...
24+
25+
Currently you have to look into the Python files, to find out, what is possible.
26+
27+
**How is the SikuliX Java API accessed from Python**
28+
29+
Before running Python scripts this way, you have to start a SikuliX server instance manually:
30+
31+
``java -jar path-to/sikulixapi.jar pythonserver``
32+
33+
When you see this in the terminal window, it is running:
34+
35+
```
36+
März 15, 2019 10:26:20 VORM. py4Java.GatewayServer fireServerStarted
37+
INFO: Gateway Server Started
38+
```
39+
40+
**What is the plan**
41+
- have the complete official SikuliX API with docs available at time of script development (autocomplete, docs, help, ...)
42+
- be able to additionally access every public method from the SikuliX Java API (you must know the method signature)
43+
- have a handy solution for handling image path's of imported scripts/modules
44+
- run existing SikuliX scripts without changes (... but there will surely be exceptions)
45+
46+
**Things you should be aware off**
47+
- you might get any problem at any time, since the current state is ``proof of concept``
48+
- anything might be changed at any time without notice
49+
- errors and warnings you get in the terminal window can be ignored, as long as it works as intended on the Python side
50+
- output coming from the SikuliX Java API is currently only going to the terminal window
51+
- my current development work is on macOS 10.14, Java 11, Python 3.7 with PyCharm
52+
- no tests on Windows nor Linux yet
53+
54+
**An example**
55+
56+
```
57+
# https://www.python.org should be opened in Safari
58+
59+
# build the bridge to SikuliX
60+
from sikulix4python import *
61+
62+
# make images available in the folder of the script
63+
addImagePath()
64+
65+
switchApp("Safari")
66+
67+
hover() # undotted uses SCREEN object (sxundotted)
68+
69+
scr = Screen()
70+
71+
# getCenter() is found auto-magically,
72+
# though not defined in the Python class Screen
73+
# see sxclasses::__getattr__
74+
# one gets method missing, if signatures do not fit
75+
scr.getCenter().grow(100).highlight(2)
76+
77+
img = "img.png" # located via ImagePath
78+
79+
# a Match object is completely handled at the Java level
80+
# not defined at the Python level
81+
match = scr.exists(img, 3) # method missing, wrong signature
82+
match = scr.exists(img, 3.0) # number must be float/double
83+
if match:
84+
match.highlight(2)
85+
match.click()
86+
```

0 commit comments

Comments
 (0)