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?