Help us understand the problem. What is going on with this article?

AutoHotkey で MacBook Pro ライクなキーバインドにする

More than 1 year has passed since last update.

ウィンドウズで MacBook みたいなきーばいどにしたくて AutoHotkey のマクロ書きました。

スペースキーの左右にある [無変換] [変換] を [英数] [かな] にして
Emacs ライクなキーバインド (Macな感じ) に変更します。

is_disable() に追加されたアプリケーションは対象外になります。
わたしのばあい Blender はもともとのキーバインドで使いたいので無効にしています。

みなさん おたのしんでね!

AutoHotkey はこちらから
https://www.autohotkey.com/

[like_jpmac.ask]
#InstallKeybdHook
#UseHook

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

}

is_disable()
{
    ;vim
    if WInActive("ahk_class Vim")
    {
        return 1
    }

    ;tera term
    if WInActive("ahk_class VTWin32")
    {
        return 1
    }

    ;blender
    if WInActive("ahk_exe blender.exe")
    {
        return 1
    }

    return 0
}

send_key(original_key,replace_key)
{
    if(is_disable() == 1)
    {
        Send,%original_key%

        return
    }
    else if(is_disable() == 2)
    {

        Send,%replace_key%

        return

    }
    Send,%replace_key%

    return
}

;<^a::send_key("^a","{Home}")
;<^+a::send_key("^+a","+{Home}")
;<^e::send_key("^e","{End}")
;<^+e::send_key("^+e","+{End}")
;<^d::send_key("^d","{Del}")
;<^+d::send_key("^+d","+{Del}")
;<^k::send_key("^k","+{End}{Del}")

<MButton::send_key("MButton","+{Alt}{Ctrl}")


vk1Dsc07B::ime_set(0)
vk1Csc079::ime_set(1)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした