Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

can't find AirplaneModeSwitch in AutomationElement.RootElement

$
0
0

Hi,

my tool is for enable Airplane mode or disable it.

source is C#, as following:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Automation; namespace Airplane { class Program { static void Main(string[] args) { GetDesktopElement(); //GetFocusedElement(); } public static void GetDesktopElement() { var NetworkCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, "AirplaneModeSwitch"); var mainNetwork = AutomationElement.RootElement.FindFirst(TreeScope.Element, NetworkCondition); TogglePattern slider = (TogglePattern)mainNetwork.GetCurrentPattern(TogglePattern.Pattern); Console.WriteLine(slider.Current.ToggleState); slider.Toggle(); Console.WriteLine(slider.Current.ToggleState); } public static void GetFocusedElement() { var NetworkCondition = new PropertyCondition(AutomationElement.AutomationIdProperty, "AirplaneModeSwitch"); var mainNetwork = AutomationElement.FocusedElement.FindFirst(TreeScope.Element, NetworkCondition); TogglePattern slider = (TogglePattern)mainNetwork.GetCurrentPattern(TogglePattern.Pattern); Console.WriteLine(slider.Current.ToggleState); slider.Toggle(); Console.WriteLine(slider.Current.ToggleState); } } }

i found use GetFocusedElement() worked after execute

rundll32.exe %SystemRoot%\system32\van.dll, RunVAN


but GetDesktopElement() can't work.

due to execute "rundll32.exe %SystemRoot%\system32\van.dll, RunVAN" will open a sidebar, i want skip this step, just fetch the automation UI "airplane mode" direct.Would you help me?










Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>