Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Titanium.Desktop.takeScreenshot throws error

If I use Titanium.Desktop.takeScreenshot with the same file more than once, it throws the error can't write file. Look's like this function doesn't free the file-ressource. Can someone reproduce this problem?

— asked March 12th 2010 by Steve Rohrlack
  • desktop
  • error
  • screenshot
1 Comment
  • Reported this as a bug here.

    — commented October 19th 2010 by Andris Z??eris

2 Answers

  • What do you mean by "with the same file"? Could you post the code you're using for folks to verify? (pastie.org)

    — answered March 12th 2010 by Kevin Whinnery
    permalink
    0 Comments
  • Seems in win32 the file can't be opened in write mode after the screenshot is taken, so here's a workaround (the original write-locked file can be deleted after titanium exits):

    var tmp = Titanium.Filesystem.createTempDirectory().toString()
            + Titanium.Filesystem.getSeparator()
            + "screenshot.png";
    Titanium.Desktop.takeScreenshot(tmp);
    Titanium.Filesystem.asyncCopy(tmp, Titanium.Filesystem.getDesktopDirectory(), function(index, total){
        alert("Screenshot should be here: " + index);
    });
    
    — answered October 19th 2010 by Andris Z??eris
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.