This Python script uses the Android Debug Bridge (ADB) to extract information about input fields from the currently displayed screen of a connected Android device.
-
Install Python Dependencies:
pip install -r requirments.txt
Enable USB Debugging on your Android device:
-
Go to
Settings
>About phone
> TapBuild number
7 times
to enable Developer options. -
Go back to
Settings
>System
>Developer options
>Enable USB debugging
. Connect your Android device to your computer via USB.
Run the Script:
python main.py
The script will connect to the first available device, dump the UI hierarchy, parse the XML, and extract information about input fields such as text, resource ID, and bounds.
The main function in your code performs the following tasks:
- Connects to the first available Android device.
- Launches the specified application using the provided package name.
- Waits for a few seconds to allow the app to stabilize.
- Dumps the UI hierarchy of the currently displayed screen.
- Parses the XML of the UI hierarchy to extract information about input fields of type
android.widget.EditText. - Prints the extracted input field data.
Output: The extracted input field information will be printed to the console in the following format:
[
{
'text': 'example text',
'resource_id': 'com.example:id/inputField',
'bounds': '[0,0][100,100]'
},
...
]
The script currently only extracts information from input fields of type android.widget.EditText. Ensure that the screen you want to analyze is displayed on the device before running the script. The extraction process might take a few seconds, depending on the complexity of the UI.