[WinClip] How to append a string to clipped image?

Get help with using AutoHotkey and its commands and hotkeys
Posts: 7
Joined: 01 Nov 2014, 08:17

[WinClip] How to append a string to clipped image?

11 Nov 2019, 08:46

I've taken a snapshot of a certain area, and hope to paste it into MS Word or OneNote with the window title as source.
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
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  )
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


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" )

Return to “Ask For Help”

Who is online

Users browsing this forum: aifritz, boiler, Chris70, chrism, eL Tux, Epialis, Google [Bot], Jazzman, loek6000, yhk and 51 guests