Taking Screenshots with Xojo


is there an easy way to take (cross-platform-) screenshots with xojo?


I think mbs has something for doing screenshot. I have a feature to talk screenshot of the current tab and attach the screenshot to the database.

ok, thank you.

Nothing Xojo build-in?


Nothing built in. On Mac you can run command line tool, I think.
But in general I would recommend our plugin.

Xojo windowshot

[code] dim p as new Picture(self.Width, self.Height, 32)
dim c as new Clipboard

self.DrawInto(p.Graphics, 0, 0)
c.Picture = p

1 Like

FWIW, the MBS plugin function works very well on both Mac and Windows. (I’ve not tried it on Linux.) And, it is VERY fast.

On OSX… Shift-Cmd-3 takes a screenshot…

Thank you all, Joachims suggestion seems to be what i was looking for.

Those code from joachims will put the screenshot in the clipboard. Mbs one can save it to a file.

you are right, but i hope i will get the clipboard-content and put it to a file with pure xojo.

try: http://documentation.xojo.com/index.php/Picture.Save

Looks good, thank you.

Michael this code from my method I have used. HTH also.

  Dim pict As Picture
  Dim d as new Date
  // Create Timestamp for ScreenCapture Save Name
  Dim timeStamp as string =  str(d.Minute) + str(d.Second)
  Dim f as FolderItem = GetSaveFolderItem("image/png","ScreenCapture_" + timeStamp + ".png")
  If f <> Nil then
    pict = New Picture(self.Width, self.Height, 32)
    Self.DrawInto pict.Graphics, 0, 0
    pict.Save(f, Picture.SaveAsPNG)
  end if

Mike, your code sample works fine here but there is another question:

How can i capture the whole desktop instead of the app-window?

Michael check this thread is it has sample declare code for Windows Screen Capture. I personally haven’t used it nor needed to capture the entire desktop (yet). :slight_smile:

Real Software Forum - Screen Capture image size - make is smaller and faster?


The code posted by guykuo on the old forums won’t work under RB2010r5 and newer since it declares directly into the runtime (the big warning on top came true.) The Windows Functionality Suite has an updated method.

While not cross platform, Joe Ranieri attached routines to feedback case # 18993 that would grab a screenshot for macs using declares labelled “screenshot.rbp.zip”

i found the code to use for both mac and windows


I tried Mike Cotrone’s code from this thread. I’m getting a blank PNG file. The only thing in my window is a HTMLViewer. Should that be showing up in the PNG?

See https://forum.xojo.com/8025-htmlviewer-image-to-canvas-question