AutoHotkey(简称AHK)是一款强大的开源自动化脚本语言和工具,用于自动化计算机上的各种任务。可以使用AHK创建自定义快捷键,以简化复杂的任务,例如启动应用程序、切换窗口、执行特定操作等。AutoHotkey是免费的开源软件,可在Windows操作系统上运行。AHK对于自动化日常计算机任务非常有用,特别是对于那些喜欢自定义计算机操作和提高工作效率的人来说,它是一个强大的工具。
由于公司的电脑不能装Quicker和按键精灵,所以要想实现自定义快捷键,AutoHotkey是一个非常好的选择,因为它的安装不需要管理员权限。
如果大家想深入研究,可以参考这份教学链接:AutoHotkey 初学者向导 | AutoHotkey v1
我这里直接给大家分享我常用的几个脚本:
^Down::
Send {Volume_Down}
Return
^Up::
Send {Volume_Up}
Return
键盘上的右ctrl键离方向键很近,我这里设置按住ctrl + 上方向键能够增加音量,按住ctrl + 下方向键能够降低音量
~LButton & XButton1:: ; ~ allows the LButton to keep its original function
Send, ^v ; Sends CTRL+V, triggering the paste action
return
如果你的鼠标有侧键,那么你可以用这个命令实现按住鼠标左键然后按鼠标后退侧键实现粘贴功能。
~LButton & RButton:: ; ~ allows the LButton to retain its original function
Send, ^c ; Sends CTRL+C, triggering the copy action
return
同样地,也可以实现类似quicker的复制功能,按住鼠标左键再按右键,可以复制。
XButton1::
KeyWait, XButton1, T0.5 ; Waits for 0.5 seconds to check for a long press
if ErrorLevel ; If the button was held down for 0.5 seconds or more
{
Send {Ctrl down} ; Sends Ctrl down key (holds Ctrl key down)
}
else ; If the button was NOT held down for 0.5 seconds
{
Send {XButton1} ; Sends the original function of XButton1
}
return
XButton1 up:: ; When the XButton1 is released
Send {Ctrl up} ; Sends Ctrl up key (releases Ctrl key)
return
知道ctrl+鼠标滚轮可以缩放吗?这里可以完全用鼠标实现,这段代码的意思是长按鼠标后退侧键0.5秒视为ctrl键按下,当然,侧键得一直按住,这样再使用滚轮就可以实现缩放了,松开侧键后,视为ctrl键释放。而轻按鼠标后退侧键还是原本的后退功能。
~MButton::
If (A_PriorHotkey = "~MButton" AND A_TimeSincePriorHotkey < 200)
{
Send, ^{PrintScreen} ; Sends CTRL+PrtSc, triggering the screenshot action
}
return
截屏也可以完全用鼠标!这里配合ShareX截图软件非常好用,ShareX的下载链接在这里:ShareX - The best free and open source screenshot tool for Windows
这款截图软件也是可以绕过管理员权限安装的。
这里快速双击鼠标中键就可以唤醒截图功能。同样地,这段代码不会影响鼠标中键的日常使用功能
这里给大家汇总一下:
!Enter::
Send ^{Enter}
Return
^Down::
Send {Volume_Down}
Return
^Up::
Send {Volume_Up}
Return
~LButton & XButton1:: ; ~ allows the LButton to keep its original function
Send, ^v ; Sends CTRL+V, triggering the paste action
return
~LButton & RButton:: ; ~ allows the LButton to retain its original function
Send, ^c ; Sends CTRL+C, triggering the copy action
return
~MButton::
If (A_PriorHotkey = "~MButton" AND A_TimeSincePriorHotkey < 200)
{
Send, ^{PrintScreen} ; Sends CTRL+PrtSc, triggering the screenshot action
}
return
End::
If (A_PriorHotkey = A_ThisHotkey and A_TimeSincePriorHotkey < 500)
{
Click
Send, ^{End}
}
Return
XButton1::
KeyWait, XButton1, T0.5 ; Waits for 0.5 seconds to check for a long press
if ErrorLevel ; If the button was held down for 0.5 seconds or more
{
Send {Ctrl down} ; Sends Ctrl down key (holds Ctrl key down)
}
else ; If the button was NOT held down for 0.5 seconds
{
Send {XButton1} ; Sends the original function of XButton1
}
return
XButton1 up:: ; When the XButton1 is released
Send {Ctrl up} ; Sends Ctrl up key (releases Ctrl key)
return