• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 'Make new attachment' dilemma
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'Make new attachment' dilemma


  • Subject: Re: 'Make new attachment' dilemma
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 27 May 2015 13:25:53 +0200


Le 27/05/2015 à 13:11, Brian Christmas <email@hidden> a écrit :

G’day Yvan, and anyone else following this thread.

I’ve struck a bit of a dilemma. The code below, copied verbatim from your post,(except for the file name), with added error trapping, gives an error…

jpgFromClipToPath No tiff data found on clipboard.

I’ve added delays, especially the long 10  second one, and the Chart is being selected, and copied, and can be pasted into a new email message.

Also, if I add a say 1, say 2, say 3, etc., without delays,  between every line of your code, it Works!

I’m at a loss. Are you able to explain what’s going on?

Regards

Santa




try
set the clipboard to ""
activate
tell current application to delay 0.1
tell document 1 to tell sheet 1
tell current application to delay 0.1
position of chart 1
tell current application to delay 10.2
tell application "System Events" to tell process "Numbers"
set frontmost to true
tell current application to delay 0.2
keystroke "c" using {command down}
end tell # System Events…
end tell # document…
on error errmsg
tell application "System Events" to display dialog "Saving jpg Chart image 1 " & errmsg
end try
end tell # Numbers
repeat
if (clipboard info) is not {{Unicode text, 0}, {string, 0}, {scrap styles, 2}, {«class utf8», 0}, {«class ut16», 2}, {scrap styles, 2}} then exit repeat
end repeat
set p2d to path to desktop as text
set fileName to "Numbers_Chart.jpg"
set pathToChart to (p2d & fileName)
set theResult to my jpegFromClipToPath:(POSIX path of pathToChart) compressFactor:1.0
# return pathToChart as alias
end setUpTallyNumbersChartCreator

#=====
# CAUTION : thePath must be a POSIX path !
on jpegFromClipToPath:thePath compressFactor:compFactor -- 0.0 = max compression, 1.0 = none
try
set pb to current application's NSPasteboard's generalPasteboard() -- get pasteboard
set theData to pb's dataForType:"public.tiff" -- get tiff data off pasteboard
if theData = missing value then error "No tiff data found on clipboard"
set newRep to current application's NSBitmapImageRep's imageRepWithData:theData
set theData to (newRep's representationUsingType:(current application's NSJPEGFileType) |properties|:{NSImageCompressionFactor:compFactor, NSImageProgressive:false})
say 18
set theResult to (theData's writeToFile:thePath atomically:true)
say theResult as text
return (theResult = 1)
on error errmsg
tell application "System Events" to display dialog "jpegFromClipToPath " & errmsg
end try
end jpegFromClipToPath:compressFactor:

On 27 May 2015, at 2:55 am, Yvan KOENIG <email@hidden> wrote:


Hello

In fact your instruction used to select a chart is too complicated 😉

Grabbing at least one of the three properties tested below is sufficient.

tell application "Numbers" to tell document 1 to tell sheet 1
position of chart 1
end tell

tell application "Numbers" to tell document 1 to tell sheet 1
width of chart 1
end tell

tell application "Numbers" to tell document 1 to tell sheet 1
height of chart 1
end tell

Grabbing its class, locked or parent doesn't select the object.


Yvan KOENIG (VALLAURIS, France) mardi 26 mai 2015 18:55:50


Here is an alternate test to check that the clipboard is correctly filled.

Replace :

repeat
if (clipboard info) is not {{Unicode text, 0}, {string, 0}, {scrap styles, 2}, {«class utf8», 0}, {«class ut16», 2}, {scrap styles, 2}} then exit repeat
end repeat

by

repeat
try
the clipboard as TIFF picture
exit repeat
on error
delay 0.1
end try
end repeat

I can't test, my wife calls me for launch.

Yvan KOENIG (VALLAURIS, France) mercredi 27 mai 2015 13:21:42




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >'Make new attachment' dilemma (From: Brian Christmas <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Yvan KOENIG <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Brian Christmas <email@hidden>)
 >Re: 'Make new attachment' dilemma (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: 'Make new attachment' dilemma
  • Next by Date: Re: 'Make new attachment' dilemma
  • Previous by thread: Re: 'Make new attachment' dilemma
  • Next by thread: Re: 'Make new attachment' dilemma
  • Index(es):
    • Date
    • Thread