0

Instead of providing beforehand all the images as png to find UI elements on screen, I want to have an option for user to capture the region first time the program is run. For example, when program starts, I want user to provide image for button that fires a command and then from next time onwards, I will use that image to find that element and no user input is needed.

So basically, there is one user setup step which will capture all UI elements in the form of png images.

So question is - how to invoke region capture and wait for user to provide the region preferably by dragging and dropping mouse. At the end of this prompt, I should get a png which I will use in subsequent region.find calls. There is "Take screenshot" available in sikuli IDE. Is it exposed programatically? Also, I am working on Windows.

rsp
  • 537
  • 2
  • 13
  • on Linux I can use program `screenshot` with option `--area` to select area (using mouse) and it shows GUI to ask for filename. Or I can use program `import name.png` from program [ImageMagick](https://imagemagick.org/) to select region (using mouse) and save in `name.png`. And I think `import` may works also on other systems. You can use it in Python using `os.system()` or `subprocess.run()`. OR you should check if python module [Wand](https://docs.wand-py.org/en/0.6.10/) has some function for screenshot because it uses `IamgeMagick` – furas Sep 11 '22 at 17:05

1 Answers1

1

Please have a look at the docs here. With the respective setting you will be prompted for an action on FindFailed/ImageMissing. One possible action is to (re)capture the image.

To make it work in your sense, you have to name the image in advance:

find("image1")

On prompt and capture the image will be named image1.png.

RaiMan from SikuliX

RaiMan
  • 1,088
  • 8
  • 13