Skip to content

Instantly share code, notes, and snippets.

@csnagu
Last active June 26, 2021 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csnagu/6bb68fdb076a9240aba5e352afa66551 to your computer and use it in GitHub Desktop.
Save csnagu/6bb68fdb076a9240aba5e352afa66551 to your computer and use it in GitHub Desktop.
MacOSのカーソル移動系キーバインドを再現するautoHotKeyのコンフィグファイル
IME_SET(SetSts, 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") ; DWORD cbSize;
hwnd := DllCall("GetGUIThreadInfo", Uint,0, Uint,&stGTI)
? NumGet(stGTI,8+PtrSize,"UInt") : hwnd
}
return DllCall("SendMessage"
, UInt, DllCall("imm32\ImmGetDefaultIMEWnd", Uint,hwnd)
, UInt, 0x0283 ;Message : WM_IME_CONTROL
, Int, 0x006 ;wParam : IMC_SETOPENSTATUS
, Int, SetSts) ;lParam : 0 or 1
}
IME_GET(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") ; DWORD cbSize;
hwnd := DllCall("GetGUIThreadInfo", Uint,0, Uint,&stGTI)
? NumGet(stGTI,8+PtrSize,"UInt") : hwnd
}
return DllCall("SendMessage"
, UInt, DllCall("imm32\ImmGetDefaultIMEWnd", Uint,hwnd)
, UInt, 0x0283 ;Message : WM_IME_CONTROL
, Int, 0x0005 ;wParam : IMC_GETOPENSTATUS
, Int, 0) ;lParam : 0
}
F13 & B::Send,{Blind}{Left}
F13 & N::Send,{Blind}{Down}
F13 & P::Send,{Blind}{Up}
F13 & F::Send,{Blind}{Right}
F13 & A::Send,{Blind}{Home}
F13 & E::Send,{Blind}{End}
F13 & K::
If GetKeyState("Shift")
Send,{F7}
Else If WinActive("ahk_exe WindowsTerminal.exe")
Send,^k
Else
Send,{ShiftDown}{END}{ShiftUp}{Del}
return
F13 & D::Send,{Blind}{Del}
F13 & L::Send,{Blind}{CtrlDown}{L}{CtrlUp}
F13 & Tab::
If GetKeyState("ShiftDown")
Send,{Blind}{CtrlDown}{ShiftDown}{Tab}{ShiftUp}{CtrlUp}
else
Send,{Blind}{CtrlDown}{Tab}{CtrlUp}
return
F13 & J::
If GetKeyState("Shift")
Send,{F6}
return
F13 & `;::
If GetKeyState("Shift")
Send,{F8}
return
F13 & Space::
If IME_GET() == 1
IME_SET(0)
Else
IME_SET(1)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment