âÀ» Æ®·¹ÀÌ ¸Þ´º·Î ÃÖ¼ÒÈ­Çϱâ

ÀÌ ½ºÅ©¸³Æ®´Â ¿©·¯ºÐÀÌ ¼±ÅÃÇÑ ÇÖÅ°¸¦ âÀ» °¨Ãß´Â µ¥ ÇÒ´çÇÕ´Ï´Ù. âÀº ½ºÅ©¸³Æ®ÀÇ Æ®·¹ÀÌ ¸Þ´º ¾Æ·¡¿¡ ¿£Æ®¸®°¡ µË´Ï´Ù. ¼ûÀº âµéÀº °³º°ÀûÀ¸·Î ¶Ç´Â ÇÑ ²¨¹ø¿¡ ¸Þ´º¿¡¼­ »óÀÀÇÏ´Â Ç׸ñÀ» ¼±ÅÃÇØ º¸¿©ÁÙ ¼ö ÀÖ½À´Ï´Ù. ½ºÅ©¸³Æ®°¡ ¾î¶² ÀÌÀ¯·Î Á¾·áÇϸé, ¼û°ÜÁø ¸ðµç âÀº ÀÚµ¿À¸·Î ¼û±è ÇØÁ¦µË´Ï´Ù.

ÀÌ ½ºÅ©¸³Æ® ³»·Á¹Þ±â  |  ´Ù¸¥ »ùÇà ½ºÅ©¸³Æ®  |  È¨À¸·Î

; º¯°æ ÀÌ·Â:
; July 22, 2005 (egilmour°¡ Á¦°øÇÑ º¯°æ):
; - ¸¶Áö¸· ¼ûÀº âÀ» º¸¿©ÁÙ »õ ÇÖÅ° Ãß°¡ (Win+U)
;
; November 3, 2004 (trogdor°¡ Á¦°øÇÑ º¯°æ):
; - ÇÁ·Î±×·¥ °ü¸®ÀÚ°¡ ¼ûÁö ¸øÇϵµ·Ï ¹æÁö.
; - È°¼º âÀÌ ¾ø´Ù¸é, minimize-to-tray ÇÖÅ°°¡ ¹«ÇÑÁ¤ ±â´Ù¸®´Â ´ë½Å¿¡
;   ¾Æ¹« È¿°ú°¡ ¾øµµ·Ï º¯°æ.
;
; October 23, 2004:
; - ŽºÅ©¹Ù°¡ ¼ûÁö ¸øÇϵµ·Ï ¹æÁö.
; - â Á¦¸ñÀÌ ±ä°æ¿ì ¹ß»ý °¡´ÉÇÑ ¹®Á¦µéÀÌ ÇØ°áµÊ.
; - Á¦¸ñ ¾ø´Â âµµ ¾Æ¹« ¹®Á¦ ¾øÀÌ ¼û±æ ¼ö ÀÖÀ½.
; - ½ºÅ©¸³Æ®°¡  AHK v1.0.22 À̻󿡼­ ½ÇÇà ÁßÀ̸é,
;   °¢ ¸Þ´º Ç׸ñÀÇ ÃÖ´ë ±æÀÌÀ» 100¿¡¼­ 260À¸·Î ´Ã¸².

; CONFIGURATION SECTION: ¾Æ·¡ÀÇ °ªÀ» ÀÔ¸À¿¡ ¸Â°Ô ¹Ù²Ù½Ê½Ã¿À.

; ´ÙÀ½Àº ¼û±â±â¸¦ Çã¿ëÇÒ Ã¢ÀÇ ÃÖ´ë °³¼öÀÔ´Ï´Ù.
; (Á¦ÇÑÀ» µÎ¸é ¼öÇ༺´ÉÀÌ Çâ»óµË´Ï´Ù):
mwt_MaxWindows = 50

; È°¼º âÀ» °¨Ãߴµ¥ »ç¿ëµÇ´Â ÇÖÅ°ÀÔ´Ï´Ù:
mwt_Hotkey = #h  ; Win+H

; ¸¶Áö¸· ¼û±è âÀ» º¸¿©ÁÖ´Â µ¥ »ç¿ëµÇ´Â ÇÖÅ°ÀÔ´Ï´Ù:
mwt_UnHotkey = #u  ; Win+U

