Created
February 3, 2021 14:02
-
-
Save DBremen/b31a9418f150fb05f2ebb707f3bcc02e to your computer and use it in GitHub Desktop.
FlaUI calculator example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#assuming the script is in the same folder as the FlaUI assemblies | |
Add-Type -Path "$PSScriptRoot\FlaUI.Core.1.3.0\lib\net45\FlaUI.Core.dll" | |
Add-Type -Path "$PSScriptRoot\FlaUI.UIA3.1.3.1\lib\net45\FlaUI.UIA3.dll" | |
$calc = [Diagnostics.Process]::Start('calc') | |
#wait for the UI to appear | |
$null = $calc.WaitForInputIdle(5000) | |
sleep -s 2 | |
$calcWindowId = ((Get-Process).where{ $_.MainWindowTitle -eq 'Calculator' })[0].Id | |
$uia = New-Object FlaUI.UIA3.UIA3Automation | |
$cf = $uia.ConditionFactory | |
$btnCondition = $cf.ByControlType('Button') | |
$desktop = $uia.GetDesktop() | |
$calc = $desktop.FindFirstDescendant($uia.ConditionFactory.ByProcessId($calcWindowId)) | |
$calc.FindFirstDescendant($btnCondition.And($cf.ByName('Five'))).AsButton().Click() | |
$calc.FindFirstDescendant($btnCondition.And($cf.ByName('Plus'))).AsButton().Click() | |
$calc.FindFirstDescendant($btnCondition.And($cf.ByName('Nine'))).AsButton().Click() | |
$calc.FindFirstDescendant($btnCondition.And($cf.ByName('Equals'))).AsButton().Click() | |
$calc.FindFirstDescendant($cf.ByAutomationId('CalculatorResults')).Properties.Name.Value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment