挖掘PowerShell中的Console界面
来源:互联网 发布:医疗人工智能招聘 编辑:程序博客网 时间:2024/05/04 01:31
在我们使用PowerShell的时候,最常见到的必定是我们的PowerShell Console界面,比如你会看到默认深蓝色的底色,白色的字体以及其它各种你在Console界面中所见到的一切。
今天我们就来挖掘下PowerShell中Console界面的一些特性。我们可以使用如下System.Console类在PowerShell中查看下控制台的一些支持属性:
PS C:\Users\Administrator> [System.Console].Getmembers()|Foreach{$_.name}get_IsInputRedirectedget_IsOutputRedirectedget_IsErrorRedirectedget_Inget_Outget_Errorget_InputEncodingset_InputEncodingget_OutputEncodingset_OutputEncodingget_BackgroundColorset_BackgroundColorset_ForegroundColorget_ForegroundColorset_BufferHeightget_BufferHeightget_BufferWidthset_BufferWidthget_WindowHeightset_WindowHeightget_WindowWidthset_WindowWidthget_LargestWindowWidthget_LargestWindowHeightset_WindowLeftget_WindowLeftset_WindowTopget_WindowTopget_CursorLeftset_CursorLeftget_CursorTopset_CursorTopset_CursorSizeget_CursorSizeget_CursorVisibleset_CursorVisibleset_Titleget_Titleget_KeyAvailableget_NumberLockget_CapsLockget_TreatControlCAsInputset_TreatControlCAsInputBeepBeepClearResetColorMoveBufferAreaMoveBufferAreaSetBufferSizeSetWindowSizeSetWindowPositionSetCursorPositionReadKeyReadKeyadd_CancelKeyPressremove_CancelKeyPressOpenStandardErrorOpenStandardErrorOpenStandardInputOpenStandardInputOpenStandardOutputOpenStandardOutputSetInSetOutSetErrorReadReadLineWriteLineWriteToStringEqualsGetHashCodeGetTypeIsInputRedirectedIsOutputRedirectedIsErrorRedirectedInOutErrorInputEncodingOutputEncodingBackgroundColorForegroundColorBufferHeightBufferWidthWindowHeightWindowWidthLargestWindowWidthLargestWindowHeightWindowLeftWindowTopCursorLeftCursorTopCursorSizeCursorVisibleTitleKeyAvailableNumberLockCapsLockTreatControlCAsInputCancelKeyPress</span>
这里我们使用了一个小技巧来获得关于[System.Console]类下面的成员,我们就拿其中的几项举例说明吧,比如CapsLock,这个成员类型是用于判断键盘是否开启了大写,我们可以按如下的方法使用:
<span style="color:#000000;">If([System.Console]::CapsLock){ Write-Host "Caps lock key is enabled." }Else{ Write-Host "Caps lock key is disabled."}
我们也可以设置Console界面的背景色,通过使用BackgroundColor成员属性来设置,但是如何知道PowerShell支持哪些颜色呢?下面的方法可以帮助你:)
PS C:\Users\Administrator> [System.Console]::BackgroundColor|Get-Member -Static -MemberType property TypeName: System.ConsoleColorName MemberType Definition---- ---------- ----------Black Property static System.ConsoleColor Black {get;}Blue Property static System.ConsoleColor Blue {get;}Cyan Property static System.ConsoleColor Cyan {get;}DarkBlue Property static System.ConsoleColor DarkBlue {get;}DarkCyan Property static System.ConsoleColor DarkCyan {get;}DarkGray Property static System.ConsoleColor DarkGray {get;}DarkGreen Property static System.ConsoleColor DarkGreen {get;}DarkMagenta Property static System.ConsoleColor DarkMagenta {get;}DarkRed Property static System.ConsoleColor DarkRed {get;}DarkYellow Property static System.ConsoleColor DarkYellow {get;}Gray Property static System.ConsoleColor Gray {get;}Green Property static System.ConsoleColor Green {get;}Magenta Property static System.ConsoleColor Magenta {get;}Red Property static System.ConsoleColor Red {get;}White Property static System.ConsoleColor White {get;}Yellow Property static System.ConsoleColor Yellow {get;}
我们使用Get-Member方法获得出所有静态的属性,这就是PowerShell所支持的全部的背景色了。
0 0
- 挖掘PowerShell中的Console界面
- 配置个性化PowerShell Console Profile
- PowerShell中的加法运算
- Powershell 中的Verbose!
- PowerShell 中的 replace
- PowerShell中的转义字符
- PowerShell 脚本中的密码
- [PowerShell教程][09]PowerShell中的数组使用
- [PowerShell教程][11]PowerShell中的加法运算
- VC隐藏Console的界面
- Saltstack console平台界面配置
- [命令行] 配置颜色(windows cmd,powershell,linux console)
- javascript 中的console.log
- QML 中的 console 对象
- JS中的console对象
- js中的console使用
- JavaScript中的console对象
- 使PowerShell拥有Ubuntu默认终端界面
- 解决myeclipse启动慢的问题
- 聚散分离,不过是寻常
- fedora下make menuconfig使用异常情况解决
- Android学习之 应用崩溃异常处理
- 我觉得汉澳军事指挥作战理论已经在最近伊拉克反政府军中使用
- 挖掘PowerShell中的Console界面
- win32 API中GetSystemMetrics函数
- MAC - 使用 Alfred 调用 Google 翻译
- java 任务调度类
- android学习笔记---contentProvider
- plist文件
- spring3 页面form标签 报错 Neither BindingResult nor plain target object for bean name "company"
- Quant 实习申请总结[转自丁丁笑笑生]
- 自定义对象的监听方式