Code: Select all
<span style="color: red;">TEXT</span>
Thank you!
Code: Select all
<span style="color: red;">TEXT</span>
Code: Select all
^+v:: ; ctrl+shift+v after copying the formatted text
Clipboard:=StrReplace(Clipboard, "red", "green")
Send, %Clipboard%
Return
Code: Select all
LWin::
myHTML := Get_Clipboard_HTML()
MsgBox, % myHTML
myHTML := RegExReplace(myHTML, "AAA", "XXX")
Put_Clipboard_HTML(myHTML)
MsgBox, % Get_Clipboard_HTML()
return
;---------------------------------
Get_Clipboard_HTML() {
If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
If DllCall( "OpenClipboard", UInt,0 ) <> 0
If hData := DllCall( "GetClipboardData", UInt, CBID, UInt )
DataL := DllCall( "GlobalSize", UInt, hData, UInt )
, pData := DllCall( "GlobalLock", UInt, hData, UInt )
, html := StrGet( pData, dataL, "UTF-8" )
, DllCall( "GlobalUnlock", UInt, hData )
DllCall( "CloseClipboard" )
Return html
}
Put_Clipboard_HTML(html) {
If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
If DllCall( "OpenClipboard", UInt,0 ) <> 0
If hData := DllCall( "GetClipboardData", UInt, CBID, UInt )
DataL := DllCall( "GlobalSize", UInt, hData, UInt )
, pData := DllCall( "GlobalLock", UInt, hData, UInt )
, StrPutVar( html, pData, "UTF-8" )
, DllCall( "GlobalUnlock", UInt, hData )
DllCall( "CloseClipboard" )
}
StrPutVar(string, ByRef var, encoding)
{
; Ensure capacity.
VarSetCapacity( var, StrPut(string, encoding)
; StrPut returns char count, but VarSetCapacity needs bytes.
* ((encoding="utf-16"||encoding="cp1200") ? 2 : 1) )
; Copy or convert the string.
return StrPut(string, &var, encoding)
}