Last active
February 28, 2022 00:20
-
-
Save daimatz/1385713 to your computer and use it in GitHub Desktop.
Example of AutoHotkey. Mac like keybinds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;================================================================ | |
;mac風キーバインド(Cmd+Q) など | |
; https://gist.github.com/daimatz/1385713 | |
;================================================================ | |
#InstallKeybdHook | |
#UseHook | |
;================================================================ | |
;関数 | |
;================================================================ | |
;---------------------------------------------------------------- | |
;キーバインドを無効にするウィンドウかどうか判断する | |
; ahk_classはauto hot key付属のAU3_Spy.exeを使用して調べる。 | |
; 引数 なし | |
; 戻り値 1:キーバインドを無効にするウィンドウ | |
; 0:キーバインドを有効にするウィンドウ | |
;---------------------------------------------------------------- | |
is_disable_window() | |
{ | |
;vmware player | |
IfWinActive,ahk_class VMPlayerFrame | |
{ | |
return 1 | |
} | |
;Meadow | |
IfWinActive,ahk_class MEADOW | |
{ | |
return 1 | |
} | |
;Emacs | |
IfWinActive,ahk_class Emacs | |
{ | |
return 1 | |
} | |
;mintty | |
IfWinActive,ahk_class mintty | |
{ | |
return 1 | |
} | |
;PowerShell | |
IfWinActive,ahk_class ConsoleWindowClass | |
{ | |
return 1 | |
} | |
;Hyper | |
IfWinActive, Hyper | |
{ | |
IfWinNotActive, ahk_exe chrome.exe | |
{ | |
return 1 | |
} | |
} | |
;ConsoleZ | |
IfWinActive,ahk_class Console_2_Main | |
{ | |
return 1 | |
} | |
;AoE II | |
IfWinActive, ahk_exe AoE2DE.exe | |
{ | |
return 1 | |
} | |
return 0 | |
} | |
;---------------------------------------------------------------- | |
;キーを送信する | |
; キーバインドを無効にするウィンドウでは、送信されたキーをそのまま使用する | |
; キーバインドを有効にするウィンドウでは、送信されたキーを置き換える | |
; | |
; 引数 original_key:キーバインドを無効にするウィンドウの場合、送信するキー | |
; replace_key:キーバインドを有効にするウィンドウの場合、送信するキー | |
; 戻り値 なし | |
;---------------------------------------------------------------- | |
send_key(original_key,replace_key,is_force:=false) | |
{ | |
if (is_disable_window() && !is_force) | |
{ | |
Send,%original_key% | |
return | |
} | |
Send,%replace_key% | |
return | |
} | |
;================================================================ | |
;ctrlキーバインド | |
;================================================================ | |
<^n::send_key("^n","{Down}") | |
<^+n::send_key("^+n","+{Down}") | |
<^p::send_key("^p","{Up}") | |
<^+p::send_key("^+p","+{Up}") | |
<^f::send_key("^f","{Right}") | |
<^+f::send_key("^+f","+{Right}") | |
<^b::send_key("^b","{Left}") | |
<^+b::send_key("^+b","+{Left}") | |
<^a::send_key("^a","{Home}") | |
<^+a::send_key("^+a","+{Home}") | |
<^e::send_key("^e","{End}") | |
<^+e::send_key("^+e","+{End}") | |
<^h::send_key("^h","{BS}") | |
<^d::send_key("^d","{Del}") | |
<^o::send_key("^o","{Return}") | |
<^k::send_key("^k","+{End}{Del}") | |
<^w::send_key("^w","^{BS}") | |
<^m::send_key("^m","{Return}") | |
;================================================================ | |
;Altキーバインド | |
;================================================================ | |
!a::send_key("!a","^a") | |
!b::send_key("!b","^b") | |
!c::send_key("!c","^c") | |
!d::send_key("!d","^d") | |
!e::send_key("!e","^e") | |
!f::send_key("!f","^f") | |
!g::send_key("!g","^g") | |
!h::send_key("!h","^h") | |
!i::send_key("!i","^i") | |
!j::send_key("!j","^j") | |
!k::send_key("!k","^k") | |
!l::send_key("!l","^l") | |
!m::send_key("!m","^m") | |
!n::send_key("!n","^n") | |
!+n::send_key("!+n","^+n") | |
!o::send_key("!o","^o") | |
!p::send_key("!p","^p") | |
!+p::send_key("!+p","^+p") | |
;!q::send_key("!q","!{F4}") | |
!r::send_key("!r","^r") | |
!s::send_key("!s","^s") | |
!t::send_key("!t","^t") | |
!+t::send_key("!+t","^+t") | |
!u::send_key("!u","^u") | |
!v::send_key("!v","^v") | |
!w::send_key("!w","^w") | |
!x::send_key("!x","^x") | |
!y::send_key("!y","^y") | |
!z::send_key("!z","^z") | |
!0::send_key("!0","^0") | |
!1::send_key("!1","^1") | |
!2::send_key("!2","^2") | |
!3::send_key("!3","^3") | |
!4::send_key("!4","^4") | |
!5::send_key("!5","^5") | |
!6::send_key("!6","^6") | |
!7::send_key("!7","^7") | |
!8::send_key("!8","^8") | |
!9::send_key("!9","^9") | |
!-::send_key("!-","^-") | |
!=::send_key("!=","^=") | |
!Space::send_key("!Space","!{vkF3sc029}") | |
^!1::send_key("^!1","^#{Left}",true) | |
^!2::send_key("^!2","^#{Right}",true) | |
; disable Win+Space | |
#Space:: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment