使用autohotkey映射按键统一交互

如果你特别烦躁vim、emacs、bash、IDE、编辑器、浏览器按键不统一带来的麻烦,可以试试autohotkey。目前唯一缺点各种远程控制可能会失效

脚本功能:

alt+j -> left

alt+shift+j -> shift+left

alt+ctrl+shift+j -> ctrl+shift+left

alt+8 -> pgup

alt+shift+8 -> shift+pgup

alt+ctrl+8 -> ctrl+pgup

alt+o->home

alt+shift+o->shift+home

alt+ctrl+o->ctrl+home

alt+ctrl+shift+o->ctrl+shift+home

alt+h -> backspace

诸如此类

normal.ahk

/*
不能彻底屏蔽alt菜单键
开启play会导致alt更易触发

RDP: 
至少在控制端开启,最好使用play
synergy: 
按键全变为Artificial
至少在被控制端开启,必须使用play
cmder异常
*/
#include checkkeyexception.ahk

#KeyHistory 1000
#SingleInstance force

;play会导致alt + back不能删除单词
sendMode input
;sendMode play
#MenuMaskKey vkFF		;会导致搜狗删除异常
;SetKeyDelay, 100




;replace CapsLock to LeftEnter; CapsLock = Alt CapsLock
$CapsLock::Enter
LAlt & Capslock::SetCapsLockState, % GetKeyState("CapsLock", "T") ? "Off" : "On"

;!u::Send ^c !{tab} ^v


<!i::send {Up down}
<!+i::send {shift down}{Up down}

<!k::send {down down}
<!+k::send {shift down}{down down}

<!j::send {left down}
<!+j::send {shift down}{left down}
<!^+j::send {shift down}{ctrl down}{left down}
<!^j::send {ctrl down}{left down}

<!l::send {right down}
<!+l::send {shift down}{right down}
<!^+l::send {shift down}{ctrl down}{right down}
<!^l::send {ctrl down}{right down}

<!u::send {home down}
<!+u::send {shift down}{home down}
<!^u::send {ctrl down}{home down}
<!^+u::send {ctrl down}{shift down}{home down}

<!o::send {end down}
<!+o::send {shift down}{end down}
<!^o::send {ctrl down}{end down}
<!^+o::send {ctrl down}{shift down}{end down}


<!8::send {pgup down}
<!+8::send {shift down}{pgup down}
<!^8::send ^{pgup down}

<!0::send {pgdn down}
<!+0::send {shift down}{pgdn down}
<!^0::send ^{pgdn down}


<!h::send {`b down}

;~LAlt Up:: return

;此法避免发送alt同时可以触发alt热键
~LAlt::sendinput {Blind}{vk07}
~LAlt up::sendinput {Blind}{vk07}

;for notepad++ eclipse firefox
;LAlt::return


/*
;for notepad++ eclipse
LAlt up::
If (A_PriorKey = "LAlt") ;  If LAlt was pressed alone
    return ; do nothing
return
*/

/*
;for ie securecrt
~LAlt::
KeyWait, LAlt
return

~LAlt Up::
Send, {LAlt Up}
return
*/



/*
LAlt & i::Send {Up down}
!+i::Send {Shift down}{Up down}

LAlt & k::Send {Down down}
LAlt & j::Send {Left down}
LAlt & l::Send {Right down}
LAlt & h::Send {Home down}
LAlt & `;::Send {End down}

LControl & h::Send {`b down}

LAlt & u::Send {PgUp down}
LAlt & o::Send {PgDn down}
*/

 

main.ahk  脚本入口点

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


MAINAHK := "normal.ahk"

Run open %MAINAHK%, , , ScriptPID

#Persistent
SetTimer, QuitOnRDPMaximized, 500
return

QuitOnRDPMaximized:
If WinActive("ahk_class TscShellContainerClass")
{
	WinGet, maxOrMin, MinMax, ahk_class TscShellContainerClass

	if (maxOrMin = 0)
	{
		WinGetPos, PosX, PosY, WinWidth, WinHeight, ahk_class TscShellContainerClass

		if (PosY = 0)
		{
			; it is fully maximized therefore end MAINAHK
			DetectHiddenWindows, On 
			SetTitleMatchMode, 2
			WinClose, %MAINAHK% ahk_class AutoHotkey
			; Process, Close, %ScriptPID%

			; wait until window gets deactivated so you don't reload it agin
			WinWaitNotActive, ahk_class TscShellContainerClass
			Run open %MAINAHK%, , , ScriptPID
		}
	}
}
return

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值