<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AutoHotkey &#8211; 李辉 / Grey Li</title>
	<atom:link href="https://greyli.com/tag/autohotkey/feed/" rel="self" type="application/rss+xml" />
	<link>https://greyli.com</link>
	<description>一个编程和写作爱好者的在线记事本</description>
	<lastBuildDate>Sat, 15 Nov 2025 10:55:15 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.26</generator>

<image>
	<url>https://greyli.com/wp-content/uploads/2025/03/avatar-500-compressed-144x144.jpg</url>
	<title>AutoHotkey &#8211; 李辉 / Grey Li</title>
	<link>https://greyli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>日常快捷键配置：daily.ahk</title>
		<link>https://greyli.com/everyday-shortcuts-configuration-daily-ahk/</link>
		<comments>https://greyli.com/everyday-shortcuts-configuration-daily-ahk/#comments</comments>
		<pubDate>Fri, 26 Aug 2016 05:27:30 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[AutoHotkey]]></category>
		<category><![CDATA[效率]]></category>

		<guid isPermaLink="false">http://withlihui.com/?p=907</guid>
		<description><![CDATA[这是我学习AHK以来逐渐修改形成的一个日常快捷键集合。这个脚本让我用一种高效的方式使用我的电脑。 如果你还不熟 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><span lang="zh-CN">这是我学习</span><span lang="en-US">AHK</span><span lang="zh-CN">以来逐渐修改形成的一个日常快捷键集合。这个脚本让我用一种高效的方式使用我的电脑。</span></p>
<p><span lang="zh-CN">如果你还不熟悉</span><span lang="en-US">AutoHotkey</span><span lang="zh-CN">，可以先读一下前两篇文章：</span></p>
<ul>
<li><a href="http://greyli.com/autohotkey-automate-your-life/" target="_blank" rel="noopener">AutoHotkey——自动化你的生活</a></li>
<li><a href="http://greyli.com/autohotkey-advanced-application-and-thinking/">AutoHotkey——进阶应用与思考</a></li>
</ul>
<p>借由这个脚本，我可以：</p>
<p>1、删掉桌面上几乎所有的快捷方式图标，然后把桌面当成一个inbox来使用，所有当前需要的文件都放在上面。<br />
2、减少鼠标的过度使用；避免手指的不合理操作，比如编程时右手扭曲着按方向键移动光标。<br />
3、减少重复劳动，把选中文字——复制——点开浏览器——打开网站——粘贴——回车简化成了选中文字，按下快捷键。同时不再重复输入常用的字符。<br />
4、玩游戏时不会被开始键和输入法打扰。<br />
5、这个脚本还在不断完善和增加中。<br />
6、编程，让生活更美好。</p>
<pre class=""> /*
我的日常快捷键 daily.ahk
by 李辉（greyli.com)

目录
一、打开常用软件、文件和网页
二、发送常用字符
三、常用操作与组合键
四、小工具
*/


;;;;;;;; 一、打开常用软件、文件、文件夹和网页

;;;; 1、程序

;QQ Lite
:://qq::
Run D:\Program Files (x86)\Tencent\QQLite\Bin\QQ.exe
return

;Picasa 3
:://pi::
Run C:\Program Files (x86)\Google\Picasa3\Picasa3.exe
return

;Chrome
:://c::
IfWinExist ahk_exe chrome.exe
WinActivate
else
Run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
return

;Steam
:://st::
Run D:\Program Files (x86)\Steam\Steam.exe
return

;PotPlayer
:://pl::
IfWinExist ahk_exe PotPlayerMini64.exe
WinActivate
else
Run C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe
return

;OneNote
:://o::
IfWinExist ahk_exe OneNote.exe
WinActivate
else
Run C:\Program Files (x86)\Microsoft Office\root\Office16\ONENOTE.EXE
return

;PyCharm
:://p::
IfWinExist ahk_exe pycharm64.exe
WinActivate
else
Run D:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\bin\pycharm64.exe
return

;Vmware Player
:://v::
IfWinExist ahk_exe vmplayer.exe
WinActivate
else
Run C:\Program Files (x86)\VMware\VMware Player\vmplayer.exe
return

;ConEmu
:://ce::
Run C:\Program Files\ConEmu\ConEmu64.exe
return

;Everything
:://e::
Run C:\Program Files\Everything\Everything.exe
return

;Gimp
:://gi::
Run C:\Program Files\GIMP 2\bin\gimp-2.8.exe
return

;Evernote
:://en::
Run C:\Program Files (x86)\Evernote\Evernote\Evernote.exe
return

;Xmind
:://xm::
Run C:\Program Files (x86)\XMind\XMind.exe
return

;任务管理器
:://t::
Run taskmgr.exe
return

;控制台
:://cmd::
Run cmd
return

;截图
:://j::
Run C:\Windows\system32\SnippingTool.exe
return


;;;; 2、文件和文件夹

;桌面的inbox.txt
#i::
IfWinExist Inbox - 记事本
WinActivate
else
Run C:\Users\Administrator\Desktop\inbox.txt
return

;桌面的goals.txt
#g::
IfWinExist Goals - 记事本
WinActivate
else
Run C:\Users\Administrator\Desktop\Goals.txt
return

;Python文档
:://pd::
Run C:\Python27\Doc\python2711rc1.chm
return

;AHK文档
:://ad::
Run C:\Program Files\AutoHotkey\AutoHotkey_zh.chm
return

;下载文件夹
:://dl::
Run D:\Documents\Downloads
return

;回收站
:://hs::
Run ::{645ff040-5081-101b-9f08-00aa002f954e}
return

;projects
:://pr::
Run D:\projects
return

/*
秘密文件夹。
你可以把一个不想让别人看到的文件夹藏在很深的地方（比如下面的地址），然后使用一串热字符来打开它。
下面的字符只是个示例:P
*/
:://open::
Run C:\Program Files\CMAK\Support\2345\fpg\asd\secret\
return

;;;; 3、网页

;我的博客
:://hui::
Run http://greyli.com
return

;豆瓣
:://dou::
Run https://douban.com
return

;豆瓣fm
:://dfm::
Run https://fm.douban.com
return

;知乎
:://zhi::
Run https://zhihu.com
return

;gmail
:://gma::
Run https://gmail.com
return

;维基百科
:://wiki::
Run https://zh.wikipedia.org
return

;;hacker news
:://hack::
Run https://news.ycombinator.com/
return

;github
:://git::
Run https://github.com/lihuii
return

;Twitter
:://twi::
Run https://twitter.com/pestear
return



;;;;;;;; 二、常用字符

;;;; 1、邮箱

::@g::
Send withlihui@gmail.com
return

::@o::
Send withlihui@outlook.com
return

;;;; 2、密码（有一定的安全风险，最好不要和账号放在一起）

::@pwd1::
Send wodemima1
return

::@pwd2::
Send wodemima2
return

::@pwd3::
Send wodemima3
return


;;;; 3、其他文字

;发送当前日期
:://now::
FormatTime, CurrentDateTime,, yyyy-M-d
Send %CurrentDateTime%
return

;手机号
:://phone::
Send 1234****
return

;地址和邮编
:://addr::
Send 江苏省南京市*****（2346***）
return

;身份证号码
:://sfz::
Send 320382****
return

;银行卡号
:://bank::
Send ***
return

;我的博客
:://blog::
Send www.greyli.com
return


;;;;;;;; 三、常用操作

;用Google搜索选中的文字
!g:: 
Send ^c 
Run http://www.google.com/search?q=%clipboard% 
return 

;用淘宝搜索选中的文字
!b:: 
Send ^c 
Run http://s.taobao.com/search?q=%clipboard% 
return 

;打开一个空白记事本
!n:: 
If WinExist Untitled - Notepad 
WinActivate 
else 
Run Notepad 
return 

;使用灵格斯翻译选中的文字
!t::
Send ^c
Send !q
Send ^v{Enter}
return 

;将选中的文字发送到桌面上的Inbox.txt，然后关闭记事本
!z:: 
Send ^c
Send #i
WinWaitActive Inbox - 记事本
Send ^v{Enter}
Send ^s
WinClose Inbox - 记事本
return 

;使用Alt+j、k、l、i上下左右移动光标
!j:: Send {Left}
!l:: Send {Right}
!i:: Send {Up}
!k:: Send {Down}

;选中一行文字
!o:: Send {Home}+{End}

;选择当前位置到行首的文字 
!y:: Send +{Home} 

;选择当前位置到行末的文字 
!p:: Send +{End} 

;Alt+鼠标中键删除
^MButton:: Send {Delete}


;;;;;;;; 四、小工具

;计时器
#c:: 
InputBox UserInput, Counter, Enter a number(minutes):
IfEqual, Errorlevel, 0
{ 
 sleep UserInput * 60000
 SoundBeep
 MsgBox 时间到！
}
return

;定时关机
:://sd::
InputBox UserInput, Counter, 输入计划关机的时间（分钟）:
Run cmd
WinWaitActive ahk_class ConsoleWindowClass
time := UserInput * 60
send ^{Space} ;设置英文输入
Send shutdown{Space} -s{Space}-t{Space}%time%{Enter}
return

;取消定时关机
:://stop::
Run cmd
WinWaitActive ahk_class ConsoleWindowClass
send ^{Space} ;设置英文输入
Send shutdown{Space} -a{Space}{Enter}
return

;立刻关机
:://sdn:: 
Shutdown, 1
return

;游戏模式
;禁用Windows键，保持大写锁定
#v::
Run D:\Documents\game.ahk
;game.ahk的内容如下，退出游戏时关闭这个脚本
;LWin::return
;SetCapsLockState, AlwaysOn

/*
*last edited by 李辉 2016/08/29
*/</pre>
<div id="gtx-trans" style="position: absolute; left: -2px; top: 7703.15px;">
<div class="gtx-trans-icon"> </div>
</div>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/everyday-shortcuts-configuration-daily-ahk/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>AutoHotkey——进阶应用与思考</title>
		<link>https://greyli.com/autohotkey-advanced-application-and-thinking/</link>
		<comments>https://greyli.com/autohotkey-advanced-application-and-thinking/#comments</comments>
		<pubDate>Fri, 12 Aug 2016 13:59:54 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[AutoHotkey]]></category>

		<guid isPermaLink="false">http://withlihui.com/?p=870</guid>
		<description><![CDATA[简单易学的AHK 作为一门脚本语言，本来可以按照通常的学习路径来学习：变量、控制语句、函数……但是因为它本身的 [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>简单易学的AHK</h2>
<p>作为一门脚本语言，本来可以按照通常的学习路径来学习：变量、控制语句、函数……但是因为它本身的特点，对于只想来满足自己的某些需求的人来说，也可以只从需求出发，学习需要的内容。同时，学习AHK可以得到很及时的反馈，让你很容易从中获得一些成就感。相比其他语言，你要做出一个GUI界面，恐怕需要一段时间的学习，当其他人还在控制台的黑窗口里接受用户输入的时候，使用AHK的你只需要一个MsgBox或是InputBox就可以弹出窗口来实现用户交互了。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>脚本精选</h2>
<p>（大部分来自帮助文档及官方论坛）</p>
<p><a class="postlink" href="http://www.appinn.com/category/autohotkey/" target="_blank">小众软件 AutoHotkey 专区</a>：提供了一些贴合国内实际的脚本。</p>
<p><a href="https://autohotkey.com/boards/viewtopic.php?t=4267" target="_blank">AHK 快餐店系列索引</a>：包含在上一篇文末推荐的懒人包里。</p>
<p><a href="http://www.donationcoder.com/Software/Skrommel/" target="_blank">1 Hour Software (1 小时软件) &#8212; 作者: skrommel</a>: 这是大量有用的脚本集合, 带有简短的说明和截图地专业呈现出来.</p>
<p><a href="http://file.autohotkey.net/Titan/" target="_blank">Titan 的脚本</a>: 这个集合包含许多有用的脚本, 例如：<br />1) XML 阅读器/写入器: 通过简单的界面来获取和写入 XML 文件中的值, 就像 JavaScript.<br /> 2) 锚: 让 GUI 控件紧贴可调整大小的 GUI 窗口的右边或底部的边缘.<br />3) 函数: 包装函数的集合, 其中的每个函数是从含有 OutputVar 的 AutoHotkey 命令包装而成.<br />4) 天气: 在托盘菜单中显示当前天气状况或在富 GUI 中显示预报。</p>
<p><a href="http://www.autohotkey.com/forum/topic12338.html" target="_blank">Toralf 的脚本</a>: 这个集合包含了有用的脚本, 例如：<br />1) AHK Window Info: 显示窗口, 控件等等的信息.<br />2) 电子节目指南: 浏览您当地的电视节目/时间表 (支持多个国家).<br />3) 自动语法整理器: 改变脚本中命令的缩进和大小写形式以使它使用一致的格式/风格。</p>
<p>Sean 的脚本: 包含有用的脚本, 例如：<br />1) <a href="http://www.autohotkey.com/forum/topic18033.html">网络下载/上传流量计</a>: 在小且置顶的进度条中显示网络下载/上传的流量 (单位为 KB).<br /> 2) <a href="http://www.autohotkey.com/forum/topic16823.html">StdoutToVar</a>: 重定向命令或应用程序的输入到脚本的变量中.<br />3) <a href="http://www.autohotkey.com/forum/topic18146.html">截取屏幕的矩形区域</a>: 用来截取部分屏幕并保存为文件 (BMP/JPG/PNG/GIF/TIF) 的函数. 它也能截取透明窗口和鼠标指针.<br />4) <a href="http://www.autohotkey.com/forum/topic18167.html">颜色放大器/选取器</a>: 放大光标周围的区域, 允许选取单个像素并识别它的颜色.<br />5) <a href="http://www.autohotkey.com/wiki/index.php?title=Internet_Explorer_Control" target="_blank">嵌入 Internet Explorer 控件</a>: 嵌入 MSIE 控件到脚本的 GUI 窗口. 此控件能进行网页显示或其他兼容于浏览器的功能。<br /><a href="https://autohotkey.com/docs/scripts/NumpadMouse.htm" target="_blank"><br />Using Keyboard Numpad as a Mouse (把小键盘作为鼠标使用) &#8212; 作者: deguix</a>: 此脚本用您的键盘来实现鼠标操作, 几乎相当于真正的鼠标 (在一些任务中甚至更方便). 它支持多达五个鼠标按钮和鼠标滚轮的转动. 它还具有能自定义移动速度, 加速和 &#8220;轴反转&#8221; 的特点。<br /><a href="http://www.autohotkey.com/forum/topic8795.html" target="_blank"><br />SKAN 的 N 个技巧提示</a>：包含实实用效果和常用功能的示例代码和技术。<br /><a href="http://www.autohotkey.com/forum/forum-2.html"><br />论坛的 Scripts &amp; Functions 版块</a>: 这是一个近 1000 个可运行脚本和函数的可搜索集合. 由 AutoHotkey 用户建立和维护, 这个存档每天都在增长和改进。<br /><a class="postlink" href="http://rosettacode.org/wiki/Category:AutoHotkey" target="_blank"><br />Rosetta Code AutoHotkey Category</a>：演示了许多独辟蹊径的用法，很有趣。<br /><a class="postlink" href="http://www.donationcoder.com/forum/index.php?topic=3461" target="_blank"><br />JGPaiva’s AutoHotkey Coding Snacks</a>：众多简单实用的小工具。</p>
<p><strong>一键登录网站（以登录淘宝为例）</strong>：因为淘宝现在使用账号密码登录需要点击一下右上角的按钮，所以先使用上面那个脚本获取屏幕坐标，然后根据自身情况调整参数就可以了。其他网站需要作相应的调整。</p>
<pre class="">;获取鼠标坐标，用于下面的登录事件
:://xy::
MouseGetPos, xpos, ypos 
Msgbox, The cursor is at X%xpos% Y%ypos%. 
return

