TGMainFrame save picture inage from macro

I have a run control GUI that I want to save a picture of it every few minutes to be able to put on the web, for a quick check to make sure the run is going well.

I know that for a TCanvas/TPad one can use the Print() function and pass it the file name. The Print() function for the TGMainFrame class just prints all the information to the screen.

Is there a way I can get a snaphot of the GUI by using ROOT functions?

Hi,

Here is the way:

TImage *img = TImage::Create(); mainframe->RaiseWindow(); img->FromWindow(mainframe->GetId()); img->WriteImage("filename.extension"); delete img;
And replace “filename.extension” with the filename and the extension you want (e.g. png, jpg, gif…) :wink:

Cheers, Bertrand.

Thanks, that did the trick.