How to run console command "shot" via C++

Here is a link to a similar question: link text

GEngine->GameViewport->Viewport->TakeHighResScreenShot();

Hi,

I want to get a screenshot by using “shot” command, so I write some code below but after running it I can not get a png file in Saved\Screenshots\Windows\ folder:

auto controller = UGameplayStatics::GetPlayerController(this, 0);
FString command = TEXT("shot");
controller->ConsoleCommand(command, true);

these code below also failed:

FString command = TEXT("shot");
GetWorld()->Exec(GetWorld(), *command);

Can anyone tell me why these doesn’t work?

After I run this statement, I cannot find any screenshot png files in my project folder. What’s wrong with my project…

After I peek the definition of “shot” in engine source code, I find an awful way to take a shot and save the png file:

GEngine->GameViewport->Exec(NULL, TEXT("SCREENSHOT"), *GLog);
GEngine->GameViewport->ProcessScreenShots(GEngine->GameViewport->Viewport);

It would be simpler to call FScreenshotRequest::RequestScreenshot(fileName, bShowUI, bAddFilenameSuffix) directly.