</head> <body> <h1>Menu</h1> <p>메뉴와 메뉴 항목을 생성, 삭제, 변경 그리고 보여줍니다. 트레이 아이콘과 그의 툴팁을 변경합니다. <a href="../Scripts.htm#ahk2exe">컴파일된 스크립트</a>의 메인 창을 열지 말지 제어합니다.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, <a href="#SubCommands">SubCommand</a> <span class="optional">, Value1, Value2, Value3, Value4</span></pre> <p>The <em>MenuName</em> parameter can be <code>Tray</code> or the name of any custom menu. 맞춤 메뉴는 그의 이름이 <a href="#Add">Add</a> 부-명령어에 처음 사용될 때 자동으로 생성됩니다. 예를 들어: <code>Menu, MyMenu, Add, Item1</code>. 일단 생성되면, 맞춤 메뉴는 <a href="#Show">Show</a> 부-명령어로 보여줄 수 있습니다. <a href="#Add">Add</a> 부-명령어를 통하여 여러 메뉴에 부메뉴로 부착할 수도 있습니다.</p> <p><em>SubCommand</em>, <em>Value1</em>, <em>Value2</em>, <em>Value3</em> 그리고 <em>Value4</em> 매개변수는 서로 의존적입니다. 그리고 그 사용법은 아래에 기술합니다.</p> <h2 id="toc">목차</h2> <ul> <li><a href="#SubCommands">부-명령어</a></li> <li><a href="#MenuItemName">The <em>MenuItemName</em> Parameter</a></li> <li><a href="#Win32_Menus">Win32 Menus</a></li> <li><a href="#Remarks">논평</a></li> <li><a href="#Related">관련 항목</a></li> <li><a href="#Examples">예제</a></li> </ul> <h2 id="SubCommands">부-명령어</h2> <p>For <em>SubCommand</em>, specify one of the following:</p> <ul> <li><a href="#Add">Add</a>: 항목을 추가하거나, 부메뉴를 새로운 부메뉴 또는 라벨로 갱신하거나 또는 한 항목을 정상 항목에서 부메뉴로 (또는 그 반대로) 변환합니다.</li> <li><a href="#Insert">Insert</a> <span class="ver">[v1.1.23+]</span>: Inserts a new item before the specified menu item.</li> <li><a href="#Delete">Delete</a>: Deletes the specified menu item from the menu.</li> <li><a href="#DeleteAll">DeleteAll</a>: Deletes all custom menu items from the menu.</li> <li><a href="#Rename">Rename</a>: Renames the specified menu item.</li> <li><a href="#Check">Check</a>: Adds a visible checkmark in the menu next to the specified menu item.</li> <li><a href="#Uncheck">Uncheck</a>: Removes the checkmark from the specified menu item.</li> <li><a href="#ToggleCheck">ToggleCheck</a>: Adds a checkmark to the specified menu item; otherwise, removes it.</li> <li><a href="#Enable">Enable</a>: Enables the specified menu item if was previously disabled.</li> <li><a href="#Disable">Disable</a>: Disables the specified menu item.</li> <li><a href="#ToggleEnable">ToggleEnable</a>: Disables the specified menu item; otherwise, enables it.</li> <li><a href="#Default">Default</a>: Changes the menu's default item to be the specified menu item and makes its font bold.</li> <li><a href="#NoDefault">NoDefault</a>: Reverses setting a user-defined default menu item.</li> <li><a href="#Standard">Standard</a>: 표준 메뉴 항목을 메뉴 아래에 삽입합니다.</li> <li><a href="#NoStandard">NoStandard</a>: 모든 표준 메뉴 항목을 트레이 메뉴로부터 제거합니다.</li> <li><a href="#Icon">Icon</a>: Changes the script's tray icon or <span class="ver">[in AHK_L 17+]</span> sets a icon for the specified menu item.</li> <li><a href="#NoIcon">NoIcon</a>: Removes the tray icon or <span class="ver">[in AHK_L 17+]</span> removes the icon from the specified menu item.</li> <li><a href="#Tip">Tip</a>: Changes the tray icon's tooltip.</li> <li><a href="#Show">Show</a>: Displays the specified menu.</li> <li><a href="#Color">Color</a>: Changes the background color of the menu.</li> <li><a href="#Click">Click</a>: Sets the number of clicks to activate the tray menu's default menu item.</li> <li><a href="#MainWindow">MainWindow</a>: Allows the main window of a script to be opened via the tray icon.</li> <li><a href="#NoMainWindow">NoMainWindow</a>: Prevents the main window from being opened via the tray icon.</li> <li><a href="#UseErrorLevel">UseErrorLevel</a>: Skips any warning dialogs and thread terminations whenever the Menu command generates an error.</li> </ul> <h3 id="Add">Add</h3> <p>항목을 추가하거나, 부메뉴를 새로운 부메뉴 또는 라벨로 갱신하거나 또는 한 항목을 정상 항목에서 부메뉴로 (또는 그 반대로) 변환합니다.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Add <span class="optional">, MenuItemName, LabelOrSubmenu, Options</span></pre> <p>이것은 다중 목적의 명령어로서. <em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details). <em>MenuItemName</em>이 아직 존재하지 않으면, 메뉴에 추가됩니다. 그렇지 않으면, <em>MenuItemName</em>은 새로 지정된 <em>LabelOrSubmenu</em>로 갱신됩니다.</p> <p>메뉴 가름줄을 추가하려면, 세 개의 매개변수를 모두 생략하십시오.</p> <p>라벨 서브루틴은 사용자가 메뉴 항목을 선택할 때 새 <a href="../misc/Threads.htm">쓰레드</a>로 실행됩니다 (<a href="Gosub.htm">Gosub</a> 그리고 <a href="../Hotkeys.htm">핫키 서브루틴</a>과 비슷합니다). <em>LabelOrSubmenu</em>를 생략하면, <em>MenuItemName</em>이 라벨과 메뉴 항목의 이름으로 사용됩니다.</p> <p id="Functor"><span class="ver">[v1.1.20+]:</span> 기존의 라벨 이름이 아니면, <em>LabelOrSubmenu</em>는 함수의 이름이거나, 아니면 <a href="../misc/Functor.htm">함수 객체</a>를 담고 있는 단일 변수 참조일 수 있습니다. 예를 들어, <code>%FuncObj%</code> 또는 <code>% FuncObj</code>. See <a href="#ExBoundFunc">example #5</a> for a fully functional demonstration. 함수 객체를 돌려주는 다른 표현식은 현재 지원하지 않습니다. 함수는 아래에 보여주는 바와 같이 선택적으로 매개변수를 정의할 수 있습니다:</p> <pre><i>FunctionName</i>(ItemName, ItemPos, MenuName)</pre> <p><em>MenuItemName</em>를 부메뉴가 되게 만들려면 -- 선택되면 새 메뉴를 여는 메뉴 항목을 만들려면 -- <em>LabelOrSubmenu</em>에 쌍점 그리고 기존 맞춤 메뉴의 <em>MenuName</em>을 지정하십시오. 예를 들어:</p> <pre>Menu, MySubmenu, Add, Item1 Menu, Tray, Add, This menu item is a submenu, :MySubmenu</pre> <p>If not omitted, <em>Options</em> must be a space- or tab-delimited list of one or more of the following options:</p> <table class="info"> <tr> <th>옵션</th> <th abbr="설명">설명</th> </tr> <tr> <td>P<em>n</em></td> <td>Replace <em>n</em> with the menu item's <a href="../misc/Threads.htm">thread priority</a>, e.g. <code>P1</code>. If this option is omitted when adding a menu item, the priority will be 0, which is the standard default. 메뉴 항목을 갱신할 때 생략하면, 항목의 우선순위는 바뀌지 않습니다. 우선 순위에 십진수를 사용하십시오 (십육진수는 불가).</td> </tr> <tr> <td>+Radio</td> <td><span class="ver">[v1.1.23+]:</span> If the item is checked, a bullet point is used instead of a check mark.</td> </tr> <tr> <td>+Right</td> <td><span class="ver">[v1.1.23+]:</span> The item is right-justified within the menu bar. This only applies to <a href="Gui.htm#Menu">menu bars</a>, not popup menus or submenus.</td> </tr> <tr> <td>+Break</td> <td><span class="ver">[v1.1.23+]:</span> The item begins a new column in a popup menu.</td> </tr> <tr> <td>+BarBreak</td> <td><span class="ver">[v1.1.23+]:</span> As above, but with a dividing line between columns.</td> </tr> </table> <p>The plus sign (+) is optional and can be replaced with minus (-) to remove the option, as in <code>-Radio</code>. Options are not case sensitive.</p> <p>To change an existing item's options without affecting its label or submenu, simply omit the <em>LabelOrSubmenu</em> parameter.</p> <h3 id="Insert">Insert <span class="ver">[v1.1.23+]</span></h3> <p>Inserts a new item before the specified menu item.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Insert <span class="optional">, MenuItemName, ItemToInsert, LabelOrSubmenu, Options</span></pre> <p>Usage is identical to the <a href="#Add">Add</a> sub-command (above), except that <em>MenuItemName</em> is always the name or position of an existing menu item (see <a href="#MenuItemName">MenuItemName</a> for details) and <em>ItemToInsert</em> is the name of a new menu item to insert before <em>MenuItemName</em>. Menu items can also be appended by omitting <em>MenuItemName</em> (by writing two consecutive commas). Unlike the <a href="#Add">Add</a> sub-command, the Insert sub-command creates a new menu item even if <em>MenuItemName</em> matches the name of an existing menu item.</p> <h3 id="Delete">Delete</h3> <p>Deletes the specified menu item from the menu.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Delete <span class="optional">, MenuItemName</span></pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details). "Exit" (아래 참조)와 같은 표준 메뉴 항목은 개별적으로 삭제할 수 없습니다. If the <em>default</em> menu item is deleted, the effect will be similar to having used the <a href="#NoDefault">NoDefault</a> sub-command.</p> <p>If <em>MenuItemName</em> is omitted, the entire <em>MenuName</em> menu will be deleted as will any menu items in other menus that use <em>MenuName</em> as a submenu. Deleting a menu also causes the current <a href="#Win32_Menus">Win32 menu</a> of each of its submenus to be destroyed, to be recreated later as needed. Other menus which contain those submenus may also be affected. This can be avoided by deleting the items of the menu with <a href="#DeleteAll">DeleteAll</a> before deleting the menu itself.</p> <h3 id="DeleteAll">DeleteAll</h3> <p>Deletes all custom menu items from the menu.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, DeleteAll</pre> <p>Any existing <em>standard</em> menu items (see below) remain unaffected. <a href="#Delete">Delete</a> 부-명령어로 완전히 삭제되는 메뉴와 다르게 (위 참조), 빈 메뉴는 여전히 존재합니다. 그래서 그 메뉴를 부메뉴로 사용하는 다른 메뉴도 여전히 그 부메뉴를 유지합니다.</p> <h3 id="Rename">Rename</h3> <p>Renames the specified menu item to <em>NewName</em>.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Rename, MenuItemName <span class="optional">, NewName</span></pre> <p>If <em>NewName</em> is blank, the specified menu item will be converted into a separator line. <em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details). 그 메뉴 항목의 현재 목표 라벨이나 부메뉴는 바뀌지 않습니다. <span class="ver">[v1.1.23+]:</span> A separator line can be converted to a normal menu item by specifying the position&amp; of the separator and a non-blank <em>NewName</em>, and then using the <a href="#Add">Add</a> sub-command to give the menu item a label or submenu.</p> <h3 id="Check">Check</h3> <p>Adds a visible checkmark in the menu next to the specified menu item (if there isn't one already).</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Check, MenuItemName</pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details).</p> <h3 id="Uncheck">Uncheck</h3> <p>Removes the checkmark (if there is one) from the specified menu item.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Uncheck, MenuItemName</pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details).</p> <h3 id="ToggleCheck">ToggleCheck</h3> <p>Adds a checkmark to the specified menu item if there wasn't one; otherwise, removes it.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, ToggleCheck, MenuItemName</pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details).</p> <h3 id="Enable">Enable</h3> <p>Allows the user to once again select the specified menu item if was previously disabled (grayed).</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Enable, MenuItemName</pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details).</p> <h3 id="Disable">Disable</h3> <p>Changes the specified menu item to a gray color to indicate that the user cannot select it.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Disable, MenuItemName</pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details).</p> <h3 id="ToggleEnable">ToggleEnable</h3> <p>Disables the specified menu item if it was previously enabled; otherwise, enables it.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, ToggleEnable, MenuItemName</pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details).</p> <h3 id="Default">Default</h3> <p>Changes the menu's default item to be the specified menu item and makes its font bold.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Default <span class="optional">, MenuItemName</span></pre> <p>TRAY 말고 메뉴에 기본 항목을 설정하는 것은 순전히 장식적인 효과입니다. <em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details). 사용자가 트레이 아이콘을 클릭할 때, 그의 기본 메뉴 항목이 기동됩니다. 기본 항목이 없다면, 더블클릭해도 아무 효과가 없습니다. If <em>MenuItemName</em> is omitted, the effect is the same as having used the <a href="#NoDefault">NoDefault</a> sub-command below.</p> <h3 id="NoDefault">NoDefault</h3> <p>Reverses setting a user-defined default menu item.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, NoDefault</pre> <p>트레이 메뉴에 대하여: Changes the menu back to having its standard default menu item, which is OPEN for non-compiled scripts and none for <a href="../Scripts.htm#ahk2exe">compiled scripts</a> (except when the <a href="#MainWindow">MainWindow</a> sub-command is in effect). 이전에 <a href="#NoStandard">NoStandard</a> 부-명령어를 사용했기 때문에 (아래 참조) OPEN 메뉴 항목이 존재하지 않으면, 기본 항목이 없으므로 트레이 아이콘을 더블 클릭해도 아무 효과가 없습니다. TRAY 말고 다른 메뉴에 대하여: 기존의 기본 항목에는 볼드체가-아닌 글꼴을 돌려줍니다.</p> <h3 id="Standard">Standard</h3> <p>표준 메뉴 항목을 (아직 존재하지 않으면) 메뉴 아래에 삽입합니다.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Standard</pre> <p>이 부-명령어는 트레이 메뉴나 기타 메뉴에 사용될 수 있습니다.</p> <h3 id="NoStandard">NoStandard</h3> <p>Removes all standard (non-custom) menu items from the menu (if they are present).</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, NoStandard</pre> <p>이 부-명령어는 트레이 메뉴나 기타 메뉴에 사용될 수 있습니다.</p> <h3 id="Icon">Icon</h3> <p>Affects the <a href="#TrayIcon">tray icon</a> or <span class="ver">[in AHK_L 17+]</span> the <a href="#MenuIcon">menu item's icon</a> depending on syntax usage below.</p> <h4 id="TrayIcon">Setting the tray icon</h4> <p>Changes the script's <a href="../Program.htm#tray-icon">tray icon</a> to one of the ones from <em>FileName</em>.</p> <pre class="Syntax"><span class="func">Menu</span>, Tray, Icon <span class="optional">, FileName, IconNumber, 1</span></pre> <p>다음 유형의 파일을 지원합니다: ICO, CUR, ANI, EXE, DLL, CPL, SCR, 그리고 아이콘 자원을 담은 기타 유형들. 파일에서 첫 번째 아이콘 말고 아이콘 그룹을 사용하려면, 그 번호를 <em>IconNumber</em>에 지정하십시오 (생략하면, 기본 값은 1입니다). 예를 들어, <strong>2</strong>이면 기본 아이콘을 두 번째 아이콘 그룹으로부터 적재할 것입니다. <em>IconNumber</em>가 음수이면, 그의 절대 값은 실행 파일 안의 아이콘의 자원 ID로 간주됩니다. 별표 (*)를 <em>FileName</em>에 지정하면 스크립트를 기본 아이콘으로 복구할 수 있습니다.</p> <p>마지막 매개변수: 1을 지정하면 아이콘을 동결합니다. 또는 0이면 그 아이콘을 해동합니다 (또는 비워 두면 동결/해동 상태를 바꾸지 않고 그대로 유지할 수 있습니다). 아이콘이 동결될 때, <a href="Pause.htm">Pause</a>와 <a href="Suspend.htm">Suspend</a>는 그것을 바꾸지 않습니다. 주의: <em>현재 아이콘</em>을 동결하거나 해동하려면, 1 또는 0을 다음 예제와 같이 사용하십시오: <code>Menu, Tray, Icon,,, 1</code>.</p> <p>트레이 아이콘을 변경하면 <a href="InputBox.htm">InputBox</a>, <a href="Progress.htm">Progress</a>, 그리고 이어서-생성되는 <a href="Gui.htm">GUI</a> 창이 보여주는 아이콘도 변경됩니다. <a href="../Scripts.htm#ahk2exe">컴파일된 스크립트</a>도 영향을 받습니다. 컴파일할 때 맞춤 아이콘을 지정했더라도 마찬가지입니다.</p> <p class="note"><strong>주의:</strong> 아이콘을 변경하더라도 트레이 아이콘은 언하이드되지 않습니다. 이전에 <a href="_NoTrayIcon.htm">#NoTrayIcon</a>과 같은 수단으로 숨겼다면 말입니다; 언하이드 하려면, (매개변수 없이) <code>Menu, Tray, Icon</code>를 사용하십시오.</p> <p id="distort">.ICO 말고 다른 유형으로부터 트레이 아이콘을 적재할 때 약간 왜곡이 발생할 수 있습니다. 특히 16x16 아이콘이 그렇습니다. 이를 피하려면, 원하는 트레이 아이콘을 .ICO 파일에 저장하십시오.</p> <p>어떤 아이콘들은 운영 체제의 DLL과 CPL에 내장되어 있어서 유용합니다. 예를 들어: <code>Menu, Tray, Icon, Shell32.dll, 174</code>.</p> <p>내장 변수 <strong>A_IconNumber</strong>와 <strong>A_IconFile</strong>에는 현재 아이콘의 번호와 (완전한 경로) 이름이 들어 있습니다 (기본 아이콘이면 둘 다 비어 있습니다).</p> <p><span class="ver">[v1.1.23+]:</span> An <a href="../misc/ImageHandles.htm">icon handle</a> can be used instead of a filename. For example, <code>Menu Tray, Icon, HICON:*%handle%</code>. The asterisk is required as the icon must be "loaded" twice: once for the small icon and again for the large icon.</p> <p><span class="ver">[v1.1.27+]:</span> Non-icon image files and <a href="../misc/ImageHandles.htm">bitmap handles</a> are supported for <em>Filename</em>. 예를 들어, <code>Menu Tray, Icon, HBITMAP:*%handle%</code>.</p> <h4 id="MenuIcon">Setting the menu item's icon <span class="ver">[AHK_L 17+]</span></h4> <p>Sets a icon for the specified menu item.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Icon, MenuItemName, FileName <span class="optional">, IconNumber, IconWidth</span></pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details). <em>FileName</em>은 아이콘 파일이거나 AutoHotkey가 지원하는 형식이 이미지일 수 있습니다. 파일에서 첫 번째 아이콘 말고 아이콘 그룹을 사용하려면, 그 번호를 <em>IconNumber</em>에 지정하십시오 (생략하면, 기본 값은 1입니다). <em>IconNumber</em>가 음수이면, 그의 절대값이 실행 파일 안에 있는 아이콘의 자원 ID라고 간주됩니다. 아이콘의 너비는 <em>IconWidth</em>에 지정하십시오. <em>IconNumber</em>이 나타내는 아이콘 그룹 안에 여러 아이콘 크기가 있다면, 가장 근접하게 부합하는 아이콘이 사용되고 그 아이콘이 지정된 크기에 맞게 조절됩니다. See <a href="#ExIcon">example #4</a> for usage examples.</p> <p>현재 Windows Vista 이후에서 아이콘에 투명성을 유지하도록 설정하려면 "실제 크기"를 지정하는 것이 필요합니다. 예를 들어:</p> <pre>Menu, <i>MenuName</i>, Icon, <i>MenuItemName</i>, Filename.png,, 0</pre> <p>알려진 한계: Gui 메뉴 바의 아이콘들은 Windows XP 이전에서 올바르게 배치되지 않습니다.</p> <p><span class="ver">[v1.1.23+]:</span> A <a href="../misc/ImageHandles.htm">bitmap or icon handle</a> can be used instead of a filename. 예를 들어, <code>HBITMAP:%handle%</code>.</p> <h3 id="NoIcon">NoIcon</h3> <p>Affects the <a href="#RemoveTrayIcon">tray icon</a> or <span class="ver">[in AHK_L 17+]</span> the <a href="#RemoveMenuIcon">menu item's icon</a> depending on syntax usage below.</p> <h4 id="RemoveTrayIcon">Removing the tray icon</h4> <p>트레이 아이콘이 존재하면 제거합니다.</p> <pre class="Syntax"><span class="func">Menu</span>, Tray, NoIcon</pre> <p>이 부-명령어를 스크립트 맨 꼭대기에 사용하면, 스크립트가 기동할 때 트레이 아이콘이 잠깐 보일 수 있습니다. 이를 피하려면 , 대신 <a href="_NoTrayIcon.htm">#NoTrayIcon</a>을 사용하십시오. 트레이 아이콘이 현재 숨어 있으면 내장 변수 <strong>A_IconHidden</strong> 안에 1이 담깁니다. 그렇지 않으면 0이 담깁니다.</p> <h4 id="RemoveMenuIcon">Removing the menu item's icon <span class="ver">[AHK_L 17+]</span></h4> <p>Removes the icon from the specified menu item, if any.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, NoIcon, MenuItemName</pre> <p><em>MenuItemName</em> is the name or position of a menu item (see <a href="#MenuItemName">MenuItemName</a> for details).</p> <h3 id="Tip">Tip</h3> <p>Changes the tray icon's tooltip.</p> <pre class="Syntax"><span class="func">Menu</span>, Tray, Tip <span class="optional">, Text</span></pre> <p>The tray icon's tooltip is displayed when the mouse hovers over it. 여러-줄 툴팁을 생성하려면, 각 줄 사이에 라인피드 (`n) 문자를 사용하십시오. 예, "Line1`nLine2". <em>Text</em>에서 앞쪽 127 개만 보여줍니다. 그리고 <em>Text</em>는 (존재하면) 첫 번째 탭 문자에서 잘려 나갑니다. <em>Text</em>를 생략하면, 툴팁은 그의 기본 텍스트로 복구됩니다. 내장 변수 <strong>A_IconTip</strong>에는 툴팁의 현재 텍스트가 담깁니다 (텍스트가 기본 값이면 비어 있습니다).</p> <h3 id="Show">Show</h3> <p>Displays <em>MenuName</em>.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Show <span class="optional">, X, Y</span></pre> <p>The user can select an item with arrow keys, menu shortcuts (underlined letters), or the mouse. 어떤 메뉴도 보여줄 수 있습니다. 여기에는 트레이 메뉴도 포함되지만, <a href="Gui.htm">GUI</a> 메뉴 바는 예외입니다. X와 Y를 모두 생략하면, 메뉴는 마우스 커서의 현재 위치에 보여집니다. 둘 중에 하나만 생략하면, 생략된 위치에 마우스 커서의 위치가 대신 사용됩니다. X와 Y는 활성 창에 상대적입니다. Specify <code><a href="CoordMode.htm">CoordMode</a>, Menu</code> beforehand to make them relative to the entire screen.</p> <h3 id="Color">Color</h3> <p>Changes the background color of the menu to <em>ColorValue</em>.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, Color, ColorValue <span class="optional">, Single</span></pre> <p><em>ColorValue</em> is one of the 16 primary HTML color names or a 6-digit RGB color value (see <a href="Progress.htm#colors">color chart</a>). <em>ColorValue</em>를 비워 두면 (또는 단어 Default를 지정하면) 메뉴를 그의 기본 컬러로 복구할 수 있습니다. 단어 Single이 다음 매개변수에 존재하지 않으면, 이 메뉴에 부착된 부메뉴들도 모두 색이 바뀝니다.</p> <h3 id="Click">Click</h3> <p>Sets the number of clicks to activate the tray menu's default menu item.</p> <pre class="Syntax"><span class="func">Menu</span>, Tray, Click, ClickCount</pre> <p>1을 <em>ClickCount</em>에 지정하면 한 번 클릭으로 트레이 메뉴의 기본 메뉴 항목을 활성화 할 수 있습니다. 2를 <em>ClickCount</em>에 지정하면 (더블-클릭해) 기본 행위로 돌아올 수 있습니다. 예를 들어: <code>Menu, Tray, Click, 1</code>.</p> <h3 id="MainWindow">MainWindow</h3> <p>Allows the <a href="../Program.htm#main-window">main window</a> of a script to be opened via the tray icon, which is impossible by default for <a href="../Scripts.htm#ahk2exe">compiled</a> or <a href="../Program.htm#embedded-scripts">embedded</a> scripts.</p> <pre class="Syntax"><span class="func">Menu</span>, Tray, MainWindow</pre> <p>This sub-command restores the "Open" option to the tray menu, unless the <a href="#NoStandard">NoStandard</a> sub-command was used. 또한 예를 들어 "최근에 실행된 줄"과 같이, 메인 창의 View 메뉴에 있는 항목들을 활성화 합니다. 이 메뉴는 스크립트의 소스 코드와 기타 정보를 보여줍니다.</p> <p>This mode is the default for scripts which are neither <a href="../Scripts.htm#ahk2exe">compiled</a> nor <a href="../Program.htm#embedded-scripts">embedded</a>.</p> <h3 id="NoMainWindow">NoMainWindow</h3> <p>Prevents the <a href="../Program.htm#main-window">main window</a> from being opened via the tray icon.</p> <pre class="Syntax"><span class="func">Menu</span>, Tray, NoMainWindow</pre> <p>This sub-command removes the standard "Open" option from the tray menu. It also disables the items in the main window's View menu such as "Lines most recently executed". However, the following commands are still able to show the main window and activate the corresponding View options when they are encountered in the script at runtime: <a href="ListLines.htm">ListLines</a>, <a href="ListVars.htm">ListVars</a>, <a href="ListHotkeys.htm">ListHotkeys</a>, 그리고 <a href="KeyHistory.htm">KeyHistory</a>.</p> <p>This sub-command does not prevent the main window from being shown by <a href="WinShow.htm">WinShow</a> or inspected by <a href="ControlGetText.htm">ControlGetText</a> or similar methods, but it does prevent the script's source code and other info from being exposed via the main window, except when one of the commands listed above is called by the script.</p> <p>This mode is the default for scripts which are <a href="../Scripts.htm#ahk2exe">compiled</a> or <a href="../Program.htm#embedded-scripts">embedded</a>.</p> <p><span class="ver">[v1.1.34+]:</span> This sub-command can be used even in a non-compiled script.</p> <h3 id="UseErrorLevel">UseErrorLevel</h3> <p>Skips any warning dialogs and thread terminations whenever the Menu command generates an error.</p> <pre class="Syntax"><span class="func">Menu</span>, MenuName, UseErrorLevel <span class="optional">, Off</span></pre> <p>이 옵션이 스크립트에 사용되지 않으면, 기본 값은 OFF입니다. OFF 설정은 Menu 명령어가 에러를 발생시킬 때마다 대화상자를 보여주고 <a href="../misc/Threads.htm">현재 쓰레드</a>를 종료합니다. <code>Menu, Tray, UseErrorLevel</code>를 지정하면 그 대화상자와 쓰레드 종료를 막을 수 있습니다; 대신에, <a href="../misc/ErrorLevel.htm">ErrorLevel</a>은 문제가 있으면 1이 없으면 0이 설정됩니다. To turn this option back off, specify OFF (or in <span class="ver">[v1.1.30+]</span>, 0) for the next parameter. 이 설정은 전역적입니다. <em>MenuName</em>은 물론이고, 모든 메뉴에 영향을 미친다는 뜻입니다.</p> <h2 id="MenuItemName">The <em>MenuItemName</em> Parameter</h2> <p>The name or position of a menu item. Some common rules apply to this parameter across all sub-commands which use it:</p> <ul> <li>메뉴 항목 의 이름에 있는 글자 중 하나에 밑줄을 그으려면, 그 글자 앞에 앰퍼센드를 (&amp;) 배치하십시오. 메뉴가 나타날 때, 그런 항목은 키보드에서 상응하는 키를 눌러서 선택할 수 있습니다. 글자 그대로 앰퍼센드를 보여주려면, 연속적으로 앰퍼센드 두 개를 다음 예제와 같이 지정하십시오: <code class="no-highlight">Save &amp;&amp; Exit</code></li> <li>기존의 메뉴나 메뉴 항목을 참조할 때, 그 이름은 대소문자를 구별하지 않지만 앰퍼센드는 반드시 포함시켜야 합니다. 예를 들어: <code class="no-highlight">&amp;Open</code></li> <li><span class="ver">[v1.1.23+]:</span> To identify an existing item by its position in the menu, write the item's position followed by an ampersand. For example, <code class="no-highlight">1&amp;</code> indicates the first item.</li> </ul> <h2 id="Win32_Menus">Win32 Menus</h2> <p>As items are added to a menu or modified, the name and other properties of each item are recorded by the Menu command, but the actual <a href="https://msdn.microsoft.com/ko-kr/library/ms646977">Win32 menu</a> is not constructed immediately. This occurs when the menu or its parent menu is attached to a GUI or shown, either for the first time or if the menu has been "destroyed" since it was last shown. Any of the following can cause this Win32 menu to be destroyed:</p> <ul> <li>Deleting a menu.</li> <li>Replacing an item's submenu with a label or a different menu.</li> <li>Prior to <span class="ver">[v1.1.27.03]</span>, calling the sub-commands <a href="#NoStandard">NoStandard</a> (if the standard items were present) or <a href="#DeleteAll">DeleteAll</a>.</li> </ul> <p>When the Win32 menu is destroyed, the Win32 menu of each submenu and parent menu may also be destroyed.</p> <p>When a menu which contains the standard items has its Win32 menu recreated, the standard items are placed at the top.</p> <p>Any modifications which are made to the menu directly by Win32 API calls only apply to the current "instance" of the menu, and are lost when the menu is destroyed.</p> <p>Each menu item is assigned an ID when it is first added to the menu. Scripts cannot rely on an item receiving a particular ID, but can retrieve the ID of an item by using GetMenuItemID as shown in the <a href="MenuGetHandle.htm#Examples">MenuGetHandle example</a>. This ID cannot be used with the Menu command, but can be used with various <a href="https://msdn.microsoft.com/ko-kr/library/ms646977">Win32 functions</a>.</p> <h2 id="Remarks">논평</h2> <p>A menu usually looks like this:</p> <img src="../static/ctrl_menu.png" alt="Menu" style="border: 1px solid silver;" /> <p>메뉴와 메뉴 항목의 이름은 최대 260 문자까지 허용됩니다.</p> <p>가름 줄은 <code>Menu, <i>MenuName</i>, Add</code>를 사용하면 메뉴에 추가할 수 있습니다 (즉, 다른 모든 매개변수 생략). <span class="ver">[v1.1.23+]</span>: To delete separator lines individually, identify them by their position in the menu. For example, use <code>Menu, <i>MenuName</i>, Delete, 3&amp;</code> if there are two items preceding the separator. Alternatively, use <code>Menu, <i>MenuName</i>, DeleteAll</code> and then re-add your custom menu items.</p> <p>새 메뉴 항목은 언제나 메뉴 아래에 추가됩니다. 트레이 메뉴에 대하여: 여러분이 메뉴 항목을 표준 메뉴 항목보다 위에 놓으려면 (여러분의 메뉴 항목을 추가한 후) <code>Menu, Tray, NoStandard</code>를 실행한 다음에 <code>Menu, Tray, Standard</code>를 실행하십시오.</p> <p>"Pause Script" 그리고 "Suspend Hotkeys"와 같은 표준 메뉴 항목은 메뉴 부-명령어로 개별적으로 작동시킬 수 없습니다.</p> <p>메뉴가 완전히 비게 되면 -- 예를 들어 <code>Menu, MyMenu, DeleteAll</code>을 사용하여 -- 보여줄 수 없습니다. 트레이 메뉴가 비게 되면, 트레이 아이콘에 우클릭과 더블클릭이 아무 효과가 없습니다 (그런 경우 보통 <a href="_NoTrayIcon.htm">#NoTrayIcon</a>을 사용하는 편이 더 좋습니다).</p> <p>메뉴 항목의 서브루틴이 이미 실행 중이고 사용자가 같은 메뉴를 다시 선택한다면, 새 <a href="../misc/Threads.htm">쓰레드</a>가 생성되고 이전의 쓰레드를 가로채어 같은 서브루틴을 실행합니다. 대신에 그런 이벤트를 나중으로 버퍼 처리하려면, <a href="Critical.htm">Critical</a>을 서브루틴의 첫 줄에 사용하십시오 (그렇지만, 이렇게 하면 또 핫키 누름과 같은 다른 쓰레드도 역시 버퍼/연기 처리됩니다).</p> <p>서브루틴이 메뉴 항목을 통하여 기동할 때마다 그 서브루틴은 예를 들어 <a href="SendMode.htm">SendMode</a>에 설정된 기본 값을 가지고 새롭게 시작합니다. 이런 기본 값은 <a href="../Scripts.htm#auto">자동-실행 섹션</a>에서 바꿀 수 있습니다.</p> <p>내장 변수 <strong>A_ThisMenuItem</strong> 그리고 <strong>A_ThisMenuItemPos</strong>에 사용자가 최근에 선택한 맞춤 메뉴 항목의 이름과 위치가 담겨 있습니다 (비어 있으면 선택 없음). 비슷하게, <strong>A_ThisMenu</strong>는 <strong>A_ThisMenuItem</strong>가 선택된 메뉴의 이름입니다. 이런 변수들은 내용이 언제나 같지 않은 메뉴를 구성할 때 유용합니다. 그런 경우, 보통 그런 모든 메뉴 항목이 같은 라벨을 가리키도록 만들고 그 라벨이 위의 변수들을 참조해서 어떤 행위를 취할지 결정하는 것이 좋습니다.</p> <p>비-핫키, 비-<a href="Gui.htm">GUI</a> 스크립트를 계속 실행되도록 유지하려면 -- 예를 들어 오직 맞춤 메뉴나 메뉴 항목만 담고 있는 스크립트 -- <a href="_Persistent.htm">#Persistent</a>를 사용하십시오.</p> <h2 id="Related">관련 항목</h2> <p><a href="Gui.htm">GUI</a>, <a href="../misc/Threads.htm">Threads</a>, <a href="Thread.htm">Thread</a>, <a href="Critical.htm">Critical</a>, <a href="_NoTrayIcon.htm">#NoTrayIcon</a>, <a href="Gosub.htm">Gosub</a>, <a href="Return.htm">Return</a>, <a href="SetTimer.htm">SetTimer</a>, <a href="_Persistent.htm">#Persistent</a></p> <h2 id="Examples">예제</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> 새 메뉴 항목을 트레이 아이콘 메뉴의 아래에 부착합니다.</p> <pre>#Persistent <em>; 사용자가 종료할 때까지 스크립트의 실행을 계속 유지합니다.</em> Menu, Tray, Add <em>; 가름 줄을 만듭니다.</em> Menu, Tray, Add, Item1, MenuHandler <em>; 새 메뉴 항목을 만듭니다.</em> return MenuHandler: MsgBox You selected %A_ThisMenuItem% from menu %A_ThisMenu%. return</pre> </div> <div class="ex" id="ExPopup"> <p><a class="ex_number" href="#ExPopup"></a> Creates a popup menu that is displayed when the user presses a hotkey.</p> <pre><em>; 약간의 항목을 부착해서 팝업 메뉴를 생성합니다.</em> Menu, MyMenu, Add, Item1, MenuHandler Menu, MyMenu, Add, Item2, MenuHandler Menu, MyMenu, Add <em>; Add a separator line.</em> <em>; 위의 메뉴의 부메뉴가 될 또다른 메뉴를 생성합니다.</em> Menu, Submenu1, Add, Item1, MenuHandler Menu, Submenu1, Add, Item2, MenuHandler <em>; 첫 번째 메뉴에 부메뉴를 하나 생성합니다 (오른쪽 화살표 표시). 사용자가 그것을 선택하면, 두 번째 메뉴가 보여집니다.</em> Menu, MyMenu, Add, My Submenu, :Submenu1 Menu, MyMenu, Add <em>; 그 부메뉴 아래에 가름 줄을 추가합니다.</em> Menu, MyMenu, Add, Item3, MenuHandler <em>; 그 부메뉴 아래에 또다른 메뉴 항목을 추가합니다.</em> return <em>; 스크립트의 자동 실행 섹션이 끝났습니다.</em> MenuHandler: MsgBox You selected %A_ThisMenuItem% from the menu %A_ThisMenu%. return #z::Menu, MyMenu, Show <em>; 즉, Win-Z 핫키를 누르면 메뉴가 나타납니다.</em></pre> </div> <div class="ex" id="ExTray"> <p><a class="ex_number" href="#ExTray"></a> 다양한 메뉴 부-명령어의 예를 보여줍니다.</p> <pre>#Persistent #SingleInstance Menu, Tray, Add <em>; 가름 줄</em> Menu, Tray, Add, TestToggle&amp;Check Menu, Tray, Add, TestToggleEnable Menu, Tray, Add, TestDefault Menu, Tray, Add, TestStandard Menu, Tray, Add, TestDelete Menu, Tray, Add, TestDeleteAll Menu, Tray, Add, TestRename Menu, Tray, Add, Test return <em>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</em> TestToggle&amp;Check: Menu, Tray, ToggleCheck, TestToggle&amp;Check Menu, Tray, Enable, TestToggleEnable <em>; 다음 테스트도 활성화 됩니다. 자기 자신을 끈 것은 언두할 수 없기 때문입니다.</em> Menu, Tray, Add, TestDelete <em>; 위와 비슷합니다.</em> return TestToggleEnable: Menu, Tray, ToggleEnable, TestToggleEnable return TestDefault: if (Default = "TestDefault") { Menu, Tray, NoDefault Default := "" } else { Menu, Tray, Default, TestDefault Default := "TestDefault" } return TestStandard: if (Standard != false) { Menu, Tray, NoStandard Standard := false } else { Menu, Tray, Standard Standard := true } return TestDelete: Menu, Tray, Delete, TestDelete return TestDeleteAll: Menu, Tray, DeleteAll return TestRename: if (NewName != "renamed") { OldName := "TestRename" NewName := "renamed" } else { OldName := "renamed" NewName := "TestRename" } Menu, Tray, Rename, %OldName%, %NewName% return Test: MsgBox, You selected "%A_ThisMenuItem%" in menu "%A_ThisMenu%". return</pre> </div> <div class="ex" id="ExIcon"> <p><a class="ex_number" href="#ExIcon"></a> Demonstrates how to add icons to menu items.</p> <pre>Menu, FileMenu, Add, Script Icon, MenuHandler Menu, FileMenu, Add, Suspend Icon, MenuHandler Menu, FileMenu, Add, Pause Icon, MenuHandler Menu, FileMenu, Icon, Script Icon, %A_AhkPath%, 2 <em>; 파일로부터 두 번째 아이콘 그룹을 사용합니다.</em> Menu, FileMenu, Icon, Suspend Icon, %A_AhkPath%, -206 <em>; 자원 식별자가 206인 아이콘을 사용합니다.</em> Menu, FileMenu, Icon, Pause Icon, %A_AhkPath%, -207 <em>; 자원 식별자가 207인 아이콘을 사용합니다.</em> Menu, MyMenuBar, Add, &amp;File, :FileMenu Gui, Menu, MyMenuBar Gui, Add, Button, gExit, Exit This Example Gui, Show return MenuHandler: return Exit: ExitApp </pre> </div> <div class="ex" id="ExBoundFunc"> <p><a class="ex_number" href="#ExBoundFunc"></a> Demonstrates the usage of <a href="../misc/Functor.htm#BoundFunc">BoundFunc objects</a> to pass additional parameters when using a function instead of a subroutine.</p> <pre><em>; Bind parameters to the function and return BoundFunc objects:</em> BoundGivePar := Func("GivePar").Bind("First", "Test one") BoundGivePar2 := Func("GivePar").Bind("Second", "Test two") <em>; Create the menu and show it:</em> Menu MyMenu, Add, Give parameters, % BoundGivePar Menu MyMenu, Add, Give parameters2, % BoundGivePar2 Menu MyMenu, Show <em>; Definition of custom function GivePar:</em> GivePar(a, b, ItemName, ItemPos, MenuName) { MsgBox % "a:`t`t" a "`n" . "b:`t`t" b "`n" . "ItemName:`t" ItemName "`n" . "ItemPos:`t`t" ItemPos "`n" . "MenuName:`t" MenuName }</pre> </div> </body> </html>