;一键登录淘宝
:://tb::
Run https://login.taobao.com
WinWaitActive 淘宝网 - 淘！我喜欢 - Google Chrome
sleep 5000 ;视网速调整等待的时间（毫秒）
Click 1410, 378 ;不同分辨率的屏幕坐标不同，可使用上面的脚本获取屏幕坐标
sleep 100
send ^{Space} ;设置英文输入
Send {Tab}1515******* ;替换你的用户名
Send {Tab}****** ;替换你的密码
MouseClickDrag, left, 1645, 634, 1428, 634 ;拖动验证滑块
Send {Enter}
return</pre>
<p>&nbsp;</p>
<h2>AHK和Python的比较（GUI）</h2>
<p>和Python相比，AHK更像是搭积木。你可以用极少的入门知识和查阅帮助文档来制作自己想要的GUI工具。以一个计时器为例，我同时用Python（Tkinter）和Autohotkey写了两个简单的计时器。用户输入一个时间数（分钟），计时结束后会弹窗提示时间到了。下面是各自的代码</p>
<p><strong>Python：</strong></p>
<pre class="">import tkMessageBox
from time import sleep
from Tkinter import Tk, Entry, Label, Button, X, Y

def time_counter():
    time = Entry.get(time_et)
    root.destroy()
    sleep(int(time) * 60)
    label = tkMessageBox.showinfo("Attention!", "Time Over!")

