How to take a screenshot and send it by email?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Re: How to take a screenshot and send it by email?

Post by liveCode » Wed Apr 06, 2022 8:01 pm

How can I make sure that the screenshot does not show black on top?

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to take a screenshot and send it by email?

Post by Klaus » Wed Apr 06, 2022 8:16 pm

If you use "showAll" for the fullscreenmode, try this:

Code: Select all

...
export snapshot from rect(the rect of this card) to image "AuxImg" as PNG
...

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Re: How to take a screenshot and send it by email?

Post by liveCode » Fri Apr 08, 2022 10:54 am

It's even worse

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to take a screenshot and send it by email?

Post by jacque » Fri Apr 08, 2022 7:58 pm

You may need to use a calculated rectangle parameter for the screenshot:

Code: Select all

export snapshot from rect "0,0,200,200" to file "Nav.jpg" as JPEG
You'll need to figure out the topleft and bottomright coordinates. Sometimes it's easier to use the corners of existing controls but it doesn't look like your card has any at the corners. You could probably calculate it by adding or subtracting pixels from controls that are near the corners. Or put a couple of invisible controls there to use as marker points (but that's an inelegant workaround.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

Re: How to take a screenshot and send it by email?

Post by terryho » Wed Apr 13, 2022 4:52 am

Hi,

Try to group the field and the the output area in a group, Then export snapshot on this group.

I think it will exactly show the area you want.

Regards

Terry Ho

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Tue Feb 23, 2010 10:53 pm
Location: Saint Louis, Missouri USA

Re: How to take a screenshot and send it by email?

Post by bobcole » Fri Apr 15, 2022 10:36 pm

It seems there are two parts to this thread, 1) the correct snapshot rectangle and 2) how to attach an image to an email by script.
1) The globalLoc function will help you translate a local point to a screen coordinates. See the Dictionary.
Below is a button script that takes a snapshot of a card and puts a jpeg image on your desktop.
2) I couldn't get the revMail function (or even AppleScript) to attach the image so I can't help with that part.
Bob C

Code: Select all

on mouseUp pButtonNumber
   put the rectangle of this card into tCardRectOrig
   put toScreenCoordinates(tCardRectOrig) into tCardRect
   
   put specialFolderPath("desktop") into tFolderPath
   put tFolderPath & "/SnapShotTest.JPEG" into tFilePath
   
   export snapshot from rectangle tCardRect to file tFilePath as JPEG
   launch document tFilePath
   beep
end mouseUp

function toScreenCoordinates pCardRect
   put pCardRect & return into message box
   --put "Unadjusted: " & pCardRect & return into message box
   
   put globalLoc("0,0") into tGlobalLoc  --see Dictionary
   --put "Global Loc: " & tGlobalLoc & return after message box
   
   put item 1 of tGlobalLoc into tHorizontalShift
   put item 2 of tGlobalLoc into tVerticalShift
   
   add tHorizontalShift to item 1 of pCardRect 
   add tVerticalShift to item 2 of pCardRect
   add tHorizontalShift to item 3 of pCardRect 
   add tVerticalShift to item 4 of pCardRect
   --put "Adjusted: " & pCardRect & return after message box
   
   return pCardRect
end toScreenCoordinates

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”