AutoHotKey是一个漂亮的工具。在今年年初在Help Desk Geek上发表的一篇文章中,我解释了如何(how to disable keys in Windows)使用AutoHotKey在 Windows 中禁用键。但是,这只是您可以使用此软件实现的无数技巧之一。
只需几行代码,您就可以创建一些将在未来几年改变您使用键盘和 PC 的方式的东西。十多年来,我的Windows启动中一直有一个不断变化的(Windows)AutoHotKey脚本——如果没有它启用的一些功能,我会完全迷失方向。
让我与您分享五个日常 PC 使用中最有用的AutoHotKey脚本。虽然我在上述文章中对使用AutoHotKey安装、设置和创建脚本进行了更详细的说明,但您只需下载应用程序(download the application),打开文本编辑器,然后保存并运行以下任何脚本即可让他们立即工作。
重新利用功能键
对于我们中的许多人来说,功能键 ( F1–F12 ) 最终完全没有使用。根据您的键盘布局,与它们的功能相比,到达这一行键的范围可能是一个令人不舒服的权衡。对于其他人来说,这些密钥可能根本没用。
我最喜欢用功能键做的事情是将它们设置为启动我经常使用但不经常打开的程序。记事本(Notepad)就是一个很好的例子。
F1::Run "%WINDIR%\notepad.exe"
上面的脚本设置F1键以在任何现代版本的Windows中启动(Windows)记事本(Notepad)。如您所见,文件路径支持直接路径或Windows环境变量之一。如果您使用多个不同版本的Windows ,则使用环境变量是理想的。
使用特殊字符
作为 em dash 的忠实粉丝,令人沮丧的是,绝大多数键盘本身并不支持它——所以,让我们来制作它们吧。
!-::Send {—}
Alt + –键时,上面的脚本将插入一个破折号。Alt是用于热键的绝佳修饰符,因为与Shift和Ctrl相比,它的使用要少得多。
另一个可靠的想法是将省略号绑定到Alt + .,可以使用以下单行执行:
!.::Send {…}
作为一名作家,使用AutoHotKey轻松访问标点符号为我节省了大量时间。
控制你的音量
不是每个人都有支持多媒体键的键盘,但这不应该阻止任何人轻松控制音乐的乐趣。
我最喜欢的实现方式是使用Shift + Page Up键调高音量,Shift + Page Down键调低音量,Shift + Pause键静音(可切换)。
+PgUp::Send {Volume_Up}
+PgDn::Send {Volume_Down}
+Pause::Send {Volume_Mute}
当然,您可能使用的键盘布局不太实用。通过查看AutoHotKey 的键列表,(AutoHotKey’s list of keys)您可以根据自己的喜好简单地更改任何键名称。
将窗口固定在顶部
这可能是我最喜欢的AutoHotKey单行代码。将窗口固定在其他窗口之上的功能可以让您在工作、尝试欣赏电影或在办公桌上进行大量其他活动时避免头疼的问题。
^Space::Winset, AlwaysOnTop, , A
如果您有一台合适的显示器但没有双显示器设置,我发现这个特别有用。使用上面的脚本,该计算器将不再被埋在所有其他窗口下!只需(Just)按Ctrl + Space即可固定(或取消固定)一个窗口。
立即搜索 Google
如果您是每天都在使用计算机的人,那么您在Google上搜索您在与朋友交谈或上网时遇到的术语的时间可能比您注意到的要多。
但是,选择文本、复制文本、打开新标签、将文本粘贴到地址栏中,然后按Enter键是一个非常漫长的过程。为什么不让它更简单呢?
^+c::
Send ^c
Sleep 50
Run "http://www.google.com/search?q=%clipboard%"
return
只要您突出显示要搜索的文本,上面的脚本就允许Ctrl + Shift + CGoogle 搜索(Google Search)页面将在您的默认浏览器中显示。
如果您不能只选择其中一个脚本,那么有一个好消息:您只需将它们中的每一个粘贴到新的一行,它们就会无缝地协同工作!
只要您没有更改热键来创建冲突,在一个AHK文件中同时使用上述所有五个脚本应该可以正常工作。
5 Simple AutoHotKey Scripts To Make Your Life Easier
AutoHotKey is a beautiful tool. In an article published near the start of the year over at Help Desk Geеk, I explained how to disable keys in Windows using AutoHotKey. However, that’s just one of the countless tricks that you can achieve with this software.
With just a few lines of code, you can create something that will change the way you use your keyboard and PC for years to come. For more than a decade now, I’ve had an ever-changing AutoHotKey script sitting in my Windows startup – without some of what it enables, I’d be completely lost.
Let me share with you five of the most useful AutoHotKey scripts for everyday PC use. While I laid out a more detailed explanation for installing, setting up, and creating scripts using AutoHotKey in the aforementioned article, all you have to do is download the application, bring up a text editor, and save and run any of the following scripts to get them working immediately.
Repurpose The Function Keys
For many of us, the function keys (F1–F12) end up completely unused. Depending on your keyboard layout, the reach to this row of keys could be an uncomfortable trade-off compared to their functionality. For others, these keys may simply be useless.
My favorite thing to do with the function keys is to set them to launch programs that I often use but don’t often keep open. Notepad is a great example.
F1::Run "%WINDIR%\notepad.exe"
The above script sets the F1 key to launch Notepad in any modern version of Windows. As you can see, the file path supports both a direct path or one of Windows environment variables. Using environment variables is ideal if you use multiple different versions of Windows.
Use Special Characters
As a massive fan of the em dash, it’s frustrating that the vast majority of keyboards don’t natively support it—so, let’s make them.
!-::Send {—}
The above script will insert an em dash when the Alt + – keys are pressed. Alt is a great modifier to use for your hotkeys because it sees much less use compared to Shift and Ctrl.
Another solid idea is to bind ellipsis to Alt + ., which can be performed with the following one-liner:
!.::Send {…}
As a writer, using AutoHotKey for easy access to punctuation marks saves me an incredible amount of time.
Control Your Volume
Not everyone has a keyboard that supports multimedia keys, but that shouldn’t stop anyone from the joys of controlling their music with ease.
My favorite way of implementing this is by using the Shift + Page Up key to turn the volume up, Shift + Page Down key to turn the volume down, and Shift + Pause key to mute (toggleable).
+PgUp::Send {Volume_Up}
+PgDn::Send {Volume_Down}
+Pause::Send {Volume_Mute}
Of course, there’s the chance that you may be on a keyboard where that layout isn’t very practical. You can simply change any of the key names above to your liking by checking out AutoHotKey’s list of keys.
Pin a Window On Top
This might be my favorite AutoHotKey one-liner of them all. The ability to pin a window on top of others is one that can save you a major headache while working, trying to enjoy a movie, or plenty of other activities at your desk.
^Space::Winset, AlwaysOnTop, , A
I find this one to be especially useful if you have a decent-sized monitor but not a dual-monitor setup. With the script above, that calculator will no longer get buried under all of your other windows! Just press Ctrl + Space to pin (or unpin) a window.
Search Google Instantly
If you’re someone who uses your computer every single day, you probably spend more time than you notice searching Google for terms that you come across while talking to friends or surfing the web.
However, selecting text, copying it, opening a new tab, pasting the text into your address bar, and pressing the Enter key is an awfully long process. Why not make it simpler?
^+c::
Send ^c
Sleep 50
Run "http://www.google.com/search?q=%clipboard%"
return
The script above allows the Ctrl + Shift + C hotkey to do all of that in a single hotkey as long as you’ve highlighted the text you want to search for. The Google Search page will be brought up in your default browser.
If you can’t pick just one of these scripts, there’s good news: All you have to do is paste each of them on a new line, and they’ll all work seamlessly together!
As long as you haven’t altered the hotkeys to create conflicts, using all five of the above scripts at once within a single AHK file should work perfectly fine.