uiautomatoreventparser


Nameuiautomatoreventparser JSON
Version 0.11 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/uiautomatoreventparser
SummaryInteracting with uiautomator events
upload_time2024-07-21 08:28:50
maintainerNone
docs_urlNone
authorJohannes Fischer
requires_pythonNone
licenseMIT
keywords uiautomator events
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Interacting with uiautomator events

### Tested against Windows 10 / Python 3.11 / Anaconda / BlueStacks 5

### pip install uiautomatoreventparser

```PY
from uiautomatoreventparser import UiautomatorEventParser
import shutil

adb_path = shutil.which("adb")
device_serial = "127.0.0.1:5645"  # use None when running directly on Android -> https://github.com/hansalemaos/termuxfree


adb_auto = UiautomatorEventParser(
    adb_path=adb_path,
    device_serial=device_serial,
    su_exe="su",
    timeout=30,
    kill_uiautomator_cmd=f"su -c 'pkill uiautomator'",
    kill_uiautomator_and_process_cmd=f"su -c 'pkill uiautomator'\nexit\n",
    print_exceptions=True,
    kwargs_for_UniversalADBExecutor=None,
)
adb_auto.non_shell_adb_commands_without_s_serial(
    [
        "connect",
        device_serial,
    ],
)


from sendkeysonroids import (
    SendEventKeysOnRoids,
    std_key_mapping_dict,
    all_linux_key_events,
)

my_key_mapping_dict = {
    " ": "KEY_SPACE",
    "!": "KEY_LEFTSHIFT + KEY_1",
    "'": "KEY_APOSTROPHE",
    '"': "KEY_LEFTSHIFT + KEY_APOSTROPHE",
    "#": "KEY_LEFTSHIFT + KEY_3",
    "$": "KEY_LEFTSHIFT + KEY_4",
    "%": "KEY_LEFTSHIFT + KEY_5",
    "&": "KEY_LEFTSHIFT + KEY_7",
    "(": "KEY_LEFTSHIFT + KEY_9",
    ")": "KEY_LEFTSHIFT + KEY_0",
    "*": "KEY_LEFTSHIFT + KEY_8",
    "+": "KEY_KPPLUS",
    ",": "KEY_COMMA",
    "-": "KEY_MINUS",
    ".": "KEY_DOT",
    "/": "KEY_SLASH",
    "0": "KEY_0",
    "1": "KEY_1",
    "2": "KEY_2",
    "3": "KEY_3",
    "4": "KEY_4",
    "5": "KEY_5",
    "6": "KEY_6",
    "7": "KEY_7",
    "8": "KEY_8",
    "9": "KEY_9",
    ":": "KEY_LEFTSHIFT + KEY_SEMICOLON",
    ";": "KEY_SEMICOLON",
    "<": "KEY_LEFTSHIFT + KEY_COMMA",
    "=": "KEY_EQUAL",
    ">": "KEY_LEFTSHIFT + KEY_DOT",
    "?": "KEY_QUESTION",
    "@": "KEY_LEFTSHIFT + KEY_2",
    "A": "KEY_LEFTSHIFT + KEY_A",
    "B": "KEY_LEFTSHIFT + KEY_B",
    "C": "KEY_LEFTSHIFT + KEY_C",
    "D": "KEY_LEFTSHIFT + KEY_D",
    "E": "KEY_LEFTSHIFT + KEY_E",
    "F": "KEY_LEFTSHIFT + KEY_F",
    "G": "KEY_LEFTSHIFT + KEY_G",
    "H": "KEY_LEFTSHIFT + KEY_H",
    "I": "KEY_LEFTSHIFT + KEY_I",
    "J": "KEY_LEFTSHIFT + KEY_J",
    "K": "KEY_LEFTSHIFT + KEY_K",
    "L": "KEY_LEFTSHIFT + KEY_L",
    "M": "KEY_LEFTSHIFT + KEY_M",
    "N": "KEY_LEFTSHIFT + KEY_N",
    "O": "KEY_LEFTSHIFT + KEY_O",
    "P": "KEY_LEFTSHIFT + KEY_P",
    "Q": "KEY_LEFTSHIFT + KEY_Q",
    "R": "KEY_LEFTSHIFT + KEY_R",
    "S": "KEY_LEFTSHIFT + KEY_S",
    "T": "KEY_LEFTSHIFT + KEY_T",
    "U": "KEY_LEFTSHIFT + KEY_U",
    "V": "KEY_LEFTSHIFT + KEY_V",
    "W": "KEY_LEFTSHIFT + KEY_W",
    "X": "KEY_LEFTSHIFT + KEY_X",
    "Y": "KEY_LEFTSHIFT + KEY_Y",
    "Z": "KEY_LEFTSHIFT + KEY_Z",
    "[": "KEY_LEFTBRACE",
    "\n": "KEY_ENTER",
    "\t": "KEY_TAB",
    "]": "KEY_RIGHTBRACE",
    "^": "KEY_LEFTSHIFT + KEY_6",
    "_": "KEY_LEFTSHIFT + KEY_MINUS",
    "`": "KEY_GRAVE",
    "a": "KEY_A",
    "b": "KEY_B",
    "c": "KEY_C",
    "d": "KEY_D",
    "e": "KEY_E",
    "f": "KEY_F",
    "g": "KEY_G",
    "h": "KEY_H",
    "i": "KEY_I",
    "j": "KEY_J",
    "k": "KEY_K",
    "l": "KEY_L",
    "m": "KEY_M",
    "n": "KEY_N",
    "o": "KEY_O",
    "p": "KEY_P",
    "q": "KEY_Q",
    "r": "KEY_R",
    "s": "KEY_S",
    "t": "KEY_T",
    "u": "KEY_U",
    "v": "KEY_V",
    "w": "KEY_W",
    "x": "KEY_X",
    "y": "KEY_Y",
    "z": "KEY_Z",
    "{": "KEY_LEFTSHIFT + KEY_LEFTBRACE",
    "}": "KEY_LEFTSHIFT + KEY_RIGHTBRACE",
    "|": "KEY_LEFTSHIFT + KEY_BACKSLASH",
    "~": "KEY_LEFTSHIFT + KEY_GRAVE",
    "ç": "KEY_LEFTALT + KEY_C",
    "Ç": "KEY_LEFTALT + KEY_LEFTSHIFT + KEY_C",
    "ß": "KEY_LEFTALT + KEY_S",
    "ẞ": "KEY_LEFTSHIFT + KEY_LEFTALT + KEY_S",
    "\u0555": "KEY_LEFTSHIFT + KEY_TAB",  # use some unicode symbols that you never use, and bind them to a key combination (select all in this case)
}
input_device = "/dev/input/event3"
android_automation = SendEventKeysOnRoids(
    adb_path=adb_path,
    device_serial=device_serial,
    input_device=input_device,
    su_exe="su",
    blocksize=144,
    prefered_execution="exec",
    chunk_size=1024,
    key_mapping_dict=my_key_mapping_dict,
)

