How can I be notified when ProgressBar's Value changes with .NET UIAutomation framework? I dont see such property in AutomationElement class.
Asked
Active
Viewed 1,089 times
1
-
`AutomationPropertyChangedEvent` with `ValuePattern.ValueProperty.Id` not working? – Eric Brown Jun 03 '14 at 20:00
-
Do you have an example code? – Peter Jun 04 '14 at 04:18
1 Answers
1
I drew this sample directly from the MSDN documentation, changing only the property:
AutomationPropertyChangedEventHandler propChangeHandler;
/// <summary>
/// Adds a handler for property-changed event; in particular, a change in the value
/// </summary>
/// <param name="element">The UI Automation element whose state is being monitored.</param>
public void SubscribePropertyChange(AutomationElement element)
{
Automation.AddAutomationPropertyChangedEventHandler(element,
TreeScope.Element,
propChangeHandler = new AutomationPropertyChangedEventHandler(OnPropertyChange),
ValuePattern.ValueProperty);
}
/// <summary>
/// Handler for property changes.
/// </summary>
/// <param name="src">The source whose properties changed.</param>
/// <param name="e">Event arguments.</param>
private void OnPropertyChange(object src, AutomationPropertyChangedEventArgs e)
{
AutomationElement sourceElement = src as AutomationElement;
if (e.Property == ValuePattern.ValueProperty)
{
// TODO: Do something with the new value.
// The element that raised the event can be identified by its runtime ID property.
}
else
{
// TODO: Handle other property-changed events.
}
}
public void UnsubscribePropertyChange(AutomationElement element)
{
if (propChangeHandler != null)
{
Automation.RemoveAutomationPropertyChangedEventHandler(element, propChangeHandler);
}
}

Eric Brown
- 13,774
- 7
- 30
- 71
-
I am using FlaUI for Automation. I have a WPF progress bar. Want to Retry until its visibiility is Collapsed. Not able to access the property. Help? – Apoorv Mar 05 '20 at 16:23
-
-
https://stackoverflow.com/questions/60553908/getting-the-visibility-of-a-progress-bar-in-a-wpf-application-using-flaui-automa – Apoorv Mar 05 '20 at 21:04