powershell transformPattern.Resize(width, height);
Hello I would like to learn how to move and resize an microsoft store app with flaui and powershell. For now, as an example, I'm able to launch the calculator and to extract size and position.
I need some help to find out how to call the transformPattern move and resize with flaui, uia3 and powershell. For now I'm trying to understand and convert the following tutorial from microsoft https://docs.microsoft.com/fr-fr/dotnet/api/system.windows.automation.transformpattern.resize?view=net-5.0#System_Windows_Automation_TransformPattern_Resize_System_Double_System_Double_ thank you for your support Thierry
here is the code
$core = Add-Type -Path "Z:\FLAUI\FlaUI.Core.3.2.0\lib\net45\FlaUI.Core.dll" $uia3 = Add-Type -Path "Z:\FLAUI\FlaUI.UIA3.3.2.0\lib\net45\FlaUI.UIA3.dll"
Start-Sleep -s 2 $calcapp = [FlaUI.Core.Application]::LaunchStoreApp("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); $calcId = ((Get-Process).where{ $_.MainWindowTitle -eq 'Calculator' })[0].Id $uia0 = New-Object FlaUI.UIA3.UIA3Automation $cf0 = $uia0.ConditionFactory $desktop = $uia0.GetDesktop()
$calc = $desktop.FindFirstDescendant($cf0.ByProcessId($calcId)) # $calc.BoundingRectangle $calc.ActualHeight $calc.ActualWidth
StoreApps are a bit of a pain. Make sure that you have the outmost Window (and not the inner window) of the application. They have different process ids and only the outermost window (directly a child of desktop) is a real window you can interact with.
As for the pattern: Either directly use the pattern or convert the window to an element (like Window) that implements this pattern.
An example that works for me is that:
$core = Add-Type -Path "C:\Temp\FlaUI.Core.dll"
$uia3 = Add-Type -Path "C:\Temp\FlaUI.UIA3.dll"
$calcapp = [FlaUI.Core.Application]::LaunchStoreApp("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
$uia0 = New-Object FlaUI.UIA3.UIA3Automation
$cf0 = $uia0.ConditionFactory
$desktop = $uia0.GetDesktop()
Start-Sleep -s 2
$calc = $desktop.FindFirstDescendant($cf0.ByName('Calculator'))
# Move by pattern
$calc.Patterns.Transform.Pattern.Move(200, 200)
Start-Sleep -s 2
# Move by implemented element
$window = [FlaUI.Core.AutomationElements.AutomationElementExtensions]::AsWindow($calc)
$window.Move(300,300)