not working from command line

Asked by writwik

My Script read the path of a image (e.g.C:\GoogleSearch.png) from the file C:\param.txt and perform exists(). Srtipt working from IDE and successfully finds the image, but not working when running from command line a using .skl file. Any clue?

Script:
try:
    r=open("C:\param.txt",'r')
    m=r.readlines()
    k = ''.join(m)
    popup (str(m))
    r.close()
    s = str(k)
    popup(s)
    if exists(s):
        f = open("C:\out.txt", "w")
        f.write("True")
        f.close()
        popup("if")
    else:
        f = open("C:\out.txt", "w")
        f.write("False")
        f.close()
        popup("else")
except:
     f = open("C:\out.txt", "w")
     f.writelines("Unexpected error:"+ str(sys.exc_info()[0]))
     f.writelines("\nUnexpected error:"+ str(sys.exc_info()[1]))
     f.writelines("\nUnexpected error:"+ str(sys.exc_info()[2]))
     f.close()

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:

This question was reopened

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

--- but not working when running from command line a using .skl file
what are the symptoms? what does not work?
error messages?

Revision history for this message
writwik (writwiksinha) said :
#2

Sikuli can't understand "C:\ImageLib\GoogleSearch.png" as image path and triggering OCR process which results FindFail. I have found a work around as below.

addImagePath("C:\ImageLib")
s = “GoogleSearch.png”
if exists(“s”):
 popup(“Success”)

But for the functions like type(), paste() below code Sikuli can’t identify two different arguments separated by “,”
s = "K.png"+","+"Type”
type(s)
paste(s)

Sikuli identify ‘s’ as singe string and act accordingly. Is there any other way to make sikuli Identify two different arguments?

Revision history for this message
writwik (writwiksinha) said :
#3

Sikuli can't understand "C:\ImageLib\GoogleSearch.png" as image path and triggering OCR process which results FindFail. I have found a work around as below.

addImagePath("C:\ImageLib")
s = “GoogleSearch.png”
if exists(“s”):
 popup(“Success”)

But for the functions like type(), paste() below code Sikuli can’t identify two different arguments separated by “,”
s = "K.png"+","+"Type”
type(s)
paste(s)

Sikuli identify ‘s’ as singe string and act accordingly. Is there any other way to make sikuli Identify two different arguments?

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

If you want to use 2 different arguments (image and text to type/paste) the syntax is:

type( "K.png", "Type")

same with paste()

type(s) just types the given string to where the GUI currently has focus.

Revision history for this message
writwik (writwiksinha) said :
#5

Thanks RaiMan, that solved my question.