ZAARONBIN - 博客园

[other] AutoHotKey.ahk

typora通过AutoHotKey软件设置Alt+(o/r/b/g/y)对选中字段添加对应颜色的快捷键

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

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

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

    ; Alt+b 浅蓝色
    !b::addFontColor("cornflowerblue")
	
	; Alt+g 绿色
	!g::addFontColor("green")
}

; 快捷增加字体颜色
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中自动补全标签
    }
}

posted @ 2021-11-17 15:06  BINBINBINZ  阅读(44)  评论(0编辑  收藏  举报