Reputation: 83
I have a custom control. i like to provide the support for System screen reading support. Is there any logic to find that the narrator or coded UI tool is enabled in our machine.??
Upvotes: 3
Views: 1258
Reputation: 1305
I had similiar case but when working with UWP app and I solved it that way. Maybe you can take something from here:
private bool isAutomationPeerCreated = false;
private bool IsAutomationPeerAttached => this.isAutomationPeerCreated || AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged);
//triggered everytime you run narrator or any other screen reading software that is based on accessing automation properties
protected override AutomationPeer OnCreateAutomationPeer()
{
if(!this.IsAutomationPeerAttached)
{
this.isAutomationPeerCreated = true;
this.OUR_LOGIC_BASED_ON_ATTACHED_NARRATOR();
}
return null;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
this.isAutomationPeerCreated = false;
}
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if(IsAutomationPeerAttached)
{
this.OUR_LOGIC_BASED_ON_ATTACHED_NARRATOR();
}
}
private void OUR_LOGIC_BASED_ON_ATTACHED_NARRATOR()
{
//DO STH.
}
Upvotes: 1
Reputation: 410
You can use namespace Windows.UI.Xaml.Automation.Peers
and this method:
var isNarratorStarted = AutomationPeer.ListenerExists(AutomationEvents.AutomationFocusChanged);
Upvotes: 1