How to save a screenshot

Hi.

I’m trying to take a screenshot of a window and then save it into a folder. I have the sequence like this:

But when it runs, it says that the file is not found

File not found 225297.png

So, my question is, does the file have to exist beforehand?

Because I have to run a set of lines and try to save the screenshot for all of them.

I’m coming from an UiPath background, so I think the activity should have an option to create the file when needed, but here it doesn’t.

Am I using the wrong activity?

I also found that one could save the screenshot via “invoke code” activity, but it is not present in the build I have. I don’t know if I should do it with the “Execute Script” one.

Since I am trying to replicate the knowledge I have with another tool, I am still looking to understand how the process would be in this case. Any help would be greatly appreciated.

I can see the confusion. Save file is for files stored in OpenCore.

Remove Save File and replace it with an Assign or Invoke Code and call item.SaveAs("C:\image.bmp"). If you use Assign, simply create a Boolean variable and assign the result to that variable. SaveAs will return True if the save was successful.

Thanks Allan.

Is BMP the only supported format to do this? Or I can do PNG for example.
Also, the “Invoke Code” activity is not listed in the version I have available.

I’m pretty sure you can change the extension to png or jpg, and it will adapt, but I cannot test and confirm that right now.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.