-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVim.ahk
124 lines (94 loc) · 2.36 KB
/
Vim.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#NoEnv
#WinActivateForce
#SingleInstance, Force
#include IME.ahk
SetCapsLockState AlwaysOff
; #NoTrayIcon ; 状态栏图标, 按需注释
ListLines, Off
SendMode Input
SetBatchLines -1
SetControlDelay 0
SetWorkingDir %A_ScriptDir%
; 置换默认的左ctrl-space行为,让其不触发输入法切换,为ide补全留出来
<^Space::ControlSend, ,{LCtrl Up}{LCtrl Down}{Space Down}{Space Up}{LCtrl Up}, A
; ESC直接切换到英文,类VIM应用有用
~Esc::CIM_SendKey()
; ^[::CIM_SendKey()
; ^c::CIM_SendKey_Ctrl_C()
Capslock::Send_ESC()
; #space::Run "D:\Program Files\Terminal\open-wsl.exe" -l
CIM_SendKey()
{
; ConvESC()
IME_SET(0)
Send {Esc}
}
CIM_SendKey_Ctrl_C()
{
; ConvESC()
IME_SET(0)
SendInput {Raw}
}
ConvESC() {
if (GetIME() = 1) {
Send {RCtrl Down}{Space Down}{Space Up}{RCtrl Up}
}
}
Send_ESC(){
SetCapsLockState AlwaysOff
CIM_SendKey()
}
GetIME(WinTitle="") {
ifEqual WinTitle,, SetEnv,WinTitle,A
WinGet,hWnd,ID,%WinTitle%
DefaultIMEWnd := DllCall("imm32\ImmGetDefaultIMEWnd", Uint,hWnd, Uint)
DetectSave := A_DetectHiddenWindows
DetectHiddenWindows,ON
SendMessage 0x283, 0x005,0,,ahk_id %DefaultIMEWnd%
DetectHiddenWindows,%DetectSave%
Return ErrorLevel
}
; 打开或者切换程序
; Function to run a program or activate an already running instance
RunOrActivateProgram(Program, WorkingDir="", WindowSize=""){
SplitPath Program, ExeFile
Process, Exist, %ExeFile%
PID = %ErrorLevel%
if (PID = 0) {
Run, %Program%, %WorkingDir%, %WindowSize%
}else{
WinActivate, ahk_pid %PID%
}
}
Capslock & j::
SetCapsLockState AlwaysOff
RunOrActivateProgram("chrome.exe")
return
Capslock & i::
SetCapsLockState AlwaysOff
RunOrActivateProgram("idea64.exe")
return
Capslock & n::
SetCapsLockState AlwaysOff
RunOrActivateProgram("notepad++.exe")
return
Capslock & f::
SetCapsLockState AlwaysOff
RunOrActivateProgram("firefox.exe")
return
Capslock & s::
SetCapsLockState AlwaysOff
Run "C:\Users\procsl\script\Vim.ahk"
return
Ctrl & [::
CIM_SendKey()
return
SwitchIME(dwLayout){
HKL:=DllCall("LoadKeyboardLayout", Str, dwLayout, UInt, 1)
ControlGetFocus,ctl,A
SendMessage,0x50,0,HKL,%ctl%,A
}
; F12::
; WinGetActiveTitle, Title
; MsgBox, The active window is "%Title%".
; return