AutoHotKet相关
AHK中文文档 https://wyagd001.github.io/zh-cn/docs/Hotstrings.htm
热字串
AHK中文文档 https://wyagd001.github.io/zh-cn/docs/Hotstrings.htm
; 例如
:*si:wqz::wwwqqqzzz中文也行
:*:bb::SoundBeep,523,500
; 全局设置: #Hoststring c * ;,对接下来的热字符生效
; 局部设置: :*:ftw::for the worth
; 更改终止符: #Hotstring EndChars -()[]{}:;'"/\,.?!`n `t
; 0表示取消设置: :*0:ftw::for the worth
; r raw 不转义
; * 不用终止符来触发
; O 终止符触发时忽略键入终止符
; b0 不退格
; c 区分大小写
; c1 让替换字符串遵循热字串的大小写首字母大写模式
; SI SendInput模式 直接替换避免键击穿插
; SP SendPlay模式 它可以让热字串运行在更大范围的游戏中.
; SE SendEvent模式 在比 [1.0.43] 早的版本中这是默认选项.
; K 设置延迟
; P 设置优先级
; T 文本模式,不转换文本为命令
; X 接受命令
; z 触发后重置热字串识别器(可以避免重复识别)
--
send run 和其他
; send:https://wyagd001.github.io/zh-cn/docs/commands/Send.htm#keynames
;# Win(Windows 徽标键)
;! Alt
;^ Ctrl
;+ Shift
;& 用于连接两个按键(含鼠标按键) 合并成一个自定义热键.
;< 使用成对按键中左边的那个. 例如 <!a 相当于 !a, 只是使用左边的 Alt 才可以触发.>
;* 通配符*#c::Run Calc.exe ; Win+C, Shift+Win+C, Ctrl+Win+C 等都会触发此热键.
;$ 前缀使用键盘钩子相当于在此热键定义之前的某个位置指定了 #UseHook.
;UP 跟在热键后面松开触发, 按住DOWN
::test::
;!A在某些程序中会被表示为alt shift a 保险起见用!a
Send, Multiple{Enter}lines have{Enter}been sent{!}. ; 正确,热键需要{}括起来
Send, {bs 5} {left 5} ;五次退格,五次左方向键
Send, ^s ; 都表示发送 CTRL+s 键击
Send, {ctrl down}s{ctrl up} ; 都表示发送 CTRL+s 键击
SendInput, inside the ctrl{+}j hotkey ;sendinput比send即时发送
Sleep, 1000 ; 保持 1 秒.
Send,;多行
(
Line 1
Line 2
Apples are a fruit.
)
Return
#if GetKeyState("a") && GetKeyState("b")
d::MsgBox abcd
#KeyHistory 10
^H::
KeyHistory
esc::
;创建热键不需要大括号{esc}:: ;错误
MsgBox you esc!!!!
;正确
return
::run::
; 打开程序 网站
Run, https://autohotkey.com
return
;按住0或1
^Numpad0::
^Numpad1::
MsgBox Pressing either Control+Numpad0 or Control+Numpad1 will display this message.
return
;0和1失去原来的效果了,用以下方法弄回来
Numpad0::Send {Numpad0} ;
Numpad1::Send {Numpad1} ;
RWin::return ;禁用热键
;同时按住
Numpad0 & Numpad1::
MsgBox You pressed Numpad1 while holding down Numpad0.
Return
Return
ExitApp
;退出脚本
; 其他
; 获取用户输入InputBox:https://wyagd001.github.io/zh-cn/docs/Tutorial.htm#s62
; 指定窗口:#IfWinActive #IfWinExist
;吧下面的例子把左 Win 重映射为左 Ctrl:
*LWin::Send {LControl down}
*LWin Up::Send {LControl up}
个人用例
#SingleInstance, Force ;运行时强制reload脚本
; utf8 with BOM
; #NoTrayIcon ;不显示任务栏图标
; SendMode Input
; SetWorkingDir, %A_ScriptDir%
; StringCaseSense, Locale ;是否大小写敏感遵循当前用户区域设置的规则.
; Notes: #win ^ctrl !alt +shift
; Notes: ~原有功能不屏蔽 $防循环调用
SetTimer, setup, -100
; =========================================================
setup:
WinWait, LittleTips
if WinExist("LittleTips")
WinClose ; 使用 WinExist 找到的窗口
return
; 使用帮助ctrl `
CapsLock & g::
send, ^c
KeyWait, c ;等待c释放(才算复制完成)
run https://www.google.com/search?q=%clipboard%
return
CapsLock & c::
send ^c
KeyWait c ;等待c释放(才算复制完成)
cb=%Clipboard%
tooltip,%cb% ;提示文本
SetTimer, RemoveToolTip , -2000
return
CapsLock & `::
StringCaseSense, On
SendInput,
(
LAlt CapsLock 切换大小写
CapsLock ` 使用帮助
CapsLock g 对选中的文字谷歌搜索
CapsLock esc 暂停脚本
CapsLock t 置顶当前窗口
CapsLock -/= 改变当前窗口透明度
CapsLock f1 启动WindowSpy.ahk
ctrl d 除vscode外映射为删除当前行
按住鼠标左键加方向键 像素级移动鼠标
任务栏处滚动滚轮调节音量
)
return
; =========================================================
; CapsLock重映射
CapsLock::return
CapsLock & f1::run, "D:\AutoHotKey\WindowSpy.ahk"
CapsLock & esc::Pause ; esc暂停脚本. 再按一次则取消暂停.
CapsLock & t:: WinSet, AlwaysOnTop,,A ;CapsLock t 置顶当前窗口
LAlt & CapsLock::SetCapsLockState, % GetKeyState("CapsLock", "T") ? "Off" : "On"
; ========================================================
; 纯字符串宏替换
:*:@q::@qq.com
:*:===::`; =========================================================
; ========================================================
; 一些函数,label
MouseIsOver(WinTitle) {
MouseGetPos,,, Winid
return WinExist(WinTitle . " ahk_id " . Winid) ;.连接字符串
}
RemoveToolTip: ;用于setTimer调用
ToolTip
return
;=========================================================
; CapsLock -/= 改变当前窗口透明度
CapsLock & -::
WinGet, ow, id, A
WinTransplus(ow,-10)
return
CapsLock & =::
WinGet, winid, id, A
WinTransplus(winid,10)
return
WinTransplus(winid,num){
WinGet, tp, Transparent, ahk_id %winid%
tp := tp+num
tp := tp<0 ? 0:tp
tp := tp>255 ? 255:tp
WinSet, Transparent, %tp%, ahk_id %winid%
ToolTip, %tp%
SetTimer, RemoveToolTip, -500
return
}
;=========================================================
#g:: ; 按下 Win+G 来显示鼠标下窗口的当前透明设置.
MouseGetPos,,, MouseWin
WinGet, ta, transparent, ahk_id %MouseWin%
WinGet, transColor, TransColor, ahk_id %MouseWin%
ToolTip %ta% %ta% %transparent% %transColor%
ToolTip Translucency:`t %transparent% `nTransColor:`t %transColor%
setTimer, RemoveToolTip, -500
return
;=========================================================
; Loop ;移除文本所有空行
; {
; MyString := StrReplace(MyString, "`r`n`r`n", "`r`n", Count)
; if (Count = 0) ; 不再需要更多的替换.
; break
; }
^j::
WinGetTitle, Title, A
MsgBox, The active window is "%Title%".
return
;=========================================================
$^d:: ;除vscode外将ctrl d映射为删除当前行,$防止Send, ^d重复调用
WinGetTitle, title ,A
if InStr(title,"Visual Studio Code") ;如果是vscode
Send, ^d
else
Send,{home}{shiftdown}{end}{Right}{shiftup}{BackSpace}
; Send,{end}{shiftdown}{home}{shiftup}{BackSpace} ;{delete}
return
;=========================================================
; 像素级移动鼠标,R表示相对位置
~LButton & Left:: MouseMove, -1, 0,,R
~LButton & Right:: MouseMove, 1, 0,,R
~LButton & Up:: MouseMove, 0, -1,,R
~LButton & Down:: MouseMove, 0, 1,,R
;=========================================================
;鼠标在任务栏时滚轮调节音量
#If MouseIsOver("ahk_class Shell_TrayWnd")
WheelUp::Send {Volume_Up}
WheelDown::Send {Volume_Down}
#IF
/*
%A_AhkVersion%
什么时候需要将变量名括在百分号中?
https://wyagd001.github.io/zh-cn/docs/FAQ.htm#percent
EnvGet, OutputVar, Path ;获取环境变量
{AppsKey} Menu(调用右键点击或上下文菜单)
Random,delay,50,100
WinGetClass,sClass,A
WinGetTitle, sTitle,A
sNow =%A_Now%
mousegetpos
*/
/*
;user-defined 自动打开记事本所有网址链接::
loop,30
{
send,{home}{shiftdown}{end}{shiftup}
send,^x{delete}
run %clipboard%
sleep,500
send,!{tab}
sleep,1000
}
return
*/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!