1. take a snapshot by comandline app, and the snapshot is saved in clipboard
2. convert the clipped image in clipboard to Base64
3. use WinClip.SetHTML to modify clipboard content to html like:
"<img src='data:img/jpg;base64,b64string '/><br><a href=" some url "> some text</a>"
But it doesn't work as it is expected. Please help to share your comments. Thanks.
Code: Select all
#Include WinClipAPI.ahk
#Include WinClip.ahk
F1::
WinGetActiveTitle, aTitle
SnipPaste:="C:\Downloads\Snipaste-1.16.2-x64\Snipaste.exe snip -o clipboard"
runwait, %SnipPaste%
wc := new WinClip
dataSize := WinClip.Snap( clipboard )
b64string := b64Encode( data, dataSize )
LinkUrl:="www.google.com"
LinkText:="Hello"
html_base64:="<img src=" . chr(39) . "data:img/jpg;base64," . b64string . chr(39) . "/>"
html_link:="<br><a href=" . chr(34) . LinkUrl . chr(34) . ">" . LinkText . "</a>"
html_content:=html_base64 . html_link
wc.SetHTML(html_content)
Return
b64Encode( ByRef buf, bufLen )
{
DllCall( "crypt32\CryptBinaryToStringA", "ptr", &buf, "UInt", bufLen, "Uint", 1, "Ptr", 0, "UInt*", outLen )
VarSetCapacity( outBuf, outLen, 0 )
DllCall( "crypt32\CryptBinaryToStringA", "ptr", &buf, "UInt", bufLen, "Uint", 1, "Ptr", &outBuf, "UInt*", outLen )
return strget( &outBuf, outLen, "CP0" )
}