Code: Select all
#NoEnv
#MaxMem,1024
MsgBox,% Clipboard ;Shows plain text, copied from a webpage (as expected).
html1:=clip_GetHtmlString()
MsgBox,% html1 ;Shows html (as expected).
clip_SetHtmlString(html1)
MsgBox,% Clipboard ;Shows nothing (as expected).
html2:=clip_GetHtmlString() ;Crashes here - specifically, when executing the line DllCall("User32.dll\OpenClipboard","Ptr",0,"UInt")
MsgBox,% html2
;----------------------------------------------------------------------------------------------
clip_GetHtmlString()
{ if !DllCall("User32.dll\IsClipboardFormatAvailable","UInt",ClipFormatHtml:=DllCall("User32.dll\RegisterClipboardFormat","Str","HTML Format","UInt"))
return 0
DllCall("User32.dll\OpenClipboard","Ptr",0,"UInt")
htmlString:=DllCall("User32.dll\GetClipboardData","UInt",ClipFormatHtml,"Str")
DllCall("User32.dll\CloseClipboard")
Len:=(StrLen(htmlString)*(A_IsUnicode?2:1))
If (Len<1)
return 0
return StrGet(&htmlString,Len,"")
}
clip_SetHtmlString(htmlString)
{ DllCall("User32.dll\OpenClipboard","Uint",0)
DllCall("User32.dll\EmptyClipboard")
DllCall("User32.dll\SetClipboardData","Uint",DllCall("User32.dll\RegisterClipboardFormat","Str","HTML Format","UInt"),"Astr",htmlString)
DllCall("User32.dll\CloseClipboard")
return
}