typroa设置字体的颜色

下载并安装 AutoHotkey

访问 AutoHotkey 主页: https://autohotkey.com/
点击下载: https://autohotkey.com/download/ahk-install.exe

桌面新建文件 MyHotkeyScript.ahk 将以下代码复制进去保存
注意文件后缀.ahk

; Typora
; 快捷增加字体颜色
; SendInput {
    
    Text} 解决中文输入法问题

#IfWinActive ahk_exe Typora.exe
{
    
    
    ; Ctrl+Alt+o 橙色
    ^!o::addFontColor("orange")

    ; Ctrl+Alt+r 红色
    ^!r::addFontColor("red")

    ; Ctrl+Alt+b 浅蓝色
    ^!b::addFontColor("cornflowerblue")
}

; 快捷增加字体颜色
addFontColor(color){
    
    
    clipboard := "" ; 清空剪切板
    Send {
    
    ctrl down}c{
    
    ctrl up} ; 复制
    SendInput {
    
    TEXT}<font color='%color%'>
    SendInput {
    
    ctrl down}v{
    
    ctrl up} ; 粘贴
    If(clipboard = ""){
    
    
        SendInput {
    
    TEXT}</font> ; Typora 在这不会自动补充
    }else{
    
    
        SendInput {
    
    TEXT}</ ; Typora中自动补全标签
    }
}

双击运行(使用AutoHotkey运行)

然后去Typora 按快捷键即可

选择要设置颜色的文字,按Ctrl+Alt+o添加橙色,按Ctrl+\取消样式!

Guess you like

Origin blog.csdn.net/weixin_42349568/article/details/120914690