I would like to get a screenshot by executing a servoy function.
I couldn’t find a plugin or anything else to get this running, but I found a pure java code for that:
var fr = new Packages.java.io.FileReader('/tmp/xyz.log');
var br = new Packages.java.io.BufferedReader(fr);
global.my3lines += br.readLine();
global.my3lines += br.readLine();
global.my3lines += br.readLine();
br.close();//do NOT forget this close! to prevent mem leaks, even better to use try/finally here
sorry for the delay. The sreenshot function by Patrick’s plugin is working well. Now I will try executing Java in a Servoy method like your example. Hope I get it working…
I also tried to execute java codes from servoy method but didn’t succeed …
It would be nice if you could share a sample method to execute the same…
Sovan
We use the screenshot code from Arup (was with Mindfire but not sure now)
To call it:
function onTakeScreenSnapshot(event)
{
var desktopImage = globals.takeScreenShot("png");
var saveFileName = plugins.file.showFileSaveDialog('RISCm_screen_dump.png','Save Image')
var createdFile = plugins.file.writeFile(saveFileName,desktopImage)
if(!createdFile)
{ globals.DIALOGS.showErrorDialog('Flie Save Error','Your File Was NOT Saved', 'OK')
}
else {globals.DIALOGS.showInfoDialog('Flie Saved','Your File Was Saved to '+saveFileName, 'OK')}
}
The function:
function takeScreenShot()
{ /*
method name : takeScreenShot
usage: takeScreenShot(imageFormat);
input: imageFormat: text representing the image mime type.
Ex. "png", "jpg", "jpeg" etc.
output: The script will take a screen shot of your desktop
and returns byte array of the specified image format.
* IRJC Modified this to grab just the current Servoy Window.
note:
Change history:
04/14/09 Arup Ranjan Sahoo Created method
*********************************************************************/
//Get the Image Format
var imageFormat = arguments[0];
//Get the Desktop Screen Size
screenWidth = application.getWindowWidth()
screenHeight = application.getWindowHeight()
screenX = application.getWindowX()
screenY =application.getWindowY()
var screenRect = new java.awt.Rectangle(screenX, screenY, screenWidth, screenHeight);
//Capture the Screen as a Buffered Image
var screenImage = new java.awt.Robot().createScreenCapture(screenRect);
//Convert the Buffered Image to Byte Array
var baos = new java.io.ByteArrayOutputStream();
Packages.javax.imageio.ImageIO.write(screenImage, imageFormat, baos);
return baos.toByteArray();
}