diff --git a/scripts/termux-accessibility.in b/scripts/termux-accessibility.in new file mode 100644 index 0000000..816fb19 --- /dev/null +++ b/scripts/termux-accessibility.in @@ -0,0 +1,33 @@ +#!@TERMUX_PREFIX@/bin/bash +set -e -u + +SCRIPTNAME=termux-accessibility +show_usage() { + echo "Usage: $SCRIPTNAME options" + echo 'Options:' + echo 'dump: returns UI XML as `adb` `uiautomator dump`' + echo 'click x y (duration): clicks at the given location for the given duration in milliseconds (default is 1)' + echo 'type toType: types the given string' + echo 'global-action globalAction: performs the given global action' + echo 'screenshot: returns the taken screenshot as PNG' + exit 0 +} + +USAGE_REGEX='^(dump|click [0-9]+ [0-9]+( [0-9]+)?|type .+|global-action .+|screenshot)$' +if ! [[ $@ =~ $USAGE_REGEX ]]; then + show_usage +fi + +if [ "$1" == dump ]; then + ARGS=(--esn dump) +elif [ "$1" == click ]; then + ARGS=(--esn click --ei x $2 --ei y $3 --ei duration ${4-1}) +elif [ "$1" == type ]; then + ARGS=(--es type "$2") +elif [ "$1" == global-action ]; then + ARGS=(--es global-action $2) +elif [ "$1" == screenshot ]; then + ARGS=(--esn screenshot) +fi + +@TERMUX_PREFIX@/libexec/termux-api Accessibility "${ARGS[@]}"