Question #235864 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/235864
tjonnyc posted a new comment: I usually use the 2-part "if-exists" / "if-not-exists" method: def FunctionName(n): Region(500,300,125,40) if exists("Condition.png"): {do something} if not exists("Condition.png"): {do something else} This way, there's an explicit definition of what to do in both cases. Yes, it's more lines of code, but it's a lot easier to maintain. You can also reverse the order, put "if not exists" first if it's more critical. Also, doing it this way allows multi-level checking & actions. Here's an example of a game-bot routine that checks if an item is active on the screen, if not found, it goes into inventory & activates one, if there's none in inventory, it buys one from the in-game store: Inventory = Location(1000,500) #X,Y coordinates of "Inventory" icon def FunctionName(a): Region(700,200,240,35) if exists("ItemIsActive.png"): wait(1) if not exists("ItemIsActive.png"): click(Inventory) if exists("ThisIsTheItemYoureLookingFor.png"): click("ThisIsTheItemYoureLookingFor.png"), wait(1) click(InventoryClose) if not exists("ThisIsTheItemYoureLookingFor.png"): click(InventoryClose), wait(1) BuyItemFromGameStore(a) #separate subroutine that buys items from store -- You received this question notification because you are a member of Sikuli Drivers, which is an answer contact for Sikuli. _______________________________________________ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp