Windows Server 2016 中 Windows 主控台的新功能What's New in the Windows Console in Windows Server 2016

適用於︰Windows Server 2016Applies To: Windows Server 2016

主控台主機 (支援所有字元模式應用程式,包括 Windows 命令提示字元、Windows PowerShell 命令提示字元等的基礎程式碼) 已利用數種方式更新,以新增各種不同的新功能。The console host (the underlying code that supports all character-mode applications including the Windows command prompt, the Windows PowerShell prompt, and others) has been updated in several ways to add a variety of new capabilities.

控制新功能Controlling the new features

新功能預設將會啟用,但您可以透過 [內容] 介面 (大部分位於 [選項] 索引標籤上),或使用這些登錄機碼 (所有機碼都是位於 HKEY_CURRENT_USER\Console 下的 DWORD 值) 來開啟和關閉各項新功能,或是還原為先前的主控台主機:The new functionality is enabled by default, but you can switch each of the new features on and off or revert to the previous console host either through the Properties interface (mostly on the Options tab) or with these Registry keys (all keys are DWORD values under HKEY_CURRENT_USER\Console):

登錄機碼Registry key 描述Description
ForceV2ForceV2 1 會啟用所有新主控台功能;0 會停用所有新功能。1 enables all new console features; 0 disables all new features. 注意︰此值不會儲存在捷徑中,而只會儲存在此登錄機碼中。Note: this value is not stored in shortcuts, but only in this Registry key.
LineSelectionLineSelection 1 會啟用線路選擇;0 會僅使用區塊模式1 enables line selection; 0 to use block mode only
FilterOnPasteFilterOnPaste 1 會啟用新的貼上行為1 enables new paste behavior
LineWrapLineWrap 1 會在您調整主控台視窗大小時將文字換行1 wraps text when you resize console windows
CtrlKeyShortcutsDisabledCtrlKeyShortcutsDisabled 0 會啟用新的快速鍵;1 會予以停用0 enables new key shortcuts; 1 disables them
ExtendedEdit KeysExtendedEdit Keys 1 會啟用整組鍵盤選取按鍵;0 會予以停用1 enables the full set of keyboard selection keys; 0 disables them
TrimLeadingZerosTrimLeadingZeros 1 會修剪按兩下所選取項目中的前置字元「零」;0 會保留前置字元「零」1 trims leading zeroes in selections made by double-clicking; 0 keeps the leading zeros
WindowsAlphaWindowsAlpha 設定介於 30% 到 100% 之間的不透明度值。Sets opacity value between 30% and 100%. 請使用 0x4C 到 0xFF 或 76 到 255 來指定值Use 0x4C to 0xFF or 76 to 255 to specify value
WordDelimitersWordDelimiters 定義用來在使用 CTRL+SHIFT+ARROW 以一次選取整個單字的方式來選取文字時,用來進行跳過的字元 (預設是空白字元)。Defines the character that is used to skip to when selecting text a whole word at a time with CTRL+SHIFT+ARROW (the default is the space character). 設定此 REG_SZ 值以包含您想要視為分隔符號的所有字元。Set this REG_SZ value to contain all characters you want to be treated as delimiters. 注意︰此值不會儲存在捷徑中,而只會儲存在此登錄機碼中。Note: this value is not stored in shortcuts, but only in this Registry key.

這些設定會在 [HKCU\Console] 下的 [登錄] 中,根據每個視窗標題分別儲存。These settings are stored per each window title in the Registry under HKCU\Console. 捷徑所開啟的主控台視窗會將這些設定儲存在捷徑當中;如果將捷徑複製到另一部電腦,設定也會隨著移至新電腦。Console windows opened by a shortcut have these settings stored in the shortcut; if the shortcut is copied to another computer, the settings move with it to the new computer. 捷徑中的設定會覆寫所有其他設定,包括全域設定和預設值。Settings in shortcuts override all other settings, including global settings and defaults. 不過,如果您使用 [選項] 索引標籤中的 [使用舊版主控台] 來還原成原始的主控台,此設定將會是全域設定,並會套用至所有後續的視窗 (包括重新啟動電腦之後)。However, if you revert to the original console by using Use legacy console in the Options tab, this setting is global and will persist for all windows afterwards, including after restarting the computer.

您可以透過在自動安裝檔案中或使用 Windows PowerShell 適當地設定 [登錄],以預先設定這些設定或編寫指令碼。You can pre-configure or script these settings by configuring the Registry appropriately in an Unattend file or with Windows PowerShell.

16 位元 NTVDM 應用程式一律會還原為較舊的主控台主機。16-bit NTVDM apps always revert to the older console host.


如果您在使用新的主控台設定時遇到問題,而且無法使用列於此處的所有特定選項來解決該問題,您隨時可以透過將 ForceV2 設定為 0,或是使用 [選項] 中的 [使用舊版主控台] 控制項,來還原至原始的主控台。If you encounter issues with the new console settings and cannot resolve them with any of the specific options listed here, you can always revert back to the original console by setting ForceV2 to 0 or with the Use legacy console control in Options.

主控台行為Console behavior

您現在可以使用滑鼠抓取視窗邊緣然後加以拖曳,來調整主控台視窗大小。You can now resize the console window at will by grabbing an edge with the mouse and dragging it. 捲軸只會在您手動設定視窗尺寸 (透過使用 [內容] 中的 [配置] 索引標籤),或是當緩衝區中文字最長那一行的寬度超過目前視窗大小時,才會出現。Scroll bars only appear if you set window dimensions manually (by using the Layout tab in Properties) or if the longest line of text in the buffer is wider than the current window size.

新的主控台視窗現已支援自動換行。The new console window now supports word wrapping. 不過,如果您使用主控台 API 來變更緩衝區中的文字時,主控台會將文字保留為原本插入時的模樣。However, if you used console APIs to change text in a buffer, the console will leave the text as it was originally inserted.

主控台視窗現在能有半透明效果 (最小透明度為 30%)。Console windows now can be semi-transparent (to a minimum transparency of 30%). 您可以從 [內容] 功能表,或是使用下列鍵盤命令來調整透明度︰You can adjust the transparency from the Properties menu or with these keyboard commands:

若要這樣做:To do this: 使用此按鍵組合︰Use this key combination:
增加透明度Increase transparency CTRL+SHIFT+加號 (+) 或 CTRL+SHIFT+滑鼠向上捲動CTRL+SHIFT+Plus (+) or CTRL+SHIFT+mouse scroll up
降低透明度Decrease transparency CTRL+SHIFT+減號 (-) 或 CTRL+SHIFT+滑鼠向下捲動CTRL+SHIFT+Minus (-) or CTRL+SHIFT+mouse scroll down
切換全螢幕模式Toggle full-screen mode ALT+ENTERALT+ENTER


有許多可用來選取文字和行,以及標記文字和使用緩衝區歷程記錄的新選項。There are many new options for selecting text and lines, as well as for marking text and using the buffer history. 主控台會嘗試避免與使用相同索引鍵的應用程式發生衝突。The console attempts to avoid clashes with applications that might be using the same keys.

針對開發人員︰如果發生衝突,您通常可以使用 SetConsoleMode() API 來控制應用程式使用列輸入、處理輸入,以及回應輸入模式的行為。For developers: If a conflict occurs, you can typically control the behavior of the application's use of line input, processed input, and echo input modes with the SetConsoleMode() API. 如果您是以處理輸入模式執行,便適用下列捷徑,針對其他模式則必須交由您的應用程式處理。If you run in processed input mode, the shortcuts below apply, but in other modes, your application must handle them. 所有未列於此處的按鍵組合,都會以和舊版主控台相同的方式運作。Any key combinations not listed here function as they did in previous versions of the console. 您也可以利用 [選項] 索引標籤上的各種設定來嘗試解決衝突。如果全都失敗,您隨時可以還原為原始的主控台。You can also try to resolve conflicts with various settings on the Options tab. If all else fails, you can always revert to the original console.

您現在可以在快速編輯模式外使用「按一下並拖曳」的選取方式,此選取方式可以和在「記事本」中一樣地跨行選取文字,而不再只能選取一個矩形區塊。You can now use "click-and-drag" selection outside of QuickEdit mode, and this selection can select text across lines as in Notepad, rather than just a rectangular block. 複製作業不會再要求您移除分行符號。Copy operations no longer require you to remove line breaks. 除了「按一下並拖曳」選取方式之外,也提供下列按鍵組合︰In addition to "click-and-drag" selection, these key combinations are available:

文字選取Text selection

若要這樣做:To do this: 使用此按鍵組合︰Use this key combination:
將游標移至某一字元的左側,以延伸選取範圍Move the cursor to the left one character, extending the selection SHIFT+向左鍵SHIFT+LEFT ARROW
將游標移至某一字元的右側,以延伸選取範圍Move the cursor to the right one character, extending the selection SHIFT+向右鍵SHIFT+RIGHT ARROW
從插入點向上逐行選取文字Selects text line by line up from the insertion point SHIFT+向上鍵SHIFT+UP ARROW
從插入點向下將文字選取範圍延伸一行Extends text selection down one line from the insertion point SHIFT+向下鍵SHIFT+DOWN ARROW
如果游標位於目前正在編輯那一行,使用此命令一次以將選取範圍延伸至該輸入行的最後一個字元。If the cursor is in the line currently being edited, use this command once to extend the selection to the last character in the input line. 使用第二次以將選取範圍延伸至右邊界。Use it a second time to extend the selection to the right margin. SHIFT+ENDSHIFT+END
如果游標沒有位於目前正在編輯的那一行,使用此命令以選取介於插入點和右邊界之間的所有文字。If the cursor is not in the line currently being edited, use this command to select all text from the insertion point to the right margin. SHIFT+ENDSHIFT+END
如果游標位於目前正在編輯的那一行,使用此命令一次以將選取範圍延伸至命令提示字元後的第一個字元。If the cursor in the line currently being edited, use this command once to extend the selection to the character immediately after the command prompt. 使用第二次以將選取範圍延伸至右邊界。Use it a second time to extend the selection to the right margin. SHIFT+HOMESHIFT+HOME
如果游標沒有位於目前正在編輯的那一行,使用此命令以將選取範圍延伸至左邊界。If the cursor is not in the line currently being edited, use this command to extend the selection to the left margin. SHIFT+HOMESHIFT+HOME
將選取範圍向下延伸一個畫面Extend the selection down one screen SHIFT+PAGE DOWNSHIFT+PAGE DOWN
將選取範圍向上延伸一個畫面Extend the selection up one screen SHIFT+PAGE UPSHIFT+PAGE UP
將選取範圍向右延伸一個單字。Extend the selection one word to the right. (您可以使用 WordDelimiters 登錄機碼來為「單字」定義分隔符號)。(You can define the delimiters for "word" with the WordDelimiters registry key.) CTRL+SHIFT+向右鍵CTRL+SHIFT+RIGHT ARROW
將選取範圍向左延伸一個單字Extend the selection one word to the left CTRL+SHIFT+HOMECTRL+SHIFT+HOME
將選取範圍延伸至螢幕緩衝區的開頭Extend the selection to the beginning of the screen buffer CTRL+SHIFT+ENDCTRL+SHIFT+END
如果游標位於目前那一行,且該行不是空的,便會選取提示之後的所有文字Select all text after the prompt, if the cursor is in the current line and the line is not empty CTRL+ACTRL+A
如果游標沒有位於目前那一行,便會選取整個緩衝區Select the entire buffer, if the cursor is not in the current line CTRL+ACTRL+A

編輯文字Editing text

