Help a new guy out?

Asked by Ben

Ok, so I am new to the Sikuli API, but not to programming. I have searched endlessly through the FAQ's and the Complete guide to Sikuli... but I cannot seem to figure out why I am getting an error on line 1... Full error code below, along with my script underneath that... I just really want to know how this all works, as the tutorials seem to just say how to do various things... My code is simple, open command line (windows 7), find ip address... But it is erroring at "line 1" The dev box is so confusing, because there are Java errors pertaining to classes, and Python errors... HELP?

[sikuli] Stopped
[sikuli] An error occurs at line 1
[sikuli] Error message:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files (x86)\Sikuli\sikuli-script.jar\Lib\sikuli\Sikuli.py", line 18, in <module>
java.lang.NoClassDefFoundError: Could not initialize class edu.mit.csail.uid.Finder

 at java.lang.Class.forName0(Native Method)

 at java.lang.Class.forName(Unknown Source)

 at org.python.core.SyspathJavaLoader.loadClass(SyspathJavaLoader.java:107)

 at java.lang.ClassLoader.loadClass(Unknown Source)

 at org.python.core.Py.findClassEx(Py.java:817)

 at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133)

 at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:28)

 at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122)

 at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)

 at org.python.core.PyObject.__findattr__(PyObject.java:869)

 at org.python.core.imp.import_name(imp.java:771)

 at org.python.core.imp.importName(imp.java:806)

 at org.python.core.ImportFunction.__call__(__builtin__.java:1232)

 at org.python.core.PyObject.__call__(PyObject.java:367)

 at org.python.core.__builtin__.__import__(__builtin__.java:1202)

 at org.python.core.imp.importFromAs(imp.java:884)

 at org.python.core.imp.importFrom(imp.java:860)

 at sikuli.Sikuli$py.f$0(C:\Program Files (x86)\Sikuli\sikuli-script.jar\Lib\sikuli\Sikuli.py:166)

 at sikuli.Sikuli$py.call_function(C:\Program Files (x86)\Sikuli\sikuli-script.jar\Lib\sikuli\Sikuli.py)

 at org.python.core.PyTableCode.call(PyTableCode.java:165)

 at org.python.core.PyCode.call(PyCode.java:18)

 at org.python.core.imp.createFromCode(imp.java:326)

 at org.python.core.util.importer.importer_load_module(importer.java:109)

 at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)

 at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)

 at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)

 at org.python.core.imp.loadFromLoader(imp.java:451)

 at org.python.core.imp.find_module(imp.java:408)

 at org.python.core.PyModule.impAttr(PyModule.java:109)

 at org.python.core.imp.import_next(imp.java:637)

 at org.python.core.imp.import_logic(imp.java:699)

 at org.python.core.imp.import_name(imp.java:761)

 at org.python.core.imp.importName(imp.java:806)

 at org.python.core.ImportFunction.__call__(__builtin__.java:1232)

 at org.python.core.PyObject.__call__(PyObject.java:367)

 at org.python.core.__builtin__.__import__(__builtin__.java:1202)

 at org.python.core.__builtin__.__import__(__builtin__.java:1185)

 at org.python.core.imp.importAll(imp.java:904)

 at org.python.pycode._pyx20.f$0(<string>:1)

 at org.python.pycode._pyx20.call_function(<string>)

 at org.python.core.PyTableCode.call(PyTableCode.java:165)

 at org.python.core.PyCode.call(PyCode.java:18)

 at org.python.core.Py.runCode(Py.java:1204)

 at org.python.core.Py.exec(Py.java:1248)

 at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:172)

 at edu.mit.csail.uid.ScriptRunner.runPython(ScriptRunner.java:52)

 at edu.mit.csail.uid.SikuliIDE$ButtonRun.runPython(SikuliIDE.java:1190)

 at edu.mit.csail.uid.SikuliIDE$ButtonRun$1.run(SikuliIDE.java:1288)

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: Could not initialize class edu.mit.csail.uid.Finder

SCRIPT:

find(windows start button pic )
click(windows start button pic )
wait(search box pic , 20)
type("cmd")
wait(command line pic , 30)
type("ipconfig /all \n")

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
RaiMan (raimund-hocke) said :
#1

Are you using the .bat to start the Sikuli IDE?

This may be helpful:
https://bugs.launchpad.net/sikuli/+bug/586699

Revision history for this message
Ben (bdluke) said :
#2

I ran the .bat in the C:/Program Files\Sikuli folder, and it didnt seem to do anything. i have been running the ide from the .EXE in the same directory... is that wrong then?

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

Are you running a 64bit Win7?

try this .cmd. it is from the above mentioned bug and will be contained in the next release.

the .exe should not be used.

####\/\/\/\/\/#### COPY BETWEEN ####\/\/\/\/\/####

@echo off
PATH=%PATH%;%~d0%~p0tmplib
set JAVA_EXE="javaw"
if defined PROGRAMFILES(X86) set JAVA_EXE="%PROGRAMFILES(X86)%\Java\jre6\bin\javaw.exe"
start /B "Silkuli-IDE Loader...." %JAVA_EXE% -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dpython.path="%~d0%~p0sikuli-script.jar/" -jar "%~d0%~p0sikuli-ide.jar" %*

####/\/\/\/\/\#### COPY BETWEEN ####/\/\/\/\/\####

Revision history for this message
Ben (bdluke) said :
#4

Yes, I am using 64 bit Win 7...
The .cmd file worked, thank you! One last thing before I "solve" this issue...

How do I make keystrokes? Say, I need it to hit enter?

and

How do I screen-Capture Dynamically changing things, effectively? For example, I hit Start button, Then- wait(start menu item). However, when I go to screen capture, the start menu closes... Any way I can screen capture dynamic elements better?

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

General suggestion: You should read the documentation - at least the 1st chapter and the headlines.

Keystrokes: use type() (or keyDown()/keyUp() for very special cases)

Capture: Try the capture hotkey (look at the option pane). This should do what you want.

Have fun. Come back if you need more help.

Revision history for this message
Ben (bdluke) said :
#6

I truly enjoy the "Ctrl_Shift+2" quick capture shortcut!!! Thanks!

pending Keystrokes though, How would you make your program hit "enter" not type the word enter... For example,

Find (input box)
type("words") <----------- does words need to be in quote marks?
hit enter <-------------------- this step
type("more words")

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

Again: You would really do me a favor looking at the "Complete Guide to Sikuli Script" http://sikuli.org/trac/wiki/reference-0.10. I put many effort in this especially for people like you: not new to programming, but new to Sikuli. Its really helpful.

type(): http://sikuli.org/trac/wiki/reference-0.10#type

In your case:
type(string) # string is a string - so has to be in quotes, if its not a variable
type(Key.ENTER) # hits enter

You have to be careful: type() writes to the visual object, that has the focus!

So this will normally not work, since find() does not click.
Find (input box)
type("words") # may do nothing - only beeps

so either:
m = find(input box) # if you need the match object later on
type(m, "words") # performs a click before typing

or shorter:
type(input box, "words") # finds, clicks and types

or extra long:
m = find(input box) # if you need the match object later on
click(m) # performs a click before typing
type("words")

In all cases, be sure, that the clickpoint is inside the text field (use preview window to check and or correct).

multiline input box:
type(input box, "words" + Key.ENTER + "more words" + Key.ENTER + "last words")
click(image of OK Button)

Revision history for this message
Ben (bdluke) said :
#8

Key.ENTER.

Thank you very much!