Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions scripts/termux-accessibility.in
Original file line number Diff line number Diff line change
@@ -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[@]}"