press_tab_key = android_automation.printf_input_text_dd(text="\t")
press_enter_key = android_automation.printf_input_text_dd(text="\n")


def function_after_each_result(**kwargs):
    # Available variables
    # dict_keys(
    #     [
    #         "self",
    #         "func",
    #         "timeout",
    #         "kill_uiautomator_cmd",
    #         "print_exceptions",
    #         "kill_uiautomator_and_process_cmd",
    #         "nonblocking_subprocess",
    #         "parsed_lines_so_far",
    #         "current_line",
    #         "cachedict",
    #         "timeout_final",
    #         "continue_execution",
    #         "current_line_as_bytes",
    #         "current_line_bytes_split",
    #         "len_of_current_line_bytes_split",
    #         "current_index_of_splitline",
    #         "tmpfi",
    #         "missing_categories",
    #     ]
    # )
    #print(kwargs.keys())
    parsed_lines_so_far = kwargs.get("parsed_lines_so_far")
    nonblocking_subprocess = kwargs.get("nonblocking_subprocess")
    current_line = kwargs.get("current_line")
    if "Termux" in parsed_lines_so_far[current_line]["Text"]:
        press_enter_key()
        print(parsed_lines_so_far[current_line]["Text"])
        nonblocking_subprocess.stdinwrite("su -c 'pkill uiautomator'\nexit\n")
        nonblocking_subprocess.kill()
        return False
    else:
        press_tab_key()
    return True


