Taking multiple HighResShot from a command line Python script

I put these 3 lines in a Python script…

import unreal
unreal.SystemLibrary.execute_console_command(unreal.EditorLevelLibrary.get_editor_world(), “HighResShot 2”)
unreal.SystemLibrary.execute_console_command(unreal.EditorLevelLibrary.get_editor_world(), “HighResShot 2”)

…and run them from the DOS command line, like this…

D:\UE4Editor.exe “D:\MyProject.uproject” -ExecutePythonScript=“D:\HighResShot_multi.py”

…and I only get 1 screenshot, instead of the two that I was expecting. Can someone help me make this work? Or explain why it does not work? The log indicates that the command got run twice. The snapshots are not overwriting eachother. I’ve tried explicit naming, and I only get the last one. I am trying to loop over assets and take snapshots. I always get only the last asset.

Note to self: I switched over to doing the same thing in C++, no python, using Editor Scripting Utilities, and the same thing is happening. I am calling

FScreenshotRequest::RequestScreenshot(MyPath, true, true);

from inside a for loop in C++ and I only get the last screenshot that is requested. It seems like the screenshot is taken after the function call is ended.

The HighResShot command sets a flag for the viewport which is read on the next engine tick. You will need to delay multiple frames between requesting high res shots. To do this via python on the command line you will probably need to hook the slate tick delegate to know when multiple frames have passed. (unreal.register_slate_post_tick_callback)

1 Like

Thanks! I just now saw this. I guess I’m not getting notified when people reply on these threads.

I want to take multiple screenshots while NOT playing. I guess I need some python code to simulate a game and tick manually?

https://forums.unrealengine.com/development-discussion/python-scripting/1679694-python-api-highrescreenshot

Thank you Andreas!!! It works! Wow! I struggled with this for a long time. Thank you!

Sorry, I know this is old, but I’m having this same problem. @Andreas_Ranman or @darkczar do you remember how you fixed this? The link from Andreas is 404 or private.

1 Like

I created this tutorial on how to make a tool to do something very similar. Hope it helps!

@quackaddict7