79444898

Date: 2025-02-17 09:10:37
Score: 0.5
Natty:
Report link

There is no precise powershell command to toggle airplane mode, the only thing we can do is toggle the network adapter, which is not what we wanted.

Instead we can achieve this by pywinauto or pyautogui. These are python modules to automate desktop apps.

below is the pywinauto script to toggle the airplane mode

I tried with pywinauto module and able to toggle it.

import time import subprocess from pywinauto import Application

subprocess.Popen(['start', 'ms-settings:'], shell=True) time.sleep(3)

app = Application(backend="uia").connect(title_re=".Settings.") # Use regex to match window title settings_window = app.window(title_re=".Settings.")

network_internet_item = settings_window.child_window(title="Network & internet", control_type="ListItem") network_internet_item.click_input() time.sleep(1)

airplane_mode_item = settings_window.child_window(title="Airplane mode", control_type="ListItem") airplane_mode_item.click_input() time.sleep(1)

airplane_mode_toggle = settings_window.child_window(auto_id="SystemSettings_Radio_IsAirplaneModeEnabled_SettingsApp_ToggleSwitch", control_type="Button") airplane_mode_toggle.click_input()

The typical method of navigating to airplane mode toggle button and clicking enter is not working. So, could not think of other solution apart from this

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: goutham ankam