使用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


 

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

 

你可能感兴趣的:(使用autohotkey映射按键统一交互)