; Æ®·¹ÀÌ ¸Þ´º¿¡¼­ ¸ðµç Ç¥ÁØ Ç׸ñÀ» ºñ¿ì·Á¸é,
; ¿¹¸¦ µé¾î Help ±×¸®°í Pause¸¦ ºñ¿ì·Á¸é, NÀ» »ç¿ëÇϽʽÿÀ. ±×·¸Áö ¾ÊÀ¸¸é, Y¸¦ »ç¿ëÇϽʽÿÀ:
mwt_StandardMenu = N

; ´ÙÀ½ÀÇ ¸î °¡Áö ¼öÇ༺´ÉÀ» À§ÇÑ ¼³Á¤Àº 
; #HotkeyModifierTimeout ½Ã°£ ¾È¿¡ Á¶Ä¡¸¦ ¸¶Ä¡´Â µ¥ µµ¿òÀÌ µË´Ï´Ù. 
; ±×¸®ÇÏ¿© ÁÖ¿í ´Ã¾î¼± ¿©·¯ âÀ» ÀÏ·Ä·Î °¨Ãß±â À§ÇØ
;  ÇÖÅ°ÀÇ ¼ö½ÄÀÚ¸¦ ¶¼°í ´©¸¦ ÇÊ¿ä°¡ ¾ø½À´Ï´Ù. 
; ´ÙÀ½°ú °°ÀÌ ¼³Á¤Çϸé #InstallKeybdHook ¶Ç´Â ±âŸ ¼ö´ÜÀ» ÅëÇÏ¿©
; ½ºÅ©¸³Æ®¿¡ Å°º¸µå °¥°í¸®¸¦ »ç¿ëÇÒ ÇÊ¿ä°¡ ¾ø½À´Ï´Ù:
#HotkeyModifierTimeout 100
SetWinDelay 10
SetKeyDelay 0

#SingleInstance  ; ÀÌ ½ºÅ©¸³Æ®ÀÇ ½Çü°¡ Çϳª¸¸ ½ÇÇàµÇµµ·Ï Çã¿ëÇÕ´Ï´Ù.

; END OF CONFIGURATION SECTION (ÀÌ ½ÃÁ¡ºÎÅÍ º¯°æÇÏÁö ¸¶½Ê½Ã¿À
; ´Ü, ½ºÅ©¸³Æ®ÀÇ ±âº» ±â´ÉÀ» º¯°æÇÏ°í ½ÍÀº °æ¿ì´Â ¿¹¿ÜÀÔ´Ï´Ù).

Hotkey, %mwt_Hotkey%, mwt_Minimize
Hotkey, %mwt_UnHotkey%, mwt_UnMinimize

; »ç¿ëÀÚ°¡ ¾î¶² ¼ö´ÜÀ¸·Î ½ºÅ©¸³Æ®¸¦ Á¾·áÇϸé, 
; ¸ðµç âÀ» ¸ÕÀú ´Ý½À´Ï´Ù:
OnExit, mwt_RestoreAllThenExit

if mwt_StandardMenu = Y
    Menu, Tray, Add
else
{
    Menu, Tray, NoStandard
    Menu, Tray, Add, E&xit and Unhide All, mwt_RestoreAllThenExit
}
Menu, Tray, Add, &Unhide All Hidden Windows, mwt_RestoreAll
Menu, Tray, Add  ; À§ Ç׸ñÀ» ´õ Ưº°ÇÏ°Ô ¸¸µé¾î ÁÙ ¶Ç´Ù¸¥ °¡¸§ ÁÙ.

if a_AhkVersion =   ; ºñ¾î ÀÖÀ¸¹Ç·Î, ¹öÀüÀÌ 1.0.22 ¹Ì¸¸ÀÔ´Ï´Ù.
    mwt_MaxLength = 100
else
    mwt_MaxLength = 260  ; À̸¦ ÁÙÀÌ¸é ¸Þ´ºÀÇ ³Êºñ¸¦ Á¦ÇÑÇÒ ¼ö ÀÖ½À´Ï´Ù.

return  ; ÀÚµ¿ ½ÇÇà ¼½¼ÇÀÇ ³¡.


mwt_Minimize:
if mwt_WindowCount >= %mwt_MaxWindows%
{
    MsgBox No more than %mwt_MaxWindows% may be hidden simultaneously.
    return
}

