SikulixIDE 1.1.2 - Take a screenshot in the script and save it permanently

Asked by PowerPenguin

Hi! I'm working with Python and I would like to take a screenshot of a certain region of the screen and save it to use it later on another script. I read in other questions that the screenshots that are taken this way are only stored as temporary files and are deleted once the script finishes.

Would it be possible to save the image taken and store it permanently even after the script finished?

This is my code:

screen = Screen()
screen.capture(someRegion)

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
Last query:
Last reply:
Revision history for this message
Best masuo (masuo-ohara) said :
#1

Try this.

import shutil
r = Region(0,0,200,200)
screen = Screen()
tmpfile = screen.capture(r).getFile()
shutil.move(tmpfile, "C:\\Users\\masuo\\Desktop\\image.png")

Revision history for this message
PowerPenguin (powerpenguin) said :
#2

Thanks masuo, that solved my question.