Capture the screen and store the images into a path while running the script

Asked by Brian

Hi RaiMan,

How can I code to capture the screen and store the images into a path after I click "Run" ?
Thanks a lot!

Best Regards,
Brian

Question information

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

Hi,

Like I have mentioned here https://answers.launchpad.net/sikuli/+question/245693, you can create a kind of a helper function you can use.

def takeScreenShot(imageName):
 img = capture(SCREEN)
 shutil.move(img, 'C:\\<Path>\\%(appName)s.png' %{"appName": imageName})

This function gets the image name you would like to give it as a parameter.
And don't forget to import the shutil module and define your <Path> properly.

Cheers,
Eugene

Revision history for this message
Brian (brianiptszleung) said :
#2

Thanks Eugene S, that solved my question.