我知道如何使用以下内容更改主ISE窗口的标题
$Host.UI.RawUI.WindowTitle = "My Awesome New Window Title"
但是,我想知道如何访问读取主机请求时弹出的窗口的标题,如:
$strP4Pass = Read-Host "Please enter Perforce Password" -assecurestring
它以Windows PowerShell ISE - Input
作为标题--是的,我知道我的Please enter Perforce Password
提示符在窗口中--但是我真的很想能够定制标题--有什么想法吗?
发布于 2011-05-06 14:25:02
可以使用System.Management.Automation.Host.ChoiceDescription创建具有多个选项的自定义提示符。
$Yes = New-Object System.Management.Automation.Host.ChoiceDescription "Yes Please"
$No = New-Object System.Management.Automation.Host.ChoiceDescription "No, Thank you"
$YesNoChoices = [System.Management.Automation.Host.ChoiceDescription[]]($No,$Yes)
$Answer = $Host.UI.PromptForChoice("Caption goes here", "Message Goes here", $YesNoChoices, 1)
这将产生与-confirm或-whatif类似的UI,但您可以指定所需的响应。这将在任何PowerShell主机、ISE或PowerShell.exe中工作。
发布于 2011-05-06 03:41:21
这是一个个人的答案,但对我来说,ISE是一个编辑和调试脚本的WorkFrame。为此我更喜欢PowerGUI。
它不是执行您的启动文件的最终PowerShell解释器。因此,如果要向代码中添加UI,可以查看如何在脚本中集成Windows窗体或WPF。它还存在一些模块来帮助您这样做。
这是微软的一个关于WPF的意境
WPF & PowerShell -第1部分( Hello &欢迎来到WPF周)
WPF & PowerShell -第2部分(用脚本探索WPF (和.NET的其余部分))
看看朝鲜劳动党(WPF PowerShell工具包)
https://stackoverflow.com/questions/5905081
复制相似问题