Custom image path for 1 function

Asked by xyz_User on 2020-08-21

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:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
2020-08-30
Last query:
2020-08-30
Last reply:
2020-08-29

This question was reopened

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

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

RaiMan (raimund-hocke) said : #7

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

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):

xyz_User (userseven) said : #12

Thanks Manfred Hampl, that solved my question.