; "¸¶Áö¸·À¸·Î ¹ß°ßµÈ â"À» ¼³Á¤ÇØ ¼öÇ༺´ÉÀ» °³¼±ÇÏ°í ÀÏÀ» °£´ÜÇÏ°Ô ¸¸µì´Ï´Ù.
; ¾î¶² °æ¿ì È°¼º âÀÌ ¾øÀ» ¼ö ÀÖÀ¸¹Ç·Î,
; ½Ã°£Á¦ÇÑÀ» Ãß°¡Çß½À´Ï´Ù:
WinWait, A,, 2
if ErrorLevel <> 0  ; ½ÃÇÑ Á¾·á, ±×·¡¼­ ¾Æ¹«°Íµµ ÇÏÁö ¾Ê½À´Ï´Ù.
    return

; ±×·¸Áö ¾ÊÀ¸¸é, "¸¶Áö¸· ¹ß°ß â"À» ¼³Á¤ÇÏ°í ÀÌÁ¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù:
WinGet, mwt_ActiveID, ID
WinGetTitle, mwt_ActiveTitle
WinGetClass, mwt_ActiveClass
if mwt_ActiveClass in Shell_TrayWnd,Progman
{
    MsgBox The desktop and taskbar cannot be hidden.
    return
}
; âÀ» °¨Ã߾ ºñÈ°¼ºÈ­µÇ´Â °ÍÀº ¾Æ´Ï±â ¶§¹®¿¡,
; ÀÌ Ã¢ ¾Æ·¡ÀÇ Ã¢À» È°¼ºÈ­ ÇÕ´Ï´Ù. ´Ù¸¥ ¹æ¹ýÀ» ½ÃµµÇßÁö¸¸, °á°úÀûÀ¸·Î
; ŽºÅ© ¹Ù°¡ È°¼ºÈ­µÇ¾ú½À´Ï´Ù. ÀÌ·± ½ÄÀ¸·Î (¼û±â ¹Ù·Î Á÷ÀüÀÇ) È°¼º âÀ» 
; ½ºÅà µÚ·Î ¹Ð¾î ¹ö¸®´Â ÆíÀÌ °¡Àå ÁÁÀº µí º¸ÀÔ´Ï´Ù:
Send, !{esc}
; Hide it only now that WinGetTitle/WinGetClass above have been run
; (±âº»ÀûÀ¸·Î, ±×·± ¸í·É¾îµéÀº ¼ûÀº âÀ» ŽÁöÇÒ ¼ö ¾ø±â ¶§¹®ÀÔ´Ï´Ù):
WinHide

; Á¦¸ñÀÌ ºñ¾î ÀÖÀ¸¸é, ´ë½Å¿¡ Ŭ·¡½º¸¦ »ç¿ëÇϽʽÿÀ. ÀÌ°ÍÀº µÎ °¡Áö ¸ñÀûÀ¸·Î ±â¿©ÇÕ´Ï´Ù:
; 1) ´õ ÀÇ¹Ì ÀÖ´Â À̸§ÀÌ ¸Þ´º À̸§À¸·Î »ç¿ëµË´Ï´Ù.
; 2) ¸Þ´º Ç׸ñÀ» »ý¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù
;     (±×·¸Áö ¾ÊÀ¸¸é, ºó Ç׸ñÀ» ¾Æ·¡ÀÇ ´Ù¾çÇÑ ·çƾ¿¡¼­ Á¦´ë·Î ´Ù·ê ¼ö ¾ø½À´Ï´Ù).
if mwt_ActiveTitle =
    mwt_ActiveTitle = ahk_class %mwt_ActiveClass%
; Á¦¸ñÀÌ ±æÀÌ°¡ ªÀºÁö È®ÀÎÇÕ´Ï´Ù. 
; mwt_ActiveTitleµµ ¿ª½Ã ÀÌ Æ¯Á¤ÇÑ ¸Þ´º Ç׸ñÀ» À¯ÀÏÇÏ°Ô ½Äº°ÇÏ´Â µ¥ ±â¿©ÇÕ´Ï´Ù.
StringLeft, mwt_ActiveTitle, mwt_ActiveTitle, %mwt_MaxLength%

