WARNING: watch the delay, if you put a delay to short before the backspace it can break your docs (even if you chose a previous version) (It probably delete some google doc important code). Try it on a draft before...
Google script are useless for this kind of quick operation (too slow), so ahk is handy for that.
Code: Select all
; ************************************** get clipboard, change to blue color
; ⚠ you need to download winclip (2 ahk files, save it somewhere and then change the 2 paths #Include bellow. Winclip is here:
; https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/
#IfWinActive ahk_exe chrome.exe ; the shortcut will only work on chrome
#Include C:\Users\Me\Desktop\modul_ahk\WinClip\WinClipAPI.ahk
#Include C:\Users\Me\Desktop\modul_ahk\WinClip\WinClip.ahk
!^+p:: ; Alt(!) CTRL(^) shift(+)
WinClip.Copy()
t := WinClip.GetText()
ClipWait
; MsgBox, % t ; (to debug)
; clipboard = %t%
; ClipWait
var1 = <p style="color:#0000cc">
var2 = </p>
x = %var1%%t%%var2%
clipboard = %x%
ClipWait
; MsgBox, % x ; (to debug)
; clipboard = %x%
; ClipWait
WinClip.SetHTML( x )
ClipWait
Send ^v
;for some reason it will create a line break, to remove it:
sleep 250 ; ⚠ if no delay or too short the code will corrupt your doc!
Send {BACKSPACE}
return
#IfWinActive
Code: Select all
sleep 300
Send, {BACKSPACE}
sleep 300
Send, {BACKSPACE}