root = Tk()
root.title("Counter")
prompt_lb = Label(root, text="Enter a number(mintutes):")
time_et = Entry(root)
start_bt = Button(root, text="Start", command=time_counter)
prompt_lb.pack()
time_et.pack()
start_bt.pack()

root.mainloop()</pre>
<p>运行结果：</p>
<p><div id="attachment_872" style="width: 186px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/08/python1.jpg" rel="attachment wp-att-872"><img class="size-full wp-image-872" src="http://greyli.com/wp-content/uploads/2016/08/python1.jpg" alt="python运行效果" width="176" height="119" srcset="https://greyli.com/wp-content/uploads/2016/08/python1.jpg 176w, https://greyli.com/wp-content/uploads/2016/08/python1-150x101.jpg 150w" sizes="(max-width: 176px) 100vw, 176px" /></a><p class="wp-caption-text">为了避免出现控制台窗口弹出，要把文件保存成.pyw</p></div> <div id="attachment_873" style="width: 437px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/08/python2.jpg" rel="attachment wp-att-873"><img class="size-full wp-image-873" src="http://greyli.com/wp-content/uploads/2016/08/python2.jpg" alt="Python运行效果" width="427" height="249" srcset="https://greyli.com/wp-content/uploads/2016/08/python2.jpg 427w, https://greyli.com/wp-content/uploads/2016/08/python2-150x87.jpg 150w, https://greyli.com/wp-content/uploads/2016/08/python2-300x175.jpg 300w" sizes="(max-width: 427px) 100vw, 427px" /></a><p class="wp-caption-text">因为关闭了主窗口（root），消息窗口又在左边新建了一个空白窗口</p></div></p>
<p>&nbsp;</p>
<p><strong>AutoHotkey：</strong></p>
<pre class="">InputBox UserInput, Counter, Enter a number(minutes):
IfEqual, Errorlevel, 0
{   
    sleep UserInput * 60000
    SoundBeep
    MsgBox Time Over！
}
return</pre>
<p>&nbsp;</p>
<p>运行结果：</p>
<div id="attachment_874" style="width: 403px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/08/ahk1.jpg" rel="attachment wp-att-874"><img class="size-full wp-image-874" src="http://greyli.com/wp-content/uploads/2016/08/ahk1.jpg" alt="ahk运行效果" width="393" height="211" srcset="https://greyli.com/wp-content/uploads/2016/08/ahk1.jpg 393w, https://greyli.com/wp-content/uploads/2016/08/ahk1-150x81.jpg 150w, https://greyli.com/wp-content/uploads/2016/08/ahk1-300x161.jpg 300w" sizes="(max-width: 393px) 100vw, 393px" /></a><p class="wp-caption-text">默认的窗口布局很美观</p></div>
<p><a href="http://greyli.com/wp-content/uploads/2016/08/ahk2.jpg" rel="attachment wp-att-871"><img class="aligncenter size-full wp-image-871" src="http://greyli.com/wp-content/uploads/2016/08/ahk2.jpg" alt="ahk运行效果" width="156" height="175" srcset="https://greyli.com/wp-content/uploads/2016/08/ahk2.jpg 156w, https://greyli.com/wp-content/uploads/2016/08/ahk2-134x150.jpg 134w" sizes="(max-width: 156px) 100vw, 156px" /></a></p>
<p>&nbsp;</p>
<p>代码的行数倒是次要，从学习量来说，后者大部分函数都帮你封装好了，只要你填几个所需的值就搞定了，而且默认的尺寸位置也比前者美观的多。在转换成exe文件上，Autohotkey也很方便。Autohotkey里甚至还有现成的splash函数。当然，这只是在简单的应用上，复杂的应用AHK就未必能很好的胜任了。</p>
<p>不同语言都有各自的优缺点。但对于使用Windows系统，不想花费大量精力学习编程，而又想制作些小工具满足日常需求的人，简单易学的Autohotkey是个好选择（说不定你对编程的兴趣就这样产生了）。</p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/autohotkey-advanced-application-and-thinking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AutoHotkey——自动化你的生活</title>
		<link>https://greyli.com/autohotkey-automate-your-life/</link>
		<comments>https://greyli.com/autohotkey-automate-your-life/#comments</comments>
		<pubDate>Mon, 08 Aug 2016 15:27:37 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[AutoHotkey]]></category>

		<guid isPermaLink="false">http://withlihui.com/?p=854</guid>
		<description><![CDATA[文明通过增加我们不假思索就能完成的的重要操作的数目而取得进步。——阿尔弗雷德 · 诺斯 · 怀特海 &#038;nbsp [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="text-align: left;">文明通过增加我们不假思索就能完成的的重要操作的数目而取得进步。<br />——阿尔弗雷德 · 诺斯 · 怀特海</p>
<p><img class="aligncenter size-full wp-image-856" src="http://greyli.com/wp-content/uploads/2016/08/ahk_logo.jpg" alt="ahk_logo" width="517" height="78" srcset="https://greyli.com/wp-content/uploads/2016/08/ahk_logo.jpg 517w, https://greyli.com/wp-content/uploads/2016/08/ahk_logo-150x23.jpg 150w, https://greyli.com/wp-content/uploads/2016/08/ahk_logo-300x45.jpg 300w" sizes="(max-width: 517px) 100vw, 517px" /></p>
<p>&nbsp;</p>
<p>和上面那句话相对应的，我们应该<strong>尽量减少重复的没有价值的操作，或是降低这种操作的成本</strong>。为了这个念头，我们使用makefile来编译程序，学习各种编程语言来减少重复劳动，在开发软件时加入快捷键支持。根据二八原则，我们在避免重复劳动上投入20%的精力可以为我们带来80%的效率提升。我们应该把这20%的时间和精力用来学习AutoHotkey。</p>
<p>AutoHotkey是一款免费的、Windows平台下开放源代码的热键脚本语言。从名字可以看出来，它可以用来设置热键。但是因为它是一门脚本语言，所以就不止设置快捷键那么简单了。帮助文档这样介绍它的功能：</p>
<ul>
<li>通过发送键盘键击和鼠标点击自动化几乎所有的操作。您可以手工编写宏或者使用宏录制器。</li>
<li>为键盘，游戏杆和鼠标创建热键。几乎任何按键、按钮或组合键都可以设置为热键。</li>
<li>在您键入缩写时扩展缩写。例如，键入 &#8220;btw&#8221; 能自动地生成 &#8220;by the way&#8221;。</li>
<li>创建自定义的数据输入表格、用户界面和菜单栏。详见图形用户界面。</li>
<li>重新映射您键盘、游戏杆和鼠标上的按键和按钮。</li>
<li>通过WinLIRC客户端脚本对手执遥控器的信号作出反应。</li>
<li>运行现有的 AutoIt v2 脚本，并用新功能增强它们。</li>
<li>将任何的脚本转换为EXE文件，使其在没有安装 AutoHotkey 的计算机上也能运行。</li>
</ul>
<p>很早就把它下载下来，却一直没有用。直到上次要用一个简易键盘来控制电脑的时候，才去学习了一下。这时才发现它真是太强大了。这个简单的教程会帮助你从实践出发快速的熟悉这门语言。建议你<strong>按照下面的学习步骤学习，不要遗漏每一项</strong>。</p>
<p>&nbsp;</p>
<h2>最简流程示例</h2>
<ol>
<li>到<a href="http://www.autohotkey.com">www.autohotkey.com</a>下载或<a href="https://www.autohotkey.com/download/1.1/AutoHotkey112401_Install.exe" target="_blank">点击这里</a>下载（AutoHotkey1.1），然后安装。</li>
<li>使用编辑器或记事本新建一个脚本文件，格式为<strong>.ahk</strong>，编码格式为<strong>UTF-8</strong>。</li>
<li>编辑脚本，在脚本中写入下面这行：
<pre class=""> #h::Run www.greyli.com</pre>
</li>
<li>保存后双击运行。</li>
<li>这时按下Windows键和h键就会打开我的博客。</li>
</ol>
<p>在上面这个命令中，符号<strong>#</strong>表示Windows键，#后紧跟着<strong>h</strong>表示组合键。符号<strong>::</strong>用来分隔热键和命令（左边是热键，右边是命令）。<strong>Run</strong>命令用来打开一个文件或网页，中间空一个空格。</p>
<p>&nbsp;</p>
<h2>基本术语</h2>
<ul>
<li><strong>脚本/宏（Script）</strong>：你要编辑的一个格式后缀为<strong>.ahk</strong>的纯文本文件（编码格式为<strong>UTF-8</strong>）。你把代码写进这个脚本里，双击执行后，你的热键就生效了。</li>
<li><strong>热键（hotkey）</strong>：用来触发操作的按键或组合键，也就是快捷键。</li>
<li><strong>命令</strong>：你为某个热键指定的一个动作（action），比如打开程序，打开网页等。</li>
<li><strong>热字串（hotstring）</strong>：类似于热键，当你输入热字串并按下回车或空格后触发相应的命令。用过老型号的黑莓的人对热键和热字串一定不陌生。</li>
<li><strong>宏录制器（AutoScriptWriter）</strong>：可以录制回放你的操作的工具，非常适合新手入门学习。目前AutoHotke_L版本已去除，详情请见<a href="https://zhuanlan.zhihu.com/p/19772251?refer=autohotkey" target="_blank">这里</a>。</li>
<li><strong>多行热键</strong>：当通过热键触发多个命令时，这时的格式是命令从第二行开始，每个命令一行，最后以占据一行的return结束。</li>
</ul>
<pre class="">#h::
RunWait Notepad
Msgbox Goodbye!
return</pre>
<ul>
<li><strong>参数</strong>：自定义的数值，传递给命令执行，比如sleep后面的时间数就是参数。参数与命令通过空格或逗号隔开，多个参数使用逗号隔开。</li>
<li><strong>注释（comment）</strong>：注释是用来对你的代码进行解释和说明的文字。单行的注释以<strong>;</strong>开头，多行注释用<strong>/*</strong>和<strong>*/</strong>括住。</li>
</ul>
<pre class="">;这是单行注释
/* 这里 
是 
多行注释 */</pre>
<h2> </h2>
<h2>常用命令</h2>
<table>
<tbody>
<tr>
<td style="text-align: center;">
<p>Run</p>
</td>
<td style="text-align: left;">
<p>用来打开一个程序、文档、网页或者快捷方式</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>Send</p>
</td>
<td style="text-align: left;">
<p>发送键击或一段字符</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>Msgbox</p>
</td>
<td style="text-align: left;">
<p>消息窗口</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>Inputbox</p>
</td>
<td style="text-align: left;">
<p>用户输入窗口</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>Sleep</p>
</td>
<td style="text-align: left;">
<p>脚本等待指定的时间，然后执行下面的命令。后面接时间参数（毫秒）。</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>Click</p>
</td>
<td style="text-align: left;">
<p>在指定的位置点击鼠标</p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2>常用符号</h2>
<table>
<tbody>
<tr>
<td style="text-align: center;">
<p>#</p>
</td>
<td style="text-align: left;">
<p>Windows</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>^</p>
</td>
<td style="text-align: left;">
<p>Control</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>!</p>
</td>
<td style="text-align: left;">
<p>Alt</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>+</p>
</td>
<td style="text-align: left;">
<p>Shift</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>&amp;</p>
</td>
<td style="text-align: left;">
<p>用来连接两个按键组成组合键（使用除了上面四个按键外）</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>&lt;和&gt;</p>
</td>
<td style="text-align: left;">
<p>分别表示成对按键中左边和右边的的按键</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<p>Tab和Enter等</p>
</td>
<td style="text-align: left;">
<p>没有特殊符号。使用Send命令时用大括号括起来以和字符区分开。</p>
</td>
</tr>
</tbody>
</table>
<p>注：前四个为修饰键，可以和其他按键直接相连（比如写成#a），其他按键要做修饰键时需要用&amp;连接（比如a&amp;b）。</p>
<h2> </h2>
<h2>基础应用示例</h2>
<h3>为常用软件、网站设置快捷键</h3>
<p>按下Windows和k打开Notepad++：</p>
<pre class="">#k::Run D:\Program Files (x86)\Notepad++\notepad++.exe</pre>
<p>按下Windows和h，或输入hui后按下回车或空格（推荐使用空格）可以打开我的博客：</p>
<pre class="">#h::Run www.greyli.com
;下面使用热字串运行同样的命令，这时要采用多行分隔
::hui:: 
Run www.greyli.com
return</pre>
<p>按下Alt和m打开一组网页和程序：</p>
<pre class="">!m::
Run www.google.com
Run http://fm.douban.com
Run D:\Program Files (x86)\Notepad++\notepad++.exe
return</pre>
<p>建议用热字串来启动常用的程序，把快捷键留给常用的操作。为了防止打字时冲突可以在热字串前加特定的符号，比如斜线。<strong>使用热字串启动命令要使用多行热键格式。</strong></p>
<p>&nbsp;</p>
<h3>用热键或热字串保存常用文字</h3>
<p>按下Alt和k发送我的签名：</p>
<pre class="">!k::
Send Sincerely,{Enter}Richard Hui.
return</pre>
<p>写下@g后按下空格或回车，自动转换为我的邮箱</p>
<pre class="">::@g::withlihui@gmail.com</pre>
<p>按下Alt键和g后填入我的账户和密码并登录（先把光标点在第一个输入框里）。</p>
<pre class="">!g::
Send withlihui@qq.com {Tab}mimashi123 {Enter}
return</pre>
<p>（下一篇会有一个一键登录网站的示例）</p>
<h2> </h2>
<h2>Tips与建议</h2>
<ul>
<li>命令不区分大小写。</li>
<li>所有的符号均为<strong>英文符号</strong>。</li>
<li>一个脚本里可以写入多个热键。</li>
<li>发送的字符里包含的按键前要有一个空格。</li>
<li>不分配热键的命令将从上往下依次执行。</li>
<li>修改后的脚本要重新运行（双击执行脚本文件）才能生效。</li>
<li>开机运行脚本：把脚本的快捷方式放到启动文件夹（开始菜单—所有程序—启动）</li>
<li>中文支持，安装Autohotkey_L（1.1）版本。</li>
<li>编辑器推荐：<a href="http://fincs.ahk4.net/scite4ahk/" target="_blank">SciTE4AutoHotkey</a></li>
</ul>
<p><strong>更有趣和复杂的的进阶应用请见下一篇。</strong></p>
<p>&nbsp;</p>
<h2>继续前进</h2>
<p>你可以从这些地方继续学习：</p>
<ul>
<li>必备：帮助文档（<a href="https://sourceforge.net/projects/ahkcn/" target="_blank">中文文档下载</a>/<a href="https://autohotkey.com/docs/AutoHotkey.htm" target="_blank">在线文档</a>/<a href="http://ahkcn.sourceforge.net/docs/AutoHotkey.htm" target="_blank">在线中文</a>）</li>
<li>新手教程包：<a href="http://www.appinn.com/autohotkey-all-in-one/" target="_blank">AHK懒人包</a></li>
<li><a href="https://autohotkey.com/boards/index.php" target="_blank">官方论坛</a>及<a href="https://autohotkey.com/boards/viewforum.php?f=26" target="_blank">中文子论坛</a></li>
<li>中文论坛：<a href="http://ahk8.com" target="_blank">ahk8.com</a></li>
<li>知乎专栏：<a href="https://zhuanlan.zhihu.com/autohotkey" target="_blank">AutoHotkey之美<br /></a></li>
<li><a href="https://autohotkey.com/boards/viewtopic.php?f=29&amp;t=1099" target="_blank">AutoHotkey 学习指南</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/autohotkey-automate-your-life/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