; Æ®·¹ÀÌ ¸Þ´º°¡ °¢ ¸Þ´º À̸§ÀÌ À¯ÀÏÇϱ⸦ ¿ä±¸ÇÏ´Â ¿Ü¿¡µµ
; ¸Þ´º À̸§ÀÌ À¯ÀÏÇؾ߸¸ ³ªÁß¿¡ âÀÌ ¼ûÀ» ¶§ 
; ¹è¿­¿¡¼­ ¾ÈÀüÇÏ°Ô Ã£À» ¼ö ÀÖ½À´Ï´Ù.
; ±×·¡¼­ ¾ÆÁ÷ ±×·¸Áö ¾Ê´Ù¸é À¯ÀÏÇÏ°Ô ¸¸µå½Ê½Ã¿À:
Loop, %mwt_MaxWindows%
{
    if mwt_WindowTitle%a_index% = %mwt_ActiveTitle%
    {
        ; ºÎÇÕÀÌ ¹ß°ßµÊ. ±×·¡¼­ À¯ÀÏÇÑ °ÍÀÌ ¾Æ´Õ´Ï´Ù.
        ; ¸ÕÀú 0x¸¦ ½ÊÀ°Áø ¼ö¿¡¼­ Á¦°ÅÇØ ¸Þ´º °ø°£À» º¸Á¸ÇÕ´Ï´Ù:
        StringTrimLeft, mwt_ActiveIDShort, mwt_ActiveID, 2
        StringLen, mwt_ActiveIDShortLength, mwt_ActiveIDShort
        StringLen, mwt_ActiveTitleLength, mwt_ActiveTitle
        mwt_ActiveTitleLength += %mwt_ActiveIDShortLength%
        mwt_ActiveTitleLength += 1 ; +1 the 1 space between title & ID.
        if mwt_ActiveTitleLength > %mwt_MaxLength%
        {
            ; ¸Þ´º À̸§ÀÌ ±æÀÌ¿¡ Á¦ÇÑÀÌ Àֱ⠶§¹®¿¡,
            ; Á¦¸ñÀ» ´Ùµë¾î ±×ÀÇ À̸§ µÚ¿¡
            ; âÀÇ Short ID¸¦ À§ÇÑ ÃæºÐÇÑ °ø°£À» È®º¸ÇÕ´Ï´Ù:
            TrimCount = %mwt_ActiveTitleLength%
            TrimCount -= %mwt_MaxLength%
            StringTrimRight, mwt_ActiveTitle, mwt_ActiveTitle, %TrimCount%
        }
        ; À¯ÀÏÇÑ Á¦¸ñÀ» ºôµåÇÕ´Ï´Ù:
        mwt_ActiveTitle = %mwt_ActiveTitle% %mwt_ActiveIDShort%
        break
    }
}

