ahk在vim中自动切换微软输入法中英文状态

ahk代码如下:

GetGUIThreadInfo_hwndActive(WinTitle="A")
{
ControlGet, hwnd, HWND,,, %WinTitle%
if (WinActive(WinTitle)) {
ptrSize := !A_PtrSize ? 4 : A_PtrSize
VarSetCapacity(stGTI, cbSize:=4+4+(PtrSize*6)+16, 0)
NumPut(cbSize, stGTI,  0, "UInt")
return hwnd := DllCall("GetGUIThreadInfo", "Uint", 0, "Ptr", &stGTI)
? NumGet(stGTI, 8+PtrSize, "Ptr") : hwnd
}
else {
return hwnd
}
}
IME_GET(WinTitle="A")  {
hwnd :=GetGUIThreadInfo_hwndActive(WinTitle)
return DllCall("SendMessage"
, Ptr, DllCall("imm32\ImmGetDefaultIMEWnd", Ptr,hwnd)
, UInt, 0x0283
, UPtr, 0x005
,  Ptr, 0)
}
IME_SET(SetSts, WinTitle="A")    {
hwnd :=GetGUIThreadInfo_hwndActive(WinTitle)
return DllCall("SendMessage"
, Ptr, DllCall("imm32\ImmGetDefaultIMEWnd", Ptr, hwnd)
, UInt, 0x0283
, UPtr, 0x006
,  Ptr, SetSts)
}
IME_GetConvMode(WinTitle="A")   {
hwnd :=GetGUIThreadInfo_hwndActive(WinTitle)
return DllCall("SendMessage"
, "Ptr", DllCall("imm32\ImmGetDefaultIMEWnd", "Ptr", hwnd)
, "UInt", 0x0283
,  "Int", 0x001
,  "Int", 0) & 0xffff
}
IME_SetConvMode(ConvMode, WinTitle="A")   {
hwnd :=GetGUIThreadInfo_hwndActive(WinTitle)
return DllCall("SendMessage"
, "Ptr", DllCall("imm32\ImmGetDefaultIMEWnd", "Ptr", hwnd)
, "UInt", 0x0283
, "UPtr", 0x002
,  "Ptr", ConvMode)
}
im_status := IME_GetConvMode()
arg = %1%
switch arg {
case "-c":
IME_SetConvMode(0)
return
case "-o":
IME_SetConvMode(1025)
return
case "-t":
if (IME_GetConvMode() = 0) {
IME_SetConvMode(1025)
} else {
IME_SetConvMode(0)
}
return
case "-T":
if (IME_GetConvMode() = 0) {
IME_SetConvMode(1025)
} else {
IME_SetConvMode(0)
}
return
default:
if (IME_GetConvMode() = 0) {
FileAppend 1`n, *
} else {
FileAppend 2`n, *
}
}
lxpb_This_and_next_line_added_by_Ahk2Exe:
Exit

上一篇:arthas 简单使用


下一篇:配置新版Chrome双击关闭标签页