Powershell & Windows Automation , Wert setzen
-
Mittwoch, 23. März 2011 17:46
* Ich möchte per Windows.Auotmation in Powershell einen Wert setzen (einer WPF) Application
Soweit bin ich schon:[void] [Reflection.Assembly]::Load('UIAutomationClient,Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35')
[void] [Reflection.Assembly]::Load('UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35')###http://theadminblog.blogspot.com/2010/09/wpf-ui-automation-powershell-problem.html
####http://www.codeproject.com/KB/WPF/automator.aspx$source = @"
using System;
using System.Windows.Automation;
using System.Windows;namespace UIAutTools
{
public class Element
{
public static AutomationElement RootElement
{
get
{
return AutomationElement.RootElement;
}
}
}
}
"@
Add-Type -TypeDefinition $source -ReferencedAssemblies("UIAutomationClient", "UIAutomationTypes")$parent = [UIAutTools.Element]::RootElement
$notepad = $Parent.FindAll( "Descendants", [System.Windows.Automation.Condition]::TrueCondition ) |
Where-Object { $_.GetCurrentPropertyValue([System.Windows.Automation.AutomationElementIdentifiers]::ClassNameProperty) -like "WindowsForms10.EDIT*" }|
Add-Member -Name Window -Type ScriptProperty -Value {$this.GetCurrentPattern( [System.Windows.Automation.WindowPattern]::Pattern )} -passthru
$notepad | ForEach {
$_.Current
}
Was muss ich nun machen, dass ich einen Wert setzen kann (bzw. Später brauche ich auch noch einen Klick auf einen Button)
Wie es in c# geht (http://msdn.microsoft.com/en-us/library/system.windows.automation.valuepattern.setvalue.aspx) weiß ich schon .. aber ich habe noch keine Ahnung wie ich das ganze auf powershell übersetze)

