Typora compiles md file text and sets the color

Typora compiles md file text and sets the color

AutoHotKey is a well-known windows system shortcut key setting software, light and small.

Official download: https://autohotkey.com/download/ahk-install.exe

1. Install AutoHotKey first

2. Open the notepad, copy and paste the following content into it:

; 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中自动补全标签
    }

}

3. Save the file as a file with ahk suffix

Such as TyporaHotKey.ahk

4. Double-click to run

5. You can use shortcut keys in Typora software:

For example, press to Ctrl+Alt+Oadd orange, Ctrl+Alt+R to red, press to Ctrl+\cancel the style!

You can also right MyHotkeyScript.ahkscript file, click Compile ScriptCompile scripts into the exeprogram, you can not download Autohotkeyto run on another computer.

The above script only writes three colors of orange, red, and light blue. You can add other colors or shortcuts as required!

6. Add to boot auto-start

Right-click TyporaHotKey.ahk to create a shortcut

Copy the shortcut to this directory under Windows7:

C:\Users\用户名\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\startup

ok!

Guess you like

Origin blog.csdn.net/weixin_43988498/article/details/109049088