标签:
上次写了一篇博文,讲如何通过AutoHotKey改造CaspLock,使其成为一个方便的编辑按键,并特意给出了设计的思路方便参考。
见地址:http://www.cnblogs.com/Vonng/p/4240219.html
今日闲来无事,将这一脚本进行了不少修改,增加了一些更为实用的功能,例如媒体控制。并参照@shines77的改进将鼠标操作加入脚本中。
主要的改动包括:将CapsLock键 + F1到F7改造为了媒体功能键;CapsLock+B, W, S, Q的功能变更;CapsLock+上下左右变为鼠标移动,CapsLock+Enter变为鼠标单击,CapsLock+ / \变为注释与取消注释。CapsLock+数字键变为自定义功能区,个人用于Visual Studio的调试快捷键。
新版的键位图:
设计思路:
原来键位的设计思路在老的博文中,那么就说一下新的键位设计的原因。
另外,新版本脚本挂在了Github上:https://github.com/Vonng/Configuration
这里也贴出来一份。
;=====================================================================o ; Feng Ruohang‘s AHK Script | ; CapsLock Enhancement | ;---------------------------------------------------------------------o ;Description: | ; This Script is wrote by Feng Ruohang via AutoHotKey Script . It | ; Provieds an enhancement towards the "Useless Key" CapsLock. It turns| ; CapsLock into an useful function Key just like Ctrl and Alt by Comb | ; -ining it with almost all other keys in the keyboard. | ; | ;Features: | ;o----------------------o---------------------------------------------o ;|CapsLock; | {ESC} Especially Convient for vim user | ;|CaspLock + ` | {CapsLock}CapsLock Switcher as a Substituent| ;|CapsLock + hjklwb | Vim-Style Cursor Mover | ;|CaspLock + uiop | Convient Home/End PageUp/PageDn | ;|CaspLock + nm,. | Convient Delete Controller | ;|CapsLock + zxcvay | Windows-Style Editor | ;|CapsLock + Direction | Mouse Move | ;|CapsLock + Enter | Mouse Click | ;|CaspLock + {F1}!{F7} | Media Volume Controller | ;|CapsLock + qs | Windows & Tags Control | ;|CapsLock + ;‘[] | Convient Key Mapping | ;|CaspLock + dfert | Frequently Used Programs (Self Defined) | ;|CaspLock + 123456 | Dev-Hotkey for Visual Studio (Self Defined) | ;|CapsLock + 67890-= | Shifter as Shift | ;-----------------------o---------------------------------------------o ;|License: | ;|Use it whatever and wherever you like. Hope it help | ;|I‘d be happy if you keep my name here, and doesn‘t matter if not. | ;=====================================================================o ;=====================================================================o ; CapsLock Initializer ;| ;---------------------------------------------------------------------o SetCapsLockState, AlwaysOff ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Switcher: ;| ;---------------------------------o-----------------------------------o ; CapsLock + ` | {CapsLock} ;| ;---------------------------------o-----------------------------------o CapsLock & `:: ;| GetKeyState, CapsLockState, CapsLock, T ;| if CapsLockState = D ;| SetCapsLockState, AlwaysOff ;| else ;| SetCapsLockState, AlwaysOn ;| KeyWait, `` ;| return ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Escaper: ;| ;----------------------------------o----------------------------------o ; CapsLock | {ESC} ;| ;----------------------------------o----------------------------------o CapsLock::Send, {ESC} ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Direction Navigator ;| ;-----------------------------------o---------------------------------o ; CapsLock + h | Left ;| ; CapsLock + j | Down ;| ; CapsLock + k | Up ;| ; CapsLock + l | Right ;| ; Ctrl, Alt Compatible ;| ;-----------------------------------o---------------------------------o CapsLock & h:: ;| if GetKeyState("control") = 0 ;| { ;| if GetKeyState("alt") = 0 ;| Send, {Left} ;| else ;| Send, +{Left} ;| return ;| } ;| else { ;| if GetKeyState("alt") = 0 ;| Send, ^{Left} ;| else ;| Send, +^{Left} ;| return ;| } ;| return ;| ;-----------------------------------o ;| CapsLock & j:: ;| if GetKeyState("control") = 0 ;| { ;| if GetKeyState("alt") = 0 ;| Send, {Down} ;| else ;| Send, +{Down} ;| return ;| } ;| else { ;| if GetKeyState("alt") = 0 ;| Send, ^{Down} ;| else ;| Send, +^{Down} ;| return ;| } ;| return ;| ;-----------------------------------o ;| CapsLock & k:: ;| if GetKeyState("control") = 0 ;| { ;| if GetKeyState("alt") = 0 ;| Send, {Up} ;| else ;| Send, +{Up} ;| return ;| } ;| else { ;| if GetKeyState("alt") = 0 ;| Send, ^{Up} ;| else ;| Send, +^{Up} ;| return ;| } ;| return ;| ;-----------------------------------o ;| CapsLock & l:: ;| if GetKeyState("control") = 0 ;| { ;| if GetKeyState("alt") = 0 ;| Send, {Right} ;| else ;| Send, +{Right} ;| return ;| } ;| else { ;| if GetKeyState("alt") = 0 ;| Send, ^{Right} ;| else ;| Send, +^{Right} ;| return ;| } ;| return ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Home/End Navigator ;| ;-----------------------------------o---------------------------------o ; CapsLock + i | Home ;| ; CapsLock + o | End ;| ; Ctrl, Alt Compatible ;| ;-----------------------------------o---------------------------------o CapsLock & i:: ;| if GetKeyState("control") = 0 ;| { ;| if GetKeyState("alt") = 0 ;| Send, {Home} ;| else ;| Send, +{Home} ;| return ;| } ;| else { ;| if GetKeyState("alt") = 0 ;| Send, ^{Home} ;| else ;| Send, +^{Home} ;| return ;| } ;| return ;| ;-----------------------------------o ;| CapsLock & o:: ;| if GetKeyState("control") = 0 ;| { ;| if GetKeyState("alt") = 0 ;| Send, {End} ;| else ;| Send, +{End} ;| return ;| } ;| else { ;| if GetKeyState("alt") = 0 ;| Send, ^{End} ;| else ;| Send, +^{End} ;| return ;| } ;| return ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Page Navigator ;| ;-----------------------------------o---------------------------------o ; CapsLock + u | PageUp ;| ; CapsLock + p | PageDown ;| ; Ctrl, Alt Compatible ;| ;-----------------------------------o---------------------------------o CapsLock & u:: ;| if GetKeyState("control") = 0 ;| { ;| if GetKeyState("alt") = 0 ;| Send, {PgUp} ;| else ;| Send, +{PgUp} ;| return ;| } ;| else { ;| if GetKeyState("alt") = 0 ;| Send, ^{PgUp} ;| else ;| Send, +^{PgUp} ;| return ;| } ;| return ;| ;-----------------------------------o ;| CapsLock & p:: ;| if GetKeyState("control") = 0 ;| { ;| if GetKeyState("alt") = 0 ;| Send, {PgDn} ;| else ;| Send, +{PgDn} ;| return ;| } ;| else { ;| if GetKeyState("alt") = 0 ;| Send, ^{PgDn} ;| else ;| Send, +^{PgDn} ;| return ;| } ;| return ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Mouse Controller ;| ;-----------------------------------o---------------------------------o ; CapsLock + Up | Mouse Up ;| ; CapsLock + Down | Mouse Down ;| ; CapsLock + Left | Mouse Left ;| ; CapsLock + Right | Mouse Right ;| ; CapsLock + Enter(Push Release) | Mouse Left Push(Release) ;| ;-----------------------------------o---------------------------------o CapsLock & Up:: MouseMove, 0, -10, 0, R ;| CapsLock & Down:: MouseMove, 0, 10, 0, R ;| CapsLock & Left:: MouseMove, -10, 0, 0, R ;| CapsLock & Right:: MouseMove, 10, 0, 0, R ;| ;-----------------------------------o ;| CapsLock & Enter:: ;| SendEvent {Blind}{LButton down} ;| KeyWait Enter ;| SendEvent {Blind}{LButton up} ;| return ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Deletor ;| ;-----------------------------------o---------------------------------o ; CapsLock + n | Ctrl + Delete (Delete a Word) ;| ; CapsLock + m | Delete ;| ; CapsLock + , | BackSpace ;| ; CapsLock + . | Ctrl + BackSpace ;| ;-----------------------------------o---------------------------------o CapsLock & ,:: Send, {Del} ;| CapsLock & .:: Send, ^{Del} ;| CapsLock & m:: Send, {BS} ;| CapsLock & n:: Send, ^{BS} ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Editor ;| ;-----------------------------------o---------------------------------o ; CapsLock + z | Ctrl + z (Cancel) ;| ; CapsLock + x | Ctrl + x (Cut) ;| ; CapsLock + c | Ctrl + c (Copy) ;| ; CapsLock + v | Ctrl + z (Paste) ;| ; CapsLock + a | Ctrl + a (Select All) ;| ; CapsLock + y | Ctrl + z (Yeild) ;| ; CapsLock + w | Ctrl + Right(Move as [vim: w]);| ; CapsLock + b | Ctrl + Left (Move as [vim: b]);| ;-----------------------------------o---------------------------------o CapsLock & z:: Send, ^z ;| CapsLock & x:: Send, ^x ;| CapsLock & c:: Send, ^c ;| CapsLock & v:: Send, ^v ;| CapsLock & a:: Send, ^a ;| CapsLock & y:: Send, ^y ;| CapsLock & w:: Send, ^{Right} ;| CapsLock & b:: Send, ^{Left} ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Media Controller ;| ;-----------------------------------o---------------------------------o ; CapsLock + F1 | Volume_Mute ;| ; CapsLock + F2 | Volume_Down ;| ; CapsLock + F3 | Volume_Up ;| ; CapsLock + F3 | Media_Play_Pause ;| ; CapsLock + F5 | Media_Prev ;| ; CapsLock + F6 | Media_Next ;| ; CapsLock + F7 | Media_Stop ;| ;-----------------------------------o---------------------------------o CapsLock & F1:: Send, {Volume_Mute} ;| CapsLock & F2:: Send, {Volume_Down} ;| CapsLock & F3:: Send, {Volume_Up} ;| CapsLock & F4:: Send, {Media_Play_Pause} ;| CapsLock & F5:: Send, {Media_Prev} ;| CapsLock & F6:: Send, {Media_Next} ;| CapsLock & F7:: Send, {Media_Stop} ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Window Controller ;| ;-----------------------------------o---------------------------------o ; CapsLock + s | Ctrl + Tab (Swith Tag) ;| ; CapsLock + q | Ctrl + W (Close Tag) ;| ; (Disabled) Alt + CapsLock + s | AltTab (Swith Windows) ;| ; Alt + CapsLock + q | Ctrl + Tab (Switch Tag) ;| ; CapsLock + g | AppsKey (Menu Key) ;| ;-----------------------------------o---------------------------------o CapsLock & s::Send, ^{Tab} ;| ;-----------------------------------o ;| CapsLock & q:: ;| if GetKeyState("alt") = 0 ;| { ;| Send, ^w ;| } ;| else { ;| Send, !{F4} ;| return ;| } ;| return ;| ;-----------------------------------o ;| CapsLock & g:: Send, {AppsKey} ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Self Defined Area ;| ;-----------------------------------o---------------------------------o ; CapsLock + d | Alt + d(Dictionary) ;| ; CapsLock + f | Alt + f(Search via Everything);| ; CapsLock + e | Open Search Engine ;| ; CapsLock + r | Open Shell ;| ; CapsLock + t | Open Text Editor ;| ;-----------------------------------o---------------------------------o CapsLock & d:: Send, !d ;| CapsLock & f:: Send, !f ;| CapsLock & e:: Run http://cn.bing.com/ ;| CapsLock & r:: Run Powershell ;| CapsLock & t:: Run C:\Program Files (x86)\Notepad++\notepad++.exe ;| ;---------------------------------------------------------------------o ;=====================================================================o ; CapsLock Char Mapping ;| ;-----------------------------------o---------------------------------o ; CapsLock + ; | Enter (Cancel) ;| ; CapsLock + ‘ | = ;| ; CapsLock + [ | Back (Visual Studio) ;| ; CapsLock + ] | Goto Define (Visual Studio) ;| ; CapsLock + / | Comment (Visual Studio) ;| ; CapsLock + \ | Uncomment (Visual Studio) ;| ; CapsLock + 1 | Build and Run(Visual Studio) ;| ; CapsLock + 2 | Debuging (Visual Studio) ;| ; CapsLock + 3 | Step Over (Visual Studio) ;| ; CapsLock + 4 | Step In (Visual Studio) ;| ; CapsLock + 5 | Stop Debuging(Visual Studio) ;| ; CapsLock + 6 | Shift + 6 ^ ;| ; CapsLock + 7 | Shift + 7 & ;| ; CapsLock + 8 | Shift + 8 * ;| ; CapsLock + 9 | Shift + 9 ( ;| ; CapsLock + 0 | Shift + 0 ) ;| ;-----------------------------------o---------------------------------o CapsLock & `;:: Send, {Enter} ;| CapsLock & ‘:: Send, = ;| CapsLock & [:: Send, ^- ;| CapsLock & ]:: Send, {F12} ;| ;-----------------------------------o ;| CapsLock & /:: ;| Send, ^e ;| Send, c ;| return ;| ;-----------------------------------o ;| CapsLock & \:: ;| Send, ^e ;| Send, u ;| return ;| ;-----------------------------------o ;| CapsLock & 1:: Send,^{F5} ;| CapsLock & 2:: Send,{F5} ;| CapsLock & 3:: Send,{F10} ;| CapsLock & 4:: Send,{F11} ;| CapsLock & 5:: Send,+{F5} ;| ;-----------------------------------o ;| CapsLock & 6:: Send,+6 ;| CapsLock & 7:: Send,+7 ;| CapsLock & 8:: Send,+8 ;| CapsLock & 9:: Send,+9 ;| CapsLock & 0:: Send,+0 ;| ;---------------------------------------------------------------------o
CapsLock Enhancement via AutoHotKey
标签:
原文地址:http://www.cnblogs.com/Vonng/p/4294344.html