You are not logged in.
I have done some research on Apple mail and find this:MUIWebDocumentPasteboardType
I have extract it to a file and it looks like this, the pasteboardType is binary plist.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>$archiver</key>
<string>NSKeyedArchiver</string>
<key>$objects</key>
<array>
<string>$null</string>
<dict>
<key>$class</key>
<dict>
<key>CF$UID</key>
<integer>9</integer>
</dict>
<key>MUIWebDocumentAttachments</key>
<dict>
<key>CF$UID</key>
<integer>3</integer>
</dict>
<key>MUIWebDocumentHTML</key>
<dict>
<key>CF$UID</key>
<integer>2</integer>
</dict>
<key>MUIWebDocumentJSDocumentContext</key>
<dict>
<key>CF$UID</key>
<integer>5</integer>
</dict>
<key>MUIWebDocumentOriginalEncoding</key>
<integer>10</integer>
</dict>
<string><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
The last line is a string I'm intresting in. (HTML Source) of the email.
So I made this code and it give the string but I wonder if there is a better way, to do this ??
Applescript:
use framework "Foundation"
use framework "AppKit"
use scripting additions
set thePath to POSIX path of (choose file)
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set theData to current application's NSData's dataWithContentsOfURL:theURL
set plist to current application's NSPropertyListSerialization's propertyListWithData:theData options:(current application's NSPropertyListImmutable) format:(missing value) |error|:(missing value)
set theObject to plist's objectForKey:"$objects"
set theString to (theObject's objectAtIndex:2) as text
Applescript:
set theObject to plist's objectForKey:"$objects"
set theString to (theObject's objectAtIndex:2) as text
Last edited by Fredrik71 (2021-01-05 03:02:26 am)
The purpose to study someone else art is not to add, its to make less more.
Offline
Rather than NSPropertyListSerialization you should use NSKeyedUnarchiver — the presence of NSKeyedArchiver tells you how it was made. Use +unarchiveObjectWithData: or + unarchiveObjectWithFile:.
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline
Thanks Shane... I will look at it
I read on website that NSPropertyListSerialization is faster and NSKeyedUnarchive
Do you share the same experience/knowledge ?
The purpose to study someone else art is not to add, its to make less more.
Offline
I'm not sure a speed comparison makes sense — they perform different functions.
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline
You could read more about it here...
https://macosx-dev.omnigroup.narkive.co … erformance
The purpose to study someone else art is not to add, its to make less more.
Offline
Shane I try this but it return a error...
error "*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (MUIWebDocument) for key (root); the class may be defined in source code or a library that is not linked" number -10000
Do you know what is happening ??
The code I use was:
Applescript:
use framework "Foundation"
use framework "AppKit"
use scripting additions
set thePath to POSIX path of (choose file)
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set theData to current application's NSData's dataWithContentsOfURL:theURL
set theUnarchiver to current application's NSKeyedUnarchiver's unarchiveObjectWithData:theData
The purpose to study someone else art is not to add, its to make less more.
Offline
It means that whatever app is putting that on the clipboard has defined a class called MUIWebDocument, of which this represents an instance.
You earlier code should be OK, but I'm generally nervous about relying on a particular order.
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline
It means that whatever app is putting that on the clipboard has defined a class called MUIWebDocument, of which this represents an instance.
So if I understand you correctly, I couldn't use NSKeyedUnarchiver or would it involve a more
complicated process.
I need to read more about this because my knowledge is very limited, I have never done any
examples with NSKeyedArchive before. The first time I heard about it was when I read on wikipedia
about webarchive.
The approach we choose for the moment maybe are not what we want, but its bold to do something
more complicated because in return we could learn something new from it.
Thanks for your input.
The purpose to study someone else art is not to add, its to make less more.
Offline
So if I understand you correctly, I couldn't use NSKeyedUnarchiver or would it involve a more complicated process.
That's correct. You'd have to do something like create a version of the class yourself, reverse-engineering parts of it from the property list. It may or may not even be possible.
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline
...reverse-engineering parts of it from the property list. It may or may not even be possible.
I feel more luck with: If I ever meet Tim Cook in person he will give me the source code of Apple Mail.
Thanks again.
The purpose to study someone else art is not to add, its to make less more.
Offline