[HowTo] Windows: Notepad++: run an opened SikuliX script using F5

Asked by Shengx

************************ how to

This only works with the latest 1.1.4:

--- make a command script (e.g. runsikulix.cmd) somewhere containing

java -jar <path-to>\sikulix.jar -r %*

--- in notepad++ with a .py file open press F5 and enter as program to run

<path-to>\runsikulix.cmd "$(FULL_CURRENT_PATH)"

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

I was able to setup and run Python + Jython on Notepad++ but how do i setup the sikuliX api and run it on notepad++??

Thanks in advance.

Question information

Language:
English Edit question
Status:
Expired
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

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

This only works with the latest 1.1.4:

--- make a command script (e.g. runsikulix.cmd) somewhere containing

java -jar <path-to>\sikulix.jar -r %*

--- in notepad++ with a .py file open press F5 and enter as program to run

<path-to>\runsikulix.cmd "$(FULL_CURRENT_PATH)"

Revision history for this message
Shengx (shengxyz) said :
#2

Hi,

What i am trying to do is to use Notepad++ to write my sikuli program in Python. But when i ran the code, it could not detect the Sikuli API, how to make notepad++ work with the Sikuli API so that i can write all of my Python code in Notepad++??

Revision history for this message
Shengx (shengxyz) said :
#3

So my question is about using the Sikuli API inside Notepad++ and to write all of the SikuliX code in Python...

Revision history for this message
Shengx (shengxyz) said :
#4

I was able to write my code in Java in Netbeans because adding Sikulixapi.jar was easy for Java + Netbeans IDE.

However Oracle has decided to change their licensing policy for Oracle JDK. Now i am switching to Open Jdk with Notepad++ but adding a new Java jar or library to Notepad++ seems more difficult than i thought..

I hope i can find some video tutorials online or if you could show me any videos that would be very helpful.

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

I personally use IntelliJ IDEA CE with Java OpenJDK 12 and I do not see any licensing problems, as long as you check the license of Java libraries before using them and then act according to what is needed.

Some years ago I used Netbeans, but later switched to IntelliJ, because they have a better Python support with PyCharms CE and also inside IDEA.

I am sure, that Java will stay a first class candidate for developing OpenSource for still a long time.

So since you used Java/NetBeans before, switching to IDEA would be the easiest step.

If you want to switch to Python as scripting language, then the SikuliX IDE surely is something to at least use it for small trials to medium complex things and of course for the image capturing and management. Disadvantage: no auto-complete, no debugging.

As IDE for more complex things with all modern dev features I would recommend PyCharms.

Revision history for this message
Shengx (shengxyz) said :
#6

what if i want to stay with notepad++, can i still use the sikulix api to write my code in notepad++??and how can i do that??

Revision history for this message
Shengx (shengxyz) said :
#7

Sorry but can i use sikulixapi in notepad++??

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

--- can i use sikulixapi in notepad++
yes, but only at runtime.

When writing your code, you have to use the API features by writing down the appropriate function calls, whose signatures you have to know or in parallel look up in the docs or the source code.

Conclusion: I am sorry, but I cannot see any advantage in using NotePad++.

Revision history for this message
Shengx (shengxyz) said :
#9

Notepad++ is light and fast and can be used to run java, python, php and c++. The only problem i have now is to use notepad++ to run api and libraries from java such as the sikuli api

Revision history for this message
Shengx (shengxyz) said :
#10

Would you have any code examples of sikulix in python using notepad++ or non-netbeans IDE??

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

--- The only problem i have now is to use notepad++ to run api and libraries from java such as the sikuli api
You have to setup appropriate command files, that you can the use via the run feature and/or the plugin nppexec.
The interpreter to use is Jython (you stated before, that you know how to run it).

For examples see the docs and the net (google is your friend)

start here: http://sikulix.com

Revision history for this message
Shengx (shengxyz) said :
#12

You mean the jython interpteter already includes the sikuli api??

I hava already installed jython and python is already worrunning correctly but its not detecting any sikuli related scripts so when i run sikuli code i got errors

Revision history for this message
Shengx (shengxyz) said :
#13

The command line and nppexec already setup and running correctly for python and c++ but not for sikuli scripts written in python

Revision history for this message
Shengx (shengxyz) said :
#14

For example when i use print("hello") the code was printing cotrectly but when i used wait(2) or type( "hello") it was not typing any characters

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

- sikulixapi.jar must be on the Java classpath at runtime
I recommend to use a Java 8 JRE and at best you should make your first steps with SikuliX 1.1.3 (1.1.4 is currently under heavy developement and might make problems).

- the main script needs as first line
import org.sikuli.script.SikulixForJython

- and each script using SikuliX features needs
from sikuli import *

Revision history for this message
Shengx (shengxyz) said :
#16

"sikulixapi.jar must be on the Java classpath at runtime"

Sorry what does this mean exactly?

Does it mean adding the sikulixapi.jar file path to the environment variable on Windows, or are there more steps to implement??

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

You may either set this globally in the Windows environment or locally in a command script or with the -cp parameter when running java.exe.

Jython as well has a parameter to prefill the Java classpath.

Revision history for this message
Shengx (shengxyz) said :
#18

I have done that but still the scripts are not working. So the following statements must be placed on the top of a file?

import org.sikuli.script.SikulixForJython
from sikuli import *

The above two statements must be placed in a file, is this correct? But notepad++ couldn't find the files or modules...

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

All my infos make sure, that the stuff is found at runtime.

About the state when editing something in NOtePad++: Sorry, but it is your decision to use NotePad++.

I gave you all needed information.
To find your way with NotePad++ is your job now.

As mentioned: for serious development with Python I do not understand your decision.

Revision history for this message
Shengx (shengxyz) said :
#20

OK so the following statements are the correct syntax to add to python file?

import org.sikuli.script.SikulixForJython
from sikuli import *

sorry just wanted to confirm one last time, thank you.

Revision history for this message
Launchpad Janitor (janitor) said :
#21

This question was expired because it remained in the 'Open' state without activity for the last 15 days.