parsed_lines = adb_auto.start_uiautomator_parsing(
    func=function_after_each_result,
    timeout=None,
    kill_uiautomator_cmd=None,
    print_exceptions=None,
    kill_uiautomator_and_process_cmd=None,
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/uiautomatoreventparser",
    "name": "uiautomatoreventparser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "uiautomator, events",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9a/22/9aabcb1cd6e78efdc3fe309495fdcbf11dd6670e562fb9952f4a22821930/uiautomatoreventparser-0.11.tar.gz",
    "platform": null,
    "description": "\r\n# Interacting with uiautomator events\r\n\r\n### Tested against Windows 10 / Python 3.11 / Anaconda / BlueStacks 5\r\n\r\n### pip install uiautomatoreventparser\r\n\r\n```PY\r\nfrom uiautomatoreventparser import UiautomatorEventParser\r\nimport shutil\r\n\r\nadb_path = shutil.which(\"adb\")\r\ndevice_serial = \"127.0.0.1:5645\"  # use None when running directly on Android -> https://github.com/hansalemaos/termuxfree\r\n\r\n\r\nadb_auto = UiautomatorEventParser(\r\n    adb_path=adb_path,\r\n    device_serial=device_serial,\r\n    su_exe=\"su\",\r\n    timeout=30,\r\n    kill_uiautomator_cmd=f\"su -c 'pkill uiautomator'\",\r\n    kill_uiautomator_and_process_cmd=f\"su -c 'pkill uiautomator'\\nexit\\n\",\r\n    print_exceptions=True,\r\n    kwargs_for_UniversalADBExecutor=None,\r\n)\r\nadb_auto.non_shell_adb_commands_without_s_serial(\r\n    [\r\n        \"connect\",\r\n        device_serial,\r\n    ],\r\n)\r\n\r\n\r\nfrom sendkeysonroids import (\r\n    SendEventKeysOnRoids,\r\n    std_key_mapping_dict,\r\n    all_linux_key_events,\r\n)\r\n\r\nmy_key_mapping_dict = {\r\n    \" \": \"KEY_SPACE\",\r\n    \"!\": \"KEY_LEFTSHIFT + KEY_1\",\r\n    \"'\": \"KEY_APOSTROPHE\",\r\n    '\"': \"KEY_LEFTSHIFT + KEY_APOSTROPHE\",\r\n    \"#\": \"KEY_LEFTSHIFT + KEY_3\",\r\n    \"$\": \"KEY_LEFTSHIFT + KEY_4\",\r\n    \"%\": \"KEY_LEFTSHIFT + KEY_5\",\r\n    \"&\": \"KEY_LEFTSHIFT + KEY_7\",\r\n    \"(\": \"KEY_LEFTSHIFT + KEY_9\",\r\n    \")\": \"KEY_LEFTSHIFT + KEY_0\",\r\n    \"*\": \"KEY_LEFTSHIFT + KEY_8\",\r\n    \"+\": \"KEY_KPPLUS\",\r\n    \",\": \"KEY_COMMA\",\r\n    \"-\": \"KEY_MINUS\",\r\n    \".\": \"KEY_DOT\",\r\n    \"/\": \"KEY_SLASH\",\r\n    \"0\": \"KEY_0\",\r\n    \"1\": \"KEY_1\",\r\n    \"2\": \"KEY_2\",\r\n    \"3\": \"KEY_3\",\r\n    \"4\": \"KEY_4\",\r\n    \"5\": \"KEY_5\",\r\n    \"6\": \"KEY_6\",\r\n    \"7\": \"KEY_7\",\r\n    \"8\": \"KEY_8\",\r\n    \"9\": \"KEY_9\",\r\n    \":\": \"KEY_LEFTSHIFT + KEY_SEMICOLON\",\r\n    \";\": \"KEY_SEMICOLON\",\r\n    \"<\": \"KEY_LEFTSHIFT + KEY_COMMA\",\r\n    \"=\": \"KEY_EQUAL\",\r\n    \">\": \"KEY_LEFTSHIFT + KEY_DOT\",\r\n    \"?\": \"KEY_QUESTION\",\r\n    \"@\": \"KEY_LEFTSHIFT + KEY_2\",\r\n    \"A\": \"KEY_LEFTSHIFT + KEY_A\",\r\n    \"B\": \"KEY_LEFTSHIFT + KEY_B\",\r\n    \"C\": \"KEY_LEFTSHIFT + KEY_C\",\r\n    \"D\": \"KEY_LEFTSHIFT + KEY_D\",\r\n    \"E\": \"KEY_LEFTSHIFT + KEY_E\",\r\n    \"F\": \"KEY_LEFTSHIFT + KEY_F\",\r\n    \"G\": \"KEY_LEFTSHIFT + KEY_G\",\r\n    \"H\": \"KEY_LEFTSHIFT + KEY_H\",\r\n    \"I\": \"KEY_LEFTSHIFT + KEY_I\",\r\n    \"J\": \"KEY_LEFTSHIFT + KEY_J\",\r\n    \"K\": \"KEY_LEFTSHIFT + KEY_K\",\r\n    \"L\": \"KEY_LEFTSHIFT + KEY_L\",\r\n    \"M\": \"KEY_LEFTSHIFT + KEY_M\",\r\n    \"N\": \"KEY_LEFTSHIFT + KEY_N\",\r\n    \"O\": \"KEY_LEFTSHIFT + KEY_O\",\r\n    \"P\": \"KEY_LEFTSHIFT + KEY_P\",\r\n    \"Q\": \"KEY_LEFTSHIFT + KEY_Q\",\r\n    \"R\": \"KEY_LEFTSHIFT + KEY_R\",\r\n    \"S\": \"KEY_LEFTSHIFT + KEY_S\",\r\n    \"T\": \"KEY_LEFTSHIFT + KEY_T\",\r\n    \"U\": \"KEY_LEFTSHIFT + KEY_U\",\r\n    \"V\": \"KEY_LEFTSHIFT + KEY_V\",\r\n    \"W\": \"KEY_LEFTSHIFT + KEY_W\",\r\n    \"X\": \"KEY_LEFTSHIFT + KEY_X\",\r\n    \"Y\": \"KEY_LEFTSHIFT + KEY_Y\",\r\n    \"Z\": \"KEY_LEFTSHIFT + KEY_Z\",\r\n    \"[\": \"KEY_LEFTBRACE\",\r\n    \"\\n\": \"KEY_ENTER\",\r\n    \"\\t\": \"KEY_TAB\",\r\n    \"]\": \"KEY_RIGHTBRACE\",\r\n    \"^\": \"KEY_LEFTSHIFT + KEY_6\",\r\n    \"_\": \"KEY_LEFTSHIFT + KEY_MINUS\",\r\n    \"`\": \"KEY_GRAVE\",\r\n    \"a\": \"KEY_A\",\r\n    \"b\": \"KEY_B\",\r\n    \"c\": \"KEY_C\",\r\n    \"d\": \"KEY_D\",\r\n    \"e\": \"KEY_E\",\r\n    \"f\": \"KEY_F\",\r\n    \"g\": \"KEY_G\",\r\n    \"h\": \"KEY_H\",\r\n    \"i\": \"KEY_I\",\r\n    \"j\": \"KEY_J\",\r\n    \"k\": \"KEY_K\",\r\n    \"l\": \"KEY_L\",\r\n    \"m\": \"KEY_M\",\r\n    \"n\": \"KEY_N\",\r\n    \"o\": \"KEY_O\",\r\n    \"p\": \"KEY_P\",\r\n    \"q\": \"KEY_Q\",\r\n    \"r\": \"KEY_R\",\r\n    \"s\": \"KEY_S\",\r\n    \"t\": \"KEY_T\",\r\n    \"u\": \"KEY_U\",\r\n    \"v\": \"KEY_V\",\r\n    \"w\": \"KEY_W\",\r\n    \"x\": \"KEY_X\",\r\n    \"y\": \"KEY_Y\",\r\n    \"z\": \"KEY_Z\",\r\n    \"{\": \"KEY_LEFTSHIFT + KEY_LEFTBRACE\",\r\n    \"}\": \"KEY_LEFTSHIFT + KEY_RIGHTBRACE\",\r\n    \"|\": \"KEY_LEFTSHIFT + KEY_BACKSLASH\",\r\n    \"~\": \"KEY_LEFTSHIFT + KEY_GRAVE\",\r\n    \"\u00e7\": \"KEY_LEFTALT + KEY_C\",\r\n    \"\u00c7\": \"KEY_LEFTALT + KEY_LEFTSHIFT + KEY_C\",\r\n    \"\u00df\": \"KEY_LEFTALT + KEY_S\",\r\n    \"\u1e9e\": \"KEY_LEFTSHIFT + KEY_LEFTALT + KEY_S\",\r\n    \"\\u0555\": \"KEY_LEFTSHIFT + KEY_TAB\",  # use some unicode symbols that you never use, and bind them to a key combination (select all in this case)\r\n}\r\ninput_device = \"/dev/input/event3\"\r\nandroid_automation = SendEventKeysOnRoids(\r\n    adb_path=adb_path,\r\n    device_serial=device_serial,\r\n    input_device=input_device,\r\n    su_exe=\"su\",\r\n    blocksize=144,\r\n    prefered_execution=\"exec\",\r\n    chunk_size=1024,\r\n    key_mapping_dict=my_key_mapping_dict,\r\n)\r\n\r\npress_tab_key = android_automation.printf_input_text_dd(text=\"\\t\")\r\npress_enter_key = android_automation.printf_input_text_dd(text=\"\\n\")\r\n\r\n\r\ndef function_after_each_result(**kwargs):\r\n    # Available variables\r\n    # dict_keys(\r\n    #     [\r\n    #         \"self\",\r\n    #         \"func\",\r\n    #         \"timeout\",\r\n    #         \"kill_uiautomator_cmd\",\r\n    #         \"print_exceptions\",\r\n    #         \"kill_uiautomator_and_process_cmd\",\r\n    #         \"nonblocking_subprocess\",\r\n    #         \"parsed_lines_so_far\",\r\n    #         \"current_line\",\r\n    #         \"cachedict\",\r\n    #         \"timeout_final\",\r\n    #         \"continue_execution\",\r\n    #         \"current_line_as_bytes\",\r\n    #         \"current_line_bytes_split\",\r\n    #         \"len_of_current_line_bytes_split\",\r\n    #         \"current_index_of_splitline\",\r\n    #         \"tmpfi\",\r\n    #         \"missing_categories\",\r\n    #     ]\r\n    # )\r\n    #print(kwargs.keys())\r\n    parsed_lines_so_far = kwargs.get(\"parsed_lines_so_far\")\r\n    nonblocking_subprocess = kwargs.get(\"nonblocking_subprocess\")\r\n    current_line = kwargs.get(\"current_line\")\r\n    if \"Termux\" in parsed_lines_so_far[current_line][\"Text\"]:\r\n        press_enter_key()\r\n        print(parsed_lines_so_far[current_line][\"Text\"])\r\n        nonblocking_subprocess.stdinwrite(\"su -c 'pkill uiautomator'\\nexit\\n\")\r\n        nonblocking_subprocess.kill()\r\n        return False\r\n    else:\r\n        press_tab_key()\r\n    return True\r\n\r\n\r\nparsed_lines = adb_auto.start_uiautomator_parsing(\r\n    func=function_after_each_result,\r\n    timeout=None,\r\n    kill_uiautomator_cmd=None,\r\n    print_exceptions=None,\r\n    kill_uiautomator_and_process_cmd=None,\r\n)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Interacting with uiautomator events",
    "version": "0.11",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/uiautomatoreventparser"
    },
    "split_keywords": [
        "uiautomator",
        " events"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52bfa9dad0ba9b0d39ef0aad408bdac26d7e7475179f05935fc9e616c17dc7bb",
                "md5": "d7b5cf1c7303a885117a5f4ce01166da",
                "sha256": "0b1e53dcc7f2f446f9bd99c24d8a11bcf0dbfe4c04cc30399b8cfa3957eb4823"
            },
            "downloads": -1,
            "filename": "uiautomatoreventparser-0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d7b5cf1c7303a885117a5f4ce01166da",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11940,
            "upload_time": "2024-07-21T08:28:49",
            "upload_time_iso_8601": "2024-07-21T08:28:49.200962Z",
            "url": "https://files.pythonhosted.org/packages/52/bf/a9dad0ba9b0d39ef0aad408bdac26d7e7475179f05935fc9e616c17dc7bb/uiautomatoreventparser-0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a229aabcb1cd6e78efdc3fe309495fdcbf11dd6670e562fb9952f4a22821930",
                "md5": "812990a0ff44c5e302b103caa8b45ccb",
                "sha256": "588bd8e377ec03cc21665f7dd60a53fea0c408f9c8d7ba1036132939ae876472"
            },
            "downloads": -1,
            "filename": "uiautomatoreventparser-0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "812990a0ff44c5e302b103caa8b45ccb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11253,
            "upload_time": "2024-07-21T08:28:50",
            "upload_time_iso_8601": "2024-07-21T08:28:50.579139Z",
            "url": "https://files.pythonhosted.org/packages/9a/22/9aabcb1cd6e78efdc3fe309495fdcbf11dd6670e562fb9952f4a22821930/uiautomatoreventparser-0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-21 08:28:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "uiautomatoreventparser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "uiautomatoreventparser"
}
        
Elapsed time: 0.38951s