I see you're roughly doing the same thing I set out to do. I made a breakthrough with WinClip that I believe can help you. While Evernote is similar to HTML it is not HTML. It is Evernote Markup Language; it's own proprietary format. As you can see here (
Evernote Markup Language) it is very similar. I found using ClipSpy that the text format in the clipboard is titled "ENML Format". With this I was able to make some changes in WinClip to account for this new format. Basically all I did was take all the HTML specific functions and replace HTML with ENML. Here is the code I added to the WinClip.ahk file.
Code: Select all
SetENML( enml, source = "" )
{
if ( enml = "" )
return 0
clipSize := this._fromclipboard( clipData )
if !( clipSize := this._setENML( clipData, clipSize, enml, source ) )
return 0
return this._toclipboard( clipData, clipSize )
}
iSetENML( enml, source = "" )
{
if ( enml = "" )
return 0
this._IsInstance( A_ThisFunc )
clipSize := this._getClipData( clipData )
if !( clipSize := this._setENML( clipData, clipSize, enml, source ) )
return 0
return this._setClipData( clipData, clipSize )
}
_calcENMLLen( num )
{
while ( StrLen( num ) < 10 )
num := "0" . num
return num
}
_setENML( ByRef clipData, clipSize, enmlData, source )
{
objFormats := this._parseClipboardData( clipData, clipSize )
uFmt := WinClipAPI.RegisterClipboardFormat( "ENML Format" )
objFormats[ uFmt ] := object()
encoding := "UTF-8"
enmlLen := StrPut( enmlData, encoding ) - 1 ;substract null
srcLen := 2 + 10 + StrPut( source, encoding ) - 1 ;substract null
StartENML := this._calcENMLLen( 105 + srcLen )
EndENML := this._calcENMLLen( StartENML + enmlLen + 76 )
StartFragment := this._calcENMLLen( StartENML + 38 )
EndFragment := this._calcENMLLen( StartFragment + enmlLen )
enml =
( Join`r`n
<en-clipboard><en-note><span style="color: rgb(0, 0, 0); font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; display: inline !important; float: none;">
%enmlData%
</span></en-note></en-clipboard>.
)
sLen := StrPut( enml, encoding )
ObjSetCapacity( objFormats[ uFmt ], "buffer", sLen )
StrPut( enml, ObjGetAddress( objFormats[ uFmt ], "buffer" ), sLen, encoding )
objFormats[ uFmt ].size := sLen
return this._compileClipData( clipData, objFormats )
}
GetENML()
{
if !( clipSize := this._fromclipboard( clipData ) )
return ""
if !( out_size := this._getFormatData( out_data, clipData, clipSize, "ENML Format" ) )
return ""
return strget( &out_data, out_size, "UTF-8" ) ;Previously UTF-8 was CP0, changed to account for unicode characters
}
iGetENML()
{
this._IsInstance( A_ThisFunc )
if !( clipSize := this._getClipData( clipData ) )
return ""
if !( out_size := this._getFormatData( out_data, clipData, clipSize, "ENML Format" ) )
return ""
return strget( &out_data, out_size, "UTF-8" ) ;Previously UTF-8 was CP0, changed to account for unicode characters
}
Use the WinClip.SetText after WinClip.getENML to see exactly how Evernote is handling the formats. I tested it myself and all the formatting was there in copied text.
Per your Bug Fix 2 I managed to change the format to UTF-8 and the characters (that I copied from your comments) encoded just fine back and forth in WinClip. I noted in the code above my format changes.