ÅøÆÁ ¸¶¿ì½º ¸Þ´º (XP/2k/NT ¿ä±¸) -- by Rajat

ÀÌ ½ºÅ©¸³Æ®´Â °¡¿îµ¥ ¹öÆ°À» Àá±ñ ´©¸£´Âµ¥ ÀÀ´äÇÏ¿© Æ˾÷ ¸Þ´º¸¦ º¸¿©ÁÝ´Ï´Ù. ¿ÞŬ¸¯ÇÏ¿© ¸Þ´º Ç׸ñÀ» ¼±ÅÃÇÕ´Ï´Ù. ¹Ù±ù¿¡¼­ ÁÂŬ¸¯ÇÏ¸é ¸Þ´º¸¦ Ãë¼ÒÇÕ´Ï´Ù. ÃÖ±Ù¿¡ ¾î´À À¯ÇüÀÇ Ã¢ÀÌ È°¼ºÈ­µÇ¾î Àִ°¡¿¡ µû¶ó ¸Þ´ºÀÇ ³»¿ëÀÌ º¯Çϵµ·Ï °³¼±µÇ¾ú½À´Ï´Ù. (¿©±â¿¡¼­´Â Notepad¿Í Word¸¦ ¿¹Á¦·Î »ç¿ëÇÕ´Ï´Ù).

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

; ¸Þ´º¿¡ ´ëÇÏ¿© ¿©±â¿¡¼­ Á¦¸ñÀ» ¼³Á¤ÇÒ ¼ö ÀÖ½À´Ï´Ù:
MenuTitle = -=-=-=-=-=-=-=-

; ´ÙÀ½Àº ¾ó¸¶³ª ¿À·¡ ¹öÆ°À» ´­·¯¾ß ¸Þ´º¸¦ º¸¿©ÁÙÁö °áÁ¤ÇÕ´Ï´Ù:
UMDelay = 20

SetFormat, float, 0.0
SetBatchLines, 10ms 
SetTitleMatchMode, 2
#SingleInstance


;___________________________________________
;_____¸Þ´º Á¤ÀÇ______________________

; ¿©±â¿¡¼­ ¸Þ´º Ç׸ñÀ» ¸¸µé°í ¼öÁ¤ÇÕ´Ï´Ù.
; keys/values/section À̸§¿¡ ½ºÆäÀ̽º¸¦ »ç¿ëÇÏ¸é ¾È µË´Ï´Ù.

; ¼ø¼­´Â ½Å°æ¾²Áö ¾Ê¾Æµµ µË´Ï´Ù. ¸Þ´º´Â Á¤·ÄµË´Ï´Ù.

MenuItems = Notepad/Calculator/Section 3/Section 4/Section 5


;___________________________________________
;______µ¿ÀûÀÎ ¸Þ´º Ç׸ñ Á¤ÀÇ_______________

; ±¸¹®:
;     Dyn# = ¸Þ´º Ç׸ñ|â Á¦¸ñ

Dyn1 = MS Word|- Microsoft Word
Dyn2 = Notepad II|- Notepad

;___________________________________________

Exit


;___________________________________________
;_____¸Þ´º ¼½¼Ç_________________________

; ¿©±â¿¡ ¸Þ´º ¼½¼ÇÀ» »ý¼ºÇÏ°í ÆíÁýÇÕ´Ï´Ù.

Notepad:
Run, Notepad.exe
Return

Calculator:
Run, Calc
Return

Section3:
MsgBox, You selected 3
Return

Section4:
MsgBox, You selected 4
Return

Section5:
MsgBox, You selected 5
Return

MSWord:
msgbox, this is a dynamic entry (word)
Return

NotepadII:
msgbox, this is a dynamic entry (notepad)
Return


;___________________________________________
;_____ÇÖÅ° ¼½¼Ç________________________

~MButton::
HowLong = 0
Loop
{
    HowLong ++
    Sleep, 10
    GetKeyState, MButton, MButton, P
    IfEqual, MButton, U, Break
}
IfLess, HowLong, %UMDelay%, Return


; µ¿Àû ¸Þ´º¸¦ ÁغñÇÕ´Ï´Ù
DynMenu =
Loop
{
    IfEqual, Dyn%a_index%,, Break

    StringGetPos, ppos, dyn%a_index%, |
    StringLeft, item, dyn%a_index%, %ppos%
    ppos += 2
    StringMid, win, dyn%a_index%, %ppos%, 1000

    IfWinActive, %win%,
        DynMenu = %DynMenu%/%item%
}


; Á¤·ÄµÈ ¸ÞÀÎ ¸Þ´º¿Í µ¿Àû ¸Þ´º¸¦ °áÇÕÇÕ´Ï´Ù
Sort, MenuItems, D/
TempMenu = %MenuItems%%DynMenu%


; ÀÌÀü ¿£Æ®¸®µéÀ» Áö¿ó´Ï´Ù
Loop
{
    IfEqual, MenuItem%a_index%,, Break
    MenuItem%a_index% =
}

; »õ ¿£Æ®¸®µéÀ» »ý¼ºÇÕ´Ï´Ù
Loop, Parse, TempMenu, /
{
    MenuItem%a_index% = %a_loopfield%
}

; ¸Þ´º¸¦ »ý¼ºÇÕ´Ï´Ù
Menu = %MenuTitle%
Loop
{
    IfEqual, MenuItem%a_index%,, Break
    numItems ++
    StringTrimLeft, MenuText, MenuItem%a_index%, 0
    Menu = %Menu%`n%MenuText%
}

MouseGetPos, mX, mY
HotKey, ~LButton, MenuClick
HotKey, ~LButton, On
ToolTip, %Menu%, %mX%, %mY%
WinActivate, %MenuTitle%
Return


MenuClick:
HotKey, ~LButton, Off
IfWinNotActive, %MenuTitle%
{
    ToolTip
    Return
}

MouseGetPos, mX, mY
ToolTip
mY -= 3        ; ù ÁÙÀÌ ½ÃÀÛÇÏ¸é µÚ¿¡ ½ºÆäÀ̽º
mY /= 13    ; °¢ ÁÙ¸¶´Ù ½ºÆäÀ̽º
IfLess, mY, 1, Return
IfGreater, mY, %numItems%, Return
StringTrimLeft, TargetSection, MenuItem%mY%, 0
StringReplace, TargetSection, TargetSection, %a_space%,, A
Gosub, %TargetSection%
Return