Skip to content

Instantly share code, notes, and snippets.

@hokorobi
Created November 28, 2018 09:05
Show Gist options
  • Save hokorobi/bc7591d48a0447de338071c0fa0a0a1c to your computer and use it in GitHub Desktop.
Save hokorobi/bc7591d48a0447de338071c0fa0a0a1c to your computer and use it in GitHub Desktop.
ahk
#InstallKeybdHook
#UseHook ;%A_ThisHotkey% での無限ループを回避。
#NoEnv ;環境変数を無視。速度面でも有利になる。
#SingleInstance force ;同じスクリプトを一つだけ起動。
; Razer Synapseなど、キーカスタマイズ系のツールを併用しているときのエラー対策
#MaxHotkeysPerInterval 350
SetTitleMatchMode, 2 ;中間一致。Autoexec section にないといけない。
GroupAdd, ThisHotkey, ahk_exe putty.exe ;PuTTY 用定義
GroupAdd, ThisHotkey, ahk_exe gvim.exe ;vim 用定義
GroupAdd, ThisHotkey, ahk_exe nvim-qt.exe ;neovim 用定義
Return ;End of Autoexec section.
; ホットキー
#Include %A_ScriptDir%\IME_Func\IME_Func.ahk
kill_line() {
Send {ShiftDown}{END}{SHIFTUP}
Sleep 10 ;[ms]
Send {Delete}
}
kill_line_bs() {
Send {ShiftDown}{HOME}{SHIFTUP}
Sleep 10 ;[ms]
Send {Delete}
}
toggle_ime() {
howime := IME_CHECK("A")
if (%howime% = 0) {
IME_ON("A")
} else {
IME_OFF("A")
}
}
freeplane_input_icon(key) {
send,{CtrlDown}{F2}{CtrlUp}
;^{F2} だと右 Ctrl が効かない場合があった。
send,{%key%}
}
;共通定義
^k::kill_line()
^BS::kill_line_bs()
^b::send,{Left}
+^b::send,+{Left}
^f::send,{Right}
+^f::send,+{Right}
^p::send,{Up}
+^p::send,+{Up}
^n::send,{Down}
+^n::send,+{Down}
^a::send,{Home}
^e::send,{End}
^d::send,{Delete}
^h::send,{BS}
^g::send,{ESC}
^m::send,{Enter}
^/::send,^f
+^w::Run,M:\OLS\File\Everything\Everything.exe
Pause::toggle_ontop()
; https://github.com/karakaram/alt-ime-ahk
; 主要なキーを HotKey に設定し、何もせずパススルーする
*~a::
*~b::
*~c::
*~d::
*~e::
*~f::
*~g::
*~h::
*~i::
*~j::
*~k::
*~l::
*~m::
*~n::
*~o::
*~p::
*~q::
*~r::
*~s::
*~t::
*~u::
*~v::
*~w::
*~x::
*~y::
*~z::
*~1::
*~2::
*~3::
*~4::
*~5::
*~6::
*~7::
*~8::
*~9::
*~0::
*~F1::
*~F2::
*~F3::
*~F4::
*~F5::
*~F6::
*~F7::
*~F8::
*~F9::
*~F10::
*~F11::
*~F12::
*~`::
*~~::
*~!::
*~@::
*~#::
*~$::
*~%::
*~^::
*~&::
*~*::
*~(::
*~)::
*~-::
*~_::
*~=::
*~+::
*~[::
*~{::
*~]::
*~}::
*~\::
*~|::
*~;::
*~'::
*~"::
*~,::
*~<::
*~.::
*~>::
*~/::
*~?::
*~Esc::
*~Tab::
*~Space::
*~Left::
*~Right::
*~Up::
*~Down::
*~Enter::
*~PrintScreen::
*~Delete::
*~Home::
*~End::
*~PgUp::
*~PgDn::
Return
; 上部メニューがアクティブになるのを抑制
*~LAlt::Send {Blind}{vk07}
*~RAlt::Send {Blind}{vk07}
; 左 Alt 空打ちで IME を OFF
LAlt up::
if (A_PriorHotkey == "*~LAlt")
{
toggle_ime()
}
Return
toggle_ontop() {
WinSet, AlwaysOnTop, toggle, A
OSD("ontop toggle")
}
; FIXME: 背景色の透明化
OSD(text) {
#Persistent
; borderless, no progressbar, font size 25, color text 009900
Progress, hide Y600 W1000 b zh0 cwFFFFFF FM50 CT00BB00,, %text%, AutoHotKeyProgressBar
WinSet, TransColor, FFFFFF 255, AutoHotKeyProgressBar
Progress, show
SetTimer, RemoveToolTip, 2000
Return
RemoveToolTip:
SetTimer, RemoveToolTip, Off
Progress, Off
return
}
winmove_edge(direction, isStay) {
margineX = 60
margineY = 0
WinGetActiveStats, title, width, height, X, Y
WinGet, statusMinMax, MinMax, %title%
if (statusMinMax = 1) {
if (isStay) {
send, !{%direction%}
} else {
send, +^{%direction%}
}
Return
}
if (direction = "Left") {
if (isStay) {
newWidth := X + width - margineX
}
newX := margineX
} else if (direction = "Right") {
if (isStay) {
newWidth := A_ScreenWidth - X
} else {
newX := A_ScreenWidth - width
}
} else if (direction = "Up") {
if (isStay) {
newHeight := Y + height - margineY
}
newY := margineY
} else if (direction = "Down") {
if (isStay) {
newHeight := A_ScreenHeight - Y
} else {
newY := A_ScreenHeight - height
}
} else {
Return
}
WinMove, %title%, , newX, newY, newWidth, newHeight
}
;Alt + 矢印でその方向にウィンドウを広げる
;Ctrl + Shift + 矢印でその方向にウィンドウを移動する
!Left::winmove_edge("Left", true)
+^Left::winmove_edge("Left", false)
!Right::winmove_edge("Right", true)
+^Right::winmove_edge("Right", false)
!Up::winmove_edge("Up", true)
+^Up::winmove_edge("Up", false)
!Down::winmove_edge("Down", true)
+^Down::winmove_edge("Down", false)
;Amazon Prime Video 用にウィンドウを調整
win640() {
WinGetActiveStats, title, width, height, X, Y
WinMove, %title%, , 1300, 656, 620, 424
}
+Pause::win640()
; Paper Plane
#IfWinActive ahk_exe PPCW.EXE
^k::send,%A_ThisHotkey%
WheelDown::send,{Down}
WheelUp::send,{Up}
#IfWinActive
; WinMerge
#IfWinActive ahk_exe WinMergeU.exe
!Up::send,!{Up}
!Down::send,!{Down}
!Left::send,!{Left}
!Right::send,!{Right}
#IfWinActive
;KeePass
#IfWinActive KeePass ahk_class #32770
^b::send,%A_ThisHotkey%
#IfWinActive
;Freeplane
#IfWinActive Freeplane ahk_class SunAwtFrame
^i::send,{Insert}
^k::send,%A_ThisHotkey%
^1::freeplane_input_icon(1)
^2::freeplane_input_icon(2)
^3::freeplane_input_icon(3)
^4::freeplane_input_icon(4)
^5::freeplane_input_icon(5)
^6::freeplane_input_icon(6)
^7::freeplane_input_icon(7)
^8::freeplane_input_icon(8)
^9::freeplane_input_icon(9)
#IfWinActive
;Excel
#IfWinActive ahk_class XLMAIN
^e::send,{F2}
F1::send,{F2}
^r::send,^h
^/::send,^f
!;::send,^{vkBB}
#IfWinActive
; LibreOffice Calc
#IfWinActive ahk_class SALFRAME
^e::send,{F2}
F1::send,{F2}
^r::send,^h
^/::send,^f
#IfWinActive
;Word
#IfWinActive ahk_class OpusApp
^r::send,^h
^/::send,^f
#IfWinActive
;Powerpoint
#IfWinActive ahk_class PP12FrameClass
^e::send,{F2}
^r::send,^h
^/::send,^f
#IfWinActive
;command prompt
#IfWinActive ahk_class ConsoleWindowClass
^w::send,exit{Enter}
#IfWinActive
; Becky
#IfWinActive ahk_class Becky2MainFrame
^b::send,%A_ThisHotkey%
^n::send,%A_ThisHotkey%
^h::send,%A_ThisHotkey%
^m::send,%A_ThisHotkey%
,::send,{Up}
.::send,{Down}
+,::send,{Home}
+.::send,{End}
#IfWinActive
; Audacity
#IfWinActive ahk_exe audacity.exe
^f::send,%A_ThisHotkey%
^e::send,%A_ThisHotkey%
#IfWinActive
;キー変更なし定義
#IfWinActive ahk_group ThisHotkey
^k::send,%A_ThisHotkey%
^BS::Send,^{BS}
^b::send,%A_ThisHotkey%
^f::send,%A_ThisHotkey%
^p::send,%A_ThisHotkey%
^n::send,%A_ThisHotkey%
^a::send,%A_ThisHotkey%
^e::send,%A_ThisHotkey%
^d::send,%A_ThisHotkey%
^h::send,%A_ThisHotkey%
;^g::send,%A_ThisHotkey%
;^m::send,%A_ThisHotkey%
^/::send,%A_ThisHotkey%
#IfWinActive
;Vim
#IfWinActive ahk_exe gvim.exe
LAlt up::send,^{^}
#IfWinActive
#IfWinActive ahk_exe MassiGra.exe
joy2::
send,{Right}
send,{NumpadAdd}
send,{NumpadAdd}
send,{NumpadAdd}
send,{Home}
return
joy4::
send,{Left}
send,{NumpadAdd}
send,{NumpadAdd}
send,{NumpadAdd}
send,{Home}
return
joy1::send,{Home}
joy3::send,{End}
joy8::send,{NumpadAdd}
joy6::send,{NumpadSub}
#IfWinActive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment