Windows Autohotkey Setting
2023-10-27
2 min read
autohotkey 在 windows 上改键的神器. 借此可以实现在 macos 下与 karabiner-Elements 同样的效果.
key binding
shorcut | effect |
F7 | stop autohotkey effect |
win + k | popup emacs |
win + r | popup edge |
win + c | copy |
win + v | paste |
win + x | cut |
win + z | undo |
win + y | redo |
casplock with single | escape |
casplock with otherkeys | ctrl with other keys |
config code
#k::
WinTitle := "ahk_exe emacs.exe"
WinGet WinState, MinMax, %WinTitle% ; retrieve minimized/maximized state
if (WinState = -1) ; minimized
WinRestore, %WinTitle%
else ; not minimized
WinMinimize, %WinTitle%
Return
!k::
WinTitle := "ahk_exe emacs.exe"
WinGet WinState, MinMax, %WinTitle% ; retrieve minimized/maximized state
if (WinState = -1) ; minimized
WinRestore, %WinTitle%
else ; not minimized
WinMinimize, %WinTitle%
Return
#r::
WinTitle := "ahk_class Chrome_WidgetWin_1"
WinGet WinState, MinMax, %WinTitle% ; retrieve minimized/maximized state
if (WinState = -1) ; minimized
WinRestore, %WinTitle%
else ; not minimized
WinMinimize, %WinTitle%
Return
!r::
WinTitle := "ahk_class Chrome_WidgetWin_1"
WinGet WinState, MinMax, %WinTitle% ; retrieve minimized/maximized state
if (WinState = -1) ; minimized
WinRestore, %WinTitle%
else ; not minimized
WinMinimize, %WinTitle%
Return
#;::
WinTitle := "ahk_exe WXWork.exe"
WinGet WinState, MinMax, %WinTitle% ; retrieve minimized/maximized state
if (WinState = -1) ; minimized
WinRestore, %WinTitle%
else ; not minimized
WinMinimize, %WinTitle%
Return
#c::
send ^c
Return
#v::
send ^v
Return
#x::
send ^x
Return
#z::
send ^z
Return
#y::
send ^y
Return
!c::
send ^c
Return
!v::
send ^v
Return
!x::
send ^x
Return
!z::
send ^z
Return
!y::
send ^y
Return
!d::
send #d
Return
F7::
Suspend, Off
Pause, Off, 1
If (toggle := !toggle)
Suspend, On
Pause, On, 1
Return
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
*CapsLock::
if (g_ControlRepeatDetected)
{
return
}
send,{Ctrl down}
g_LastCtrlKeyDownTime := A_TickCount
g_AbortSendEsc := false
g_ControlRepeatDetected := true
return
*CapsLock Up::
send,{Ctrl up}
g_ControlRepeatDetected := false
if (g_AbortSendEsc)
{
return
}
current_time := A_TickCount
time_elapsed := current_time - g_LastCtrlKeyDownTime
if (time_elapsed <= 250)
{
SendInput {Esc}
}
return
question
There always have one question confuse me is I wanna binding a shorcut only on a particular application. I tried some of the solution support by the autohotkey offically, but it does not work well. I will keep looking for the solution.