Skip to content

Instantly share code, notes, and snippets.

@babyking
Last active December 18, 2019 03:01
Show Gist options
  • Save babyking/5057457 to your computer and use it in GitHub Desktop.
Save babyking/5057457 to your computer and use it in GitHub Desktop.
自己使用的Autohotkey 脚本 绝大多数的习惯与我的MAC上定义快捷键是一致的. mac上实现此脚本中快捷键主要是通过 keyremap4macbook来实现的.大部分定义受vi以及unix的一些快捷键影响,另外,刚刚买了一个hhkb键盘,部分定义也受其启发.
/*
* email: [email protected]
* update: 2013/3/9
*/
;常用快捷命令
:://cmd:: ;打开命令行
Run cmd
return
:://t:: ;打开任务管理器
Run taskmgr
return
:://sys:: ;打开系统属性
Run control sysdm.cpl
return
;HJKL 方向键
^h:: Send {left}
^j:: Send {down}
^k:: Send {up}
^l:: Send {right}
;翻页键
^!k:: Send {PgUp}
^!j:: Send {PgDn}
^i:: Send {PgUp}
^u:: Send {PgDn}
;HOME END
^!h:: Send {Home}
^!l:: Send {End}
;Delete
^d:: Send {Delete}
^,:: Send {Delete}
^.:: Send {Backspace}
;程序切换
LCtrl & space::AltTab
LCtrl & lshift::
keywait space
send {ShiftAltTab}
return
;关闭窗口,应用
^q::!F4
!q::!F4
!w::^w
;~映射为esc键,shift+~映射为~(模拟hhkb)
;`::Send {Esc}
;+Esc::Send ~
;capslock键映射
^'::
if GetKeyState("Capslock", "T")
SetCapsLockState,off
else
SetCapsLockState,on
return
;回车键映射
^;::Send {Enter}
;1建议将capslock键映射为ctrl键(可以通过keytweak软件或更改注册表来实现)
;2单独单击capslock(实际为ctrl)键仍然实现capslock键原本的功能,当有组合健时则表现为ctrl+xxx组合键
;3作为vimer,目前我更喜欢将单击capslock(ctrl)键映射为esc,大写锁定键可以使用其他组合键或是双击ctrl来实现,主要取决于哪个键的使用频率更高一些.对于普通用户,2更合适,由于跟媳妇共用一台机器,双击可以在正常键和映射键之间进行切换.
Ctrl::
if ctrl_presses > 0 ; SetTimer already started, so we log the keypress instead.
{
ctrl_presses += 1
return
}
ctrl_presses = 1
SetTimer, KeyCtrl, 200 ; Wait for more presses within a 400 millisecond window.
return
KeyCtrl:
SetTimer, KeyCtrl, off
if ctrl_presses = 1 ; The key was pressed once.
{
if caps_tag = 1
{
Send {Esc} ;单击为ESC
}
else
{
if GetKeyState("Capslock", "T")
SetCapsLockState,off
else
SetCapsLockState,on
}
}
else if ctrl_presses = 2 ; The key was pressed twice.
{
if caps_tag = 1
{
caps_tag = 2
Msgbox, 已将capslock功能置为大写锁定键
}
else
{
caps_tag = 1
Msgbox, 已将capslock功能置为ESC
}
}
else if ctrl_presses > 2
{
MsgBox, Three or more clicks detected.
}
ctrl_presses = 0
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment