是否有可能实现以下PowerShell脚本?脚本块作为字典的值?
其目的是稍后调用脚本块以获取html控件。
$sites = @{
site1= @{
url = ".......";
inputUserID = { $doc.getElementsByID("username"]) }; #Some code to get the html input control
inputPassword = { $doc.getElementsByName("passowrd"]) }; #Some code to get the html input control
};
.....
}
$ie = New-Object -ComObject "InternetExplorer.Application"
$ie.navigate($sites[$site]["url"])
$ie.visible = $true
while ($ie.busy) { start-sleep -milliseconds 1000; }
... #Get the input controls and fill the values
问题已更新。这足够清楚了吗?它不应该很难理解。
这真的需要澄清 - 我不知道你是什么试图去做。 – 2012-07-09 21:53:04
@TrevorSullivan我有数据结构'$ sites'来存储所有的网站相关信息。我不想保存某些控件的输入元素ID/Name ...('inputUserID','inputPassword'等),我想存储代码以获取这些控件,因为每个网站都可能有不同的方法来获取这些控件。 – ca9163d9 2012-07-09 22:24:37