Custom image path for 1 function

Asked by xyz_User

Is it possible for me to set a custom image path for just one function in the script?

Meaning when it's calling that function it searches for images in that function at a different location then the default sikuli folder?

eg:

def find_img_custom_location():
image1 = "C:\temp\test_image.png"
    if exists(image1):
        click(image1)

Please advise how if possible, thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:

This question was reopened

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

def find_img_custom_location():
    image1 = r"C:\temp\test_image.png" # ... or double backslash
    if exists(image1):
        click() # clicks last match

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

- check wether the image is available in the directory
- absolute path
- double-back-slash or r"..." with single backslash

post what you have in your script

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

The docs would have helped:
Pattern(Image).similar(...)

Revision history for this message
Best Manfred Hampl (m-hampl) said :
#11

Has to be
    if exists(Pattern(image1).similar(0.85)):
instead of
    if Pattern(image1).similar(0.85):

Revision history for this message
xyz_User (userseven) said :
#12

Thanks Manfred Hampl, that solved my question.