AutoHotkey —— 自定义热键编辑软件(设置Typora字体颜色快捷键应用)

一、安装 AutoHotkey

官方安装链接:https://autohotkey.com/download/ahk-install.exe

  1. 【home】Tab页:选择【Custom lnstallation】自定义安装;
  2. 【version】Tab页:选择版本,与操作系统一致即可(我选择Unicode 64-bit);
  3. 【location】Tab页:选择软件安装位置
  4. 点击【next】继续安装;
  5. 点击【install】软件就会安装;
  6. AutoHotkey安装完成,点击exit退出软件安装,点击其他可以打开软件帮助界面。

二、配置

在桌面新建一个 MyHotkeyScript.ahk文件,一记事本方式打开并复制以下代码:

; 分号以及分号后的内容代表注释,以下为代码解释
#IfWinActive ahk_exe Typora.exe
{
	; alt+0 黑色
    !0::addFontColor("black")
    ; alt+1 红色
    !1::addFontColor("red")
    ; alt+2 橙色
    !2::addFontColor("orange")
    ; alt+3 黄色
    !3::addFontColor("yellow")
    ; alt+4 绿色
    !4::addFontColor("green")    
    ; alt+5 青色
    !5::addFontColor("cyan") 
	; alt+6 浅蓝色
    !6::addFontColor("cornflowerblue")
    ; alt+7 紫色
    !7::addFontColor("purple")
}

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

三、运行

  1. 双击文件运行【用AutoHotkey运行】,打开AutoHotkey程序看见以下内容;
Script lines most recently executed (oldest first).  Press [F5] to refresh.  The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0).  The bottommost line's elapsed time is the number of seconds since it executed.

---- C:\Users\liang\Desktop\MyHotkeyScript.ahk
003: {
005: Return (58.16)

Press [F5] to refresh.
  1. 重启Typora,测试快捷键是否有效,Alt + 01234567 分别是各种颜色。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值