【问题标题】:How to avoid sikuli creating a png file when using "with Region"使用“with Region”时如何避免 sikuli 创建 png 文件
【发布时间】:2015-03-31 19:58:34
【问题描述】:

我在 sikulix(版本 2015-01-06)中有以下代码

...
t = wait("total_power.png")
area = Region(t.x+t.w, t.y, 80, 31)

with Region(area):
    wait("num_1.png")
    ....

我发现“with Region”会在python文件的同一目录下创建一个png文件。 png 文件是我想要的区域。
如何避免?

【问题讨论】:

    标签: sikuli


    【解决方案1】:

    你想在这里做什么?
    您是否想等到一个窗口出现,然后在该窗口内查看另一张图片出现?

    在这种情况下,当您找到“t”时,您已经定义了该区域。
    “t”是图片“total_power.png”的位置

    例如:

    # Wait until the window appears. 
    p1 = wait("image1.png")
    # Find another picture inside the window. 
    p2 = p1.wait("image2.png")
    

    编辑:

    你应该看看这里:Link
    我认为你可以使用 .right(),如果你把 () 留空,你就会拿走所有东西。
    如果填写一个值,您将占据屏幕的一部分。
    我在编程时使用 .hightlight() 来显示我正在查看的区域。

    您还可以使用 region1.union(region2) 将 2 个区域合并到一个新区域。

    一个例子:

    Image1 = ("image1.png")
    
    class Blue():
        def __init__(self):
            # Find an image. 
            LocImage1 = find(Image1)
            # Too show the user the region we selected, we can highlight if for 5 seconds. 
            LocImage1.highlight(5)
            # Grab the region to the right of this image. 
            LocImage1RightSide = LocImage1.right()
            # Highlight the region again. 
            LocImage1RightSide.highlight(5)
    
    # Run class 
    Blue()
    

    【讨论】:

    • 我要找的是“total_power.png”的右侧,而不是里面。
      这就是我创建另一个区域并使用“with Region”语法的原因。
    • 我认为你需要使用 .right() 我用一个例子编辑了我的帖子。
    • 谢谢你,丹增。但是,我的问题是避免在使用“with Region”时创建 png 文件。不要在它旁边设置区域。无论如何, region.find() 工作并且不创建 png 文件。
    猜你喜欢
    • 2018-03-17
    • 1970-01-01
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多