← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #705665]: The exists() parameter is set to the image file path and does not work

 

Question #705665 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/705665

    Status: Needs information => Open

Chaoyang Shi gave more information on the question:
My version is 2.0.5.jar
Strangely, just when I ran it again, exists() ran successfully, however, in the afternoon, it bothered me for two hours

The problem is the final if statement。In the afternoon, click() did not run when the if statement was present
-------Below is my code--------

import shutil
import os

#Gets the absolute path to the current file    
user_file = os.path.realpath("sikulix")    

#Gets the path to the parent directory where the current file is located    
user_file = os.path.dirname(os.path.dirname(user_file))

#Read the WORLD_FLIPPER-Auto_Land.sikuli file in the sikulix directory    
user_file = os.path.join(user_file, "sikulix","test1.sikuli")

#The user sets the region to determine the play area
user_img = selectRegion()
x = 95
y = user_img.getY()
if x > user_img.getX():
    x = user_img.getX()
game_Area = user_img.offset(-x, -y)
Screen = game_Area.setW(500).setH(1080)
sleep(3)

def Capture():

    #Screenshot of login reward obtained
    game_Area = Screen

    #Reduce the area
    Login_rewards_L = game_Area.setW(game_Area.getW()/2).setH(game_Area.getH()/9)

    #Change the region
    Login_rewards_L = Login_rewards_L.offset(130, 220)

    #Save the picture to start
    Login_rewards_img = Login_rewards_L
    img_name = "Login_rewards"
    Login_rewards_img_S = Login_rewards_img

    #Create a picture storage path
    Lr_img_L = os.path.join(user_file, img_name+".png")

    #Move the image to the set path and change the name to img_name
    Login_rewards_img = capture(Login_rewards_img)
    shutil.move(Login_rewards_img, Lr_img_L)
    
    #Screenshot of the announcement "Close" button
    #Move down vertically from the "Login" screenshot
    Shut_down = Login_rewards_L.offset(-80, 480)
    Shut_down = Shut_down.setH(80)
    Shut_down_X = Shut_down.getX()
    img_name = "Shut_down"
    Sd_img_L = os.path.join(user_file, img_name+".png")
    Shut_down_img = capture(Shut_down)
    shutil.move(Shut_down_img, Sd_img_L)

    if exists(Sd_img_L):
        SD = find(Sd_img_L)       
        click(SD)
        
Capture()

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.