Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-31-2009, 10:56 AM
Junior Member
 
Join Date: Mar 2009
Posts: 19
Default Image.captureMovie & IE (createControl)

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
Reply With Quote
  #2 (permalink)  
Old 03-31-2009, 12:56 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

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');
Reply With Quote
  #3 (permalink)  
Old 03-31-2009, 03:51 PM
Junior Member
 
Join Date: Mar 2009
Posts: 19
Default

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);
Oh and I'm not 100% sure how I get the spash screen to show then to show the application once the spash timer has ran its course. At the moment with the code below it show the splash screen over the top of the application with both of them loading in at the same time.

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.
Reply With Quote
  #4 (permalink)  
Old 03-31-2009, 04:43 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

Sorry, the parameters for the captureScreen method were not correct. The correct code should be
Code:
var img = Image.captureScreen(l, t, r, b);
About the splash window, you can add some code to prevent the main window from displaying before the splash has been closed:

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;
}
Reply With Quote
  #5 (permalink)  
Old 04-02-2009, 10:58 AM
Junior Member
 
Join Date: Mar 2009
Posts: 19
Default

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();
Are there any samples that would allow me to send the captured image file via my own STMP server to a default email address?

Kind regards
Reply With Quote
  #6 (permalink)  
Old 04-02-2009, 01:33 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

Sure, you can create a Mail object, and add the image as an attachment.
Reply With Quote
  #7 (permalink)  
Old 04-02-2009, 04:04 PM
Junior Member
 
Join Date: Mar 2009
Posts: 19
Default

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 
{
}
Any ideas ?
Reply With Quote
  #8 (permalink)  
Old 04-02-2009, 04:41 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

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.
Reply With Quote
  #9 (permalink)  
Old 04-03-2009, 08:14 AM
Junior Member
 
Join Date: Mar 2009
Posts: 19
Default

Thing is it still runs the code if I click Yes or No, not sure why.

Regards
Reply With Quote
  #10 (permalink)  
Old 04-03-2009, 08:54 AM
Junior Member
 
Join Date: Mar 2009
Posts: 19
Default

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) {
Should have been:
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
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:41 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.