|
|||
|
Hi,
If I use Image.captureMovie it captures the swf movie only and not the IE browser that I've got loading in. What's the solution to capturing just the application without the rest of the desktop and also the IE instance content? Or how would one go about cropping the captured image using Image.captureScreen to only save the area of the movie? If I can get this working my project will be finished and I'll be on cloud nine ![]() Please advise if you can Cheers |
|
|||
|
In fact there aren't any methods in swfkit can get the screen coordinates of a window. Fortunately, it can be done by calling windows api directly. A little complicated, but it works.
Code:
var wnd = getMainWnd();
var l = wnd.clientRect.left;
var t = wnd.clientRect.top;
var r = l + wnd.clientRect.width;
var b = t + wnd.clientRect.height;
trace(l, ',', t, ',', r, ',', b);
struct {
long x;
long y;
} POINT;
dllimport "user32.dll" stdcall Boolean ClientToScreen(int, POINT*);
var v = new Object;
v.value = new Struct(POINT);
v.value.x = l;
v.value.y = t;
ClientToScreen(wnd.handle, v);
l = v.value.x;
t = v.value.y;
v.value.x = r;
v.value.y = b;
ClientToScreen(wnd.handle, v);
r = v.value.x;
b = v.value.y;
trace(l, ',', t, ',', r, ',', b);
var img = Image.captureScreen(l, t, r - l, b - t);
img.save('e:\\temp\\test.jpg');
|
|
|||
|
Wow thank you, yes it's way above my head but it works
![]() However it isn't working perfectly just yet. It's capturing an image 712x 492 when my Movie is 1008 x 728. Yet if I maximize my Application it captures the full size perfectly. Any chance you could take a sneak peak at the code to see why it might be missing off some of the screen when it opens at it's original size? Code:
//capture
var wnd = getMainWnd();
var l = wnd.clientRect.left;
var t = wnd.clientRect.top;
var r = l + wnd.clientRect.width;
var b = t + wnd.clientRect.height;
trace(l, ',', t, ',', r, ',', b);
struct {
long x;
long y;
} POINT;
dllimport "user32.dll" stdcall Boolean ClientToScreen(int, POINT*);
var v = new Object;
v.value = new Struct(POINT);
v.value.x = l;
v.value.y = t;
ClientToScreen(wnd.handle, v);
l = v.value.x;
t = v.value.y;
v.value.x = r;
v.value.y = b;
ClientToScreen(wnd.handle, v);
r = v.value.x;
b = v.value.y;
trace(l, ',', t, ',', r, ',', b);
var img = Image.captureScreen(l, t, r - l, b - t);
// save file
var f = "jpg files(*.jpg)|*.jpg|";
var path = Dialogs.fileSave(f,"","");
img.save(path);
Code:
//Splash screen
var splash = new SplashWnd(570, 330);
splash.loadSWF(getAdditionalFile("splash.swf"));
splash.timeout = 5000;
splash.window.center();
splash.window.show();
Last edited by urbanriver; 03-31-2009 at 03:59 PM. |
|
|||
|
Sorry, the parameters for the captureScreen method were not correct. The correct code should be
Code:
var img = Image.captureScreen(l, t, r, b); Code:
var splash = new SplashWnd(570, 330);
var stop = false;
splash.onTimeout = function () {
stop = true;
}
splash.loadSWF(getAdditionalFile("splash.swf"));
splash.timeout = 5000;
splash.window.center();
splash.window.show();
while (!stop) {
if (!processMsg()) break;
}
|
|
|||
|
That works a treat thank you very much
![]() One last question, I've found the sample code to send email in the help files: Code:
var sender = new SendMail;
sender.server = " a_smtp_server ";
sender.username = "username";
sender.password = "password";
sender.connect();
sender.command("HELO" + sender.username + "\r\n");
sender.command("MAIL FROM:" + mail.from + "\r\n");
sender.command("RCPT TO:" + mail.to + "\r\n");
sender.command("DATA\r\n");
sender.write(mail.asText());
sender.command("\r\n.\r\n");
sender.close();
Kind regards |
|
|||
|
I've kind of got it working but I can't seem to only send the image if the user clicks ok to the dialog box option:
Code:
//Email Function
Dialogs.msgBox("Capture saved!", "Capture Screen", 0 | 48);
if (Dialogs.msgBox("Would you like to email your image?", "Capture Screen", 4 | 32) != 1)
{
Dialogs.msgBox("Please wait while we send your image. This process may take up to 60 seconds", "Capture Screen", 64);
var mail = new Mail;
//make the envelope
mail.from = "*********";
mail.replyTo = "***********";
mail.to = "*********";
mail.subject = "**********";
mail.date = Date();
mail.priority = 3;
mail.addAttachment(path);
//send the mail
var sender = new SendMail;
sender.server = "********";
//if need authorization, set username and password
sender.username = "********";
sender.password = "******";
sender.send(mail);
Dialogs.msgBox("Email sent!", "Capture Screen", 64);
return true;
}
else
{
}
|
|
|||
|
The image will only be sent when the "OK" button of the second message box has been pushed. A message box simply pauses the program and waits for input. Thus, the program will be stoped by the second message box, and cannot continue to run the followed code to send an email.
|
|
|||
|
Nevermind I was using the wrong return value.
Was: Code:
if (Dialogs.msgBox("Would you like to email your image to Snap Support?", "Capture Screen", 4 | 32) != 1) {
Code:
if (Dialogs.msgBox("Would you like to email your image to Snap Support?", "Capture Screen", 4 | 32) != 6) {
I've got to say I'm impressed with the support and the software so far, I'm looking forward to understanding more about how things work in SWFKit, thanks again! ;D Last edited by urbanriver; 04-03-2009 at 08:55 AM. Reason: Typo |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|