您可以使用鍵盤命令在主控台中複製並貼上文字。You can copy and paste text in the console using keyboard commands. CTRL+C 現在具有兩種功能。CTRL+C now serves two functions. 如果使用時並未選取任何文字,它會如往常般傳送 BREAK 命令。If no text is selected when you use it, it sends the BREAK command as usual. 如果有選取文字,第一次使用時會複製該文字並清除選取範圍;第二次使用時會傳送 BREAK。If text is selected, the first use copies the text and clears the selection; the second use sends BREAK. 以下是其他的編輯命令︰Here are the other editing commands:

若要這樣做:To do this: 使用此按鍵組合︰Use this key combination:
將文字貼到命令列Paste text into the command line CTRL+VCTRL+V
將選取的文字複製到剪貼簿Copy selected text to the clipboard CTRL+INSCTRL+INS
將選取的文字複製到剪貼簿;傳送 BREAKCopy selected text to the clipboard; send BREAK CTRL+CCTRL+C
將文字貼到命令列Paste text into the command line SHIFT+INSSHIFT+INS

標記模式Mark mode

若要進入標記模式,您可以隨時以滑鼠右鍵按一下主控台標題列的任何地方,指向 [編輯],然後從開啟的功能表中選取 [標記]To enter mark mode at any time, right-click anywhere in the console title bar, point to Edit, and select Mark from the menu that opens. 您也可以輸入 CTRL+M。You can also type CTRL+M. 處於標記模式時,使用 ALT 鍵來識別換行選取的開頭。While in mark mode, use the ALT key to identify the start of a line-wrapping selection. (如果 [啟用換行選取] 已停用,標記模式將會以區塊的方式選取文字)。處於標記模式時,CTRL+SHIFT+方向鍵會依字元逐一選取,而不是如一般模式中依單字逐一選取。(If Enable line wrapping selection is disabled, mark mode selects text in a block.) While in mark mode, CTRL+SHIFT+ARROW selects by character and not by word as in normal mode. 除了 [編輯文字] 區段中的選取按鍵之外,也可以在標記模式中使用下列組合︰In addition to the selection keys in the Editing text section, these combinations are available in mark mode:

若要這樣做:To do this: 使用此按鍵組合︰Use this key combination:
進入標記模式以在視窗中移動指標Enter mark mode to move cursor in the window CTRL+MCTRL+M
搭配其他按鍵組合,在標記模式中開始換行選取Begin line-wrapping selection in mark mode, in conjunction with other key combinations ALTALT
朝指定的方向移動游標Move cursor in the direction specified 方向鍵ARROW keys
朝指定的方向將游標移動一頁Move cursor by one page in the direction specified PAGE 鍵PAGE keys
將游標移至緩衝區的開頭Move cursor to beginning of buffer CTRL+HOMECTRL+HOME
將游標移至緩衝區的結尾Move cursor to end of buffer CTRL+ENDCTRL+END

瀏覽歷程記錄Navigating history

若要這樣做:To do this: 使用此按鍵組合︰Use this key combination:
在輸出歷程記錄中上移一行Move up one line in output history CTRL+向上鍵CTRL+UP ARROW
在輸出歷程記錄中下移一行Move down one line in output history CTRL+向下鍵CTRL+DOWN ARROW
將檢視區移至緩衝區的頂端 (如果命令列是空的),或是刪除游標左側的所有字元 (如果命令列不是空的)Move viewport to top of buffer (if command line is empty) or delete all characters to the left of the cursor (if command line is not empty) CTRL+HOMECTRL+HOME
將檢視區移至命令列 (如果命令列是空的),或是刪除游標右側的所有字元 (如果命令列不是空的)Move viewport to command line (if command line is empty) or delete all characters to the right of the cursor (if command line is not empty) CTRL+ENDCTRL+END

其他鍵盤命令Additional keyboard commands

若要這樣做:To do this: 使用此按鍵組合︰Use this key combination:
開啟 [尋找] 對話方塊Open Find dialog CTRL+FCTRL+F
關閉主控台視窗Close console window ALT+F4ALT+F4