2017-07-24 76 views

回答

0

您可以使用命名空間Windows.UI.Xaml.Automation.Peers這種方法:

var isNarratorStarted = AutomationPeer.ListenerExists(AutomationEvents.AutomationFocusChanged); 
+0

感謝您的幫助。但在Windows 10機器默認支持屏幕閱讀,以便每次OnAutomationPeer調用時都意味着每次創建對等體。到目前爲止,您的建議始終返回true如何跳過此操作。我的目標是檢測在我們的機器中啓用了第三方屏幕閱讀器工具或解說器。因爲我們已經在此基礎上進一步採取行動 – James

0

我similiar情況下,但UWP應用程序工作時,我解決了這種方式。也許你可以從這裏拿東西:

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. 
}