我有一个 PowerShell 文件,比如TestForm.ps1和一个 PrimalForm 文件UserForm.ps1,有 3 个文本框;如以下代码所示:
$FormPath = $PSScriptRoot + "\UserForm.ps1"
$Result = & $FormPath
我不知道,如何将在 UserForm.ps1 的 3 个文本框中输入的文本读入我的调用 TestForm.ps1。
请帮忙。
我有一个 PowerShell 文件,比如TestForm.ps1和一个 PrimalForm 文件UserForm.ps1,有 3 个文本框;如以下代码所示:
$FormPath = $PSScriptRoot + "\UserForm.ps1"
$Result = & $FormPath
我不知道,如何将在 UserForm.ps1 的 3 个文本框中输入的文本读入我的调用 TestForm.ps1。
请帮忙。
一种方法是修改 PrimalForm 生成的代码以从其 GenerateForm 函数返回一个值。
#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.9.0
# Generated On: 8/8/2011 2:30 PM
# Generated By: Andy Arismendi
########################################################################
# ... bunch of generated code ...
#Show the Form
$your_form.ShowDialog()| Out-Null
$text_box_values = @{}
$text_box_values.a = $text_box_1.Text
$text_box_values.b = $text_box_2.Text
$text_box_values.c = $text_box_3.Text
return $text_box_values
} #End Function
这个小例子将返回一个哈希表,其中包含存储文本框值的键 a、b 和 c。