; ¸ÕÀú, ÀÌ ID°¡ ¸®½ºÆ®¿¡ ÀÌ¹Ì Á¸ÀçÇÏÁö ¾Ê´ÂÁö È®ÀÎÇÕ´Ï´Ù.
; ÀÌ·± ÀÏÀº ƯÁ¤ âÀÌ ¿ÜºÎÀûÀ¸·Î º¸ÀÌ°Ô µÇ¸é (¶Ç´Â ±×ÀÇ ¾îÇø®ÄÉÀ̼ÇÀÌ ¼û±èÀ» ÇØÁ¦Çϸé
; ÀϾ ¼ö ÀÖ½À´Ï´Ù. ±×¸®°í ÀÌÁ¦ ´Ù½Ã ¼û±â ÀϺ¸ Á÷ÀüÀÔ´Ï´Ù:
mwt_AlreadyExists = n
Loop, %mwt_MaxWindows%
{
    if mwt_WindowID%a_index% = %mwt_ActiveID%
    {
        mwt_AlreadyExists = y
        break
    }
}

; Ç׸ñÀ» Æ®·¹ÀÌ¿Í ¸Þ´º¿¡ Ãß°¡ÇÕ´Ï´Ù:
if mwt_AlreadyExists = n
{
    Menu, Tray, add, %mwt_ActiveTitle%, RestoreFromTrayMenu
    mwt_WindowCount += 1
    Loop, %mwt_MaxWindows%  ; Search for a free slot.
    {
        ; ¿Ã¹Ù¸£°Ô ¼³°èµÇ¾ú´Ù¸é ¾ðÁ¦³ª ºó °ø°£À» ãÀ» ¼ö ÀÖÀ» °ÍÀÔ´Ï´Ù.
        if mwt_WindowID%a_index% =  ; ºó ½½·ÔÀÌ ¹ß°ßµÇ¾ú½À´Ï´Ù.
        {
            mwt_WindowID%a_index% = %mwt_ActiveID%
            mwt_WindowTitle%a_index% = %mwt_ActiveTitle%
            break
        }
    }
}
return


RestoreFromTrayMenu:
Menu, Tray, delete, %A_ThisMenuItem%
; ¸Þ´º Ç׸ñ À̸§À¸·Î ÀúÀåµÈ À¯ÀÏÇÑ Á¦¸ñ¿¡ ±â¹ÝÇÏ¿© âÀ» ã½À´Ï´Ù:
Loop, %mwt_MaxWindows%
{
    if mwt_WindowTitle%a_index% = %A_ThisMenuItem%  ; ºÎÇÕ ¹ß°ß.
    {
        StringTrimRight, IDToRestore, mwt_WindowID%a_index%, 0
        WinShow, ahk_id %IDToRestore%
        WinActivate ahk_id %IDToRestore%  ; Á¾Á¾ ÇÊ¿ä.
        mwt_WindowID%a_index% =  ; ºñ¿ö¼­ ½½·ÔÀ» Ç®¾îÁÝ´Ï´Ù.
        mwt_WindowTitle%a_index% =
        mwt_WindowCount -= 1
        break
    }
}
return


;; ´ÙÀ½Àº ¸¶Áö¸· ÃÖ¼ÒÈ­ âÀ» ½ºÅÿ¡¼­ ²¨³» º¸¿©ÁÝ´Ï´Ù.
mwt_UnMinimize:
;; ´õ ÀÌ»ó º¸¿©ÁÙ °ÍÀÌ ¾ø´ÂÁö È®ÀÎÇÕ´Ï´Ù.
if mwt_WindowCount > 0 
{
    ;; ¸¶Áö¸· ÃÖ¼Ò Ã¢ÀÇ id¸¦ ¾ò¾î ±×°ÍÀ» º¸¿©ÁÝ´Ï´Ù
    StringTrimRight, IDToRestore, mwt_WindowID%mwt_WindowCount%, 0
    WinShow, ahk_id %IDToRestore%
    WinActivate ahk_id %IDToRestore%
    
    ;; ¸¶Áö¸· ÃÖ¼Ò Ã¢ÀÇ ¸Þ´º À̸§À» ¾ò¾î ±×°ÍÀ» Á¦°ÅÇÕ´Ï´Ù
    StringTrimRight, MenuToRemove, mwt_WindowTitle%mwt_WindowCount%, 0
    Menu, Tray, delete, %MenuToRemove%
    
    ;; ¿ì¸®ÀÇ '¹è¿­'À» Á¤¸®ÇÏ°í â °³¼ö¸¦ ÁÙÀÔ´Ï´Ù
    mwt_WindowID%mwt_WindowCount% =
    mwt_WindowTitle%mwt_WindowCount% = 
    mwt_WindowCount -= 1
}
return


mwt_RestoreAllThenExit:
Gosub, mwt_RestoreAll
ExitApp  ; ÁøÂ¥·Î Á¾·áÇÕ´Ï´Ù.


mwt_RestoreAll:
Loop, %mwt_MaxWindows%
{
    if mwt_WindowID%a_index% <>
    {
        StringTrimRight, IDToRestore, mwt_WindowID%a_index%, 0
        WinShow, ahk_id %IDToRestore%
        WinActivate ahk_id %IDToRestore%  ; Á¾Á¾ ÇÊ¿äÇÔ.
        ; ÀÌ·± ½ÄÀ¸·Î Çϰųª vs. ¸ðµÎ Áö¿ó´Ï´Ù(DeleteAll)
        ; °¡¸§ ÁÙ°ú ù Ç׸ñÀº ±×´ë·Î µÓ´Ï´Ù:
        StringTrimRight, MenuToRemove, mwt_WindowTitle%a_index%, 0
        Menu, Tray, delete, %MenuToRemove%
        mwt_WindowID%a_index% =  ; ºñ¿ö¼­ ½½·ÔÀ» Ç®¾î ÁÝ´Ï´Ù.
        mwt_WindowTitle%a_index% =
        mwt_WindowCount -= 1
    }
    if mwt_WindowCount = 0
        break
}
return