MCPcopy
hub / github.com/zai-org/Open-AutoGLM / clear_text

Function clear_text

phone_agent/hdc/input.py:66–89  ·  view source on GitHub ↗

Clear text in the currently focused input field. Args: device_id: Optional HDC device ID for multi-device setups. Note: This method uses repeated delete key events to clear text. For HarmonyOS, you might also use select all + delete for better efficiency.

(device_id: str | None = None)

Source from the content-addressed store, hash-verified

64
65
66def clear_text(device_id: str | None = None) -> None:
67 """
68 Clear text in the currently focused input field.
69
70 Args:
71 device_id: Optional HDC device ID for multi-device setups.
72
73 Note:
74 This method uses repeated delete key events to clear text.
75 For HarmonyOS, you might also use select all + delete for better efficiency.
76 """
77 hdc_prefix = _get_hdc_prefix(device_id)
78 # Ctrl+A to select all (key code 2072 for Ctrl, 2017 for A)
79 # Then delete
80 _run_hdc_command(
81 hdc_prefix + ["shell", "uitest", "uiInput", "keyEvent", "2072", "2017"],
82 capture_output=True,
83 text=True,
84 )
85 _run_hdc_command(
86 hdc_prefix + ["shell", "uitest", "uiInput", "keyEvent", "2055"], # Delete key
87 capture_output=True,
88 text=True,
89 )
90
91
92def detect_and_set_adb_keyboard(device_id: str | None = None) -> str:

Callers

nothing calls this directly

Calls 2

_run_hdc_commandFunction · 0.90
_get_hdc_prefixFunction · 0.70

Tested by

no test coverage detected