Typora sets the default programming language and font color settings for code blocks

Typora sets the default programming language and font color settings for code blocks

1. Link to download ahk. https://autohotkey.com/download/ahk-install.exe

        After the installation is complete, you can directly create a new ahk script (right click on the desktop, or change the suffix of txt)

<span style="background-color:#333333"><span style="color:#b8bfc6"> <span style="color:#da924a">#IfWinActive ahk_exe Typora.exe</span>
 {
     ; Ctrl<span style="color:#b8bfc6">+</span>Alt<span style="color:#b8bfc6">+</span>K cCode    
     ; crtl  是  ^      alt   是   !    k  是  k键
     ^!k::addCodeC()
     
     ; Typora
     ; 快捷增加字体颜色
     ; SendInput {Text} 解决中文输入法问题
     
     ; Ctrl<span style="color:#b8bfc6">+</span>Alt<span style="color:#b8bfc6">+</span>O 橙色
     ^!o::addFontColor(<span style="color:#d26b6b">"orange"</span>)
 ​
     ; Ctrl<span style="color:#b8bfc6">+</span>Alt<span style="color:#b8bfc6">+</span>R 红色
     ^!r::addFontColor(<span style="color:#d26b6b">"red"</span>)
      
     ; Ctrl<span style="color:#b8bfc6">+</span>Alt<span style="color:#b8bfc6">+</span>B 浅蓝色
     ^!b::addFontColor(<span style="color:#d26b6b">"cornflowerblue"</span>)
 }
 addCodeC()
 {
     Send,{Asc <span style="color:#64ab8f">096</span>}
     Send,{Asc <span style="color:#64ab8f">096</span>}
     Send,{Asc <span style="color:#64ab8f">096</span>}
     Send,c
     Send,{Enter}
     Send,{Enter}
     Return
 }
 ​
 ; 快捷增加字体颜色
 addFontColor(color)
 {
     clipboard :<span style="color:#b8bfc6">=</span> <span style="color:#d26b6b">""</span> ; 清空剪切板
     Send {ctrl down}c{ctrl up} ; 复制
     SendInput {TEXT}<font <span style="color:#8d8df0">color</span><span style="color:#b8bfc6">=</span><span style="color:#d26b6b">'%color%'</span>>
     SendInput {ctrl down}v{ctrl up} ; 粘贴
     If(clipboard <span style="color:#b8bfc6">=</span> <span style="color:#d26b6b">""</span>){
         SendInput {TEXT}</font> ; Typora 在这不会自动补充
     }else{
         SendInput {TEXT}</ ; Typora中自动补全标签
     }
 }</span></span>

        Copy the above content into the file. Save and run. Choose to go directly to Typora to use. I am using the shortcut key Ctrl+Alt+K of typora's default code block. You can also replace it yourself as needed.

2. The syntax is as follows:
        Send, {Asc 096}  means to output asc码的096就是输出
        Send, and java  means to output java. This article sets
        Send in c language, and {Enter}  is equivalent to pressing the Enter key. In the same way, this article also adds color to the font.

 

3. Set and open the self-starting script file
3. Press "window logo key + R", enter shell:Common Startup, and put the file just saved into the opened startup folder!
 


Guess you like

Origin blog.csdn.net/liangfei868/article/details/125971642