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

Asked by PowerPenguin on 2018-03-14

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:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
2018-03-14
Last query:
2018-03-14
Last reply:
2018-03-14
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")

PowerPenguin (powerpenguin) said : #2

Thanks masuo, that solved my question.