카테고리 없음

나의 AutoHotKey 스크립트

컴돌이 2026. 8. 4. 17:27
#Requires AutoHotkey v2.0
#SingleInstance Force
#Hotstring EndChars `s ; 스페이스를 입력해야만 변환

;; Modifier Keys
; Caps <-> Control
CapsLock::LControl
LControl::CapsLock

!.::Esc 			; ESC
*VK19::LAlt 		; 한자(VK19) -> Ctrl
*VK15::LControl		; 한영(VK15) -> Alt

;; --- 시스템 도구 ---
^Space::Send("{vk15}") 	  	; 한영
^!Space::Send("{vk19}")     ; 한자
!q::Send("!{F4}")         	; 종료
!Space::Send("#s")        	; Spotlight 스타일 검색
!h::WinMinimize("A")		    ; 최소화

;; === 복잡한 로직들 === 
; 해당 창 외 전체 최소화
!#h::						
{			
    try {
        if activeID := WinExist("A") {
            actMon := DllCall("MonitorFromWindow", "Ptr", activeID, "UInt", 2, "Ptr")
            
            for hwnd in WinGetList() {
                ; 가독성을 위해 시스템 창 판단 로직을 분리
                isSystemUI := WinGetClass(hwnd) ~= "Progman|WorkerW|Shell_TrayWnd"
                
                ; 조건이 훨씬 명확해집니다
                if (hwnd != activeID && WinGetTitle(hwnd) != "" && !isSystemUI)
                    if DllCall("MonitorFromWindow", "Ptr", hwnd, "UInt", 2, "Ptr") == actMon
                        WinMinimize(hwnd)
            }
        }
    }
}

; --- Alt + ` (Mac 스타일 동일 앱 내 창 전환) ---
!`::
{
    activeProcess := WinGetProcessName("A")
    ids := WinGetList("ahk_exe " activeProcess)
    
    if (ids.Length > 1)
    {
        ; 정방향: 가장 오래 사용 안 한 창(목록 맨 뒤)을 맨 위로
        lastId := ids[ids.Length]
        WinActivate("ahk_id " lastId)
    }
}

; --- Shift + Alt + ` (역방향 전환) ---
+!`::
{
    activeProcess := WinGetProcessName("A")
    ids := WinGetList("ahk_exe " activeProcess)
    
    if (ids.Length > 1)
    {
        ; 역방향: 현재 창을 목록 맨 뒤로 보내고, 바로 다음 창을 활성화
        WinMoveBottom("A")
        WinActivate("ahk_id " ids[2])
    }
}

; --- 창 관리 (Vim 스타일) ---
^!h::Send("#{Left}")
^!j::Send("#{Down}")
^!k::Send("#{Up}")
^!l::Send("#{Right}")

; 치환
::<>::⇔
::>>::⇒
::<<::⇐
::<->::↔
::->::→
::<-::←
::--::—