Android-ElectricSheep-Automator

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


    - up
    - down
    - left
    - right

- **`dt`**

    denotes the time taken for the swipe
    in milliseconds. The smaller its value the faster
    the swipe. A value of `100` is fast enough to swipe to
    the next screen.

It returns `0` on success, `1` on failure.

## **`tap($params)`**

Emulates a "tap" at the specified location.
`$params` is a HASH\_REF which must contain one
of the following items:

- **`position`**

    should be an ARRAY\_REF
    as the `X,Y` coordinates of the point to "tap".

- **`bounds`**

    should be an ARRAY\_REF of a bounding rectangle
    of the widget to tap. Which contains two ARRAY\_REFs
    for the top-left and bottom-right coordinates, e.g.
    ` [ [tlX,tlY], [brX,brY] ] `. This is convenient
    when the widget is extracted from an XML dump of
    the UI (see ["dump\_current\_screen\_ui($params)"](#dump_current_screen_ui-params)) which
    contains exactly this bounding rectangle.

It returns `0` on success, `1` on failure.

## **`input_text($params)`**

It "`types`" the specified text into the specified position,
where a text-input widget is expected to exist.
At first it taps at the widget's
location in order to get the focus. And then it enters
the text. You need to find the position of the desired
text-input widget by first getting the current screen UI
(using ["dump\_current\_screen\_ui($params)"](#dump_current_screen_ui-params)) and then using an XPath
selector to identify the desired widget by name/id/attributes.
See the source code of method ["send\_message()"](#send_message) in file
`lib/Android/ElectricSheep/Automator/Plugins/Apps/Viber.pm`
for how this is done for the message-sending text-input widget
of the Viber app.

`$params` is a HASH\_REF which must contain `text`
and one of the two position (of the text-edit widget)
specifiers `position` or `bounds`:

- **`text`**

    the text to write on the text edit widget. At the
    moment, this must be plain ASCII string, not unicode.
    No spaces are accepted.
    Each space character must be replaced with `%s`.

- **`position`**

    should be an ARRAY\_REF
    as the `X,Y` coordinates of the point to "tap" in order
    to get the focus of the text edit widget, preceding the
    text input.

- **`bounds`**

    should be an ARRAY\_REF of a bounding rectangle
    of the widget to tap, in order to get the focus, preceding
    the text input. Which contains two ARRAY\_REFs
    for the top-left and bottom-right coordinates, e.g.
    ` [ [tlX,tlY], [brX,brY] ] `. This is convenient
    when the widget is extracted from an XML dump of
    the UI (see ["dump\_current\_screen\_ui($params)"](#dump_current_screen_ui-params)) which
    contains exactly this bounding rectangle.

It returns `0` on success, `1` on failure.

## **`clear_input_field($params)`**

It clears the contents of a text-input widget
at specified location.

There are several ways to do this. The simplest way
(with `keycombination`) does not work in some
devices, in which case a failsafe way is employed
which deletes characters one after the other for
250 times. 

`$params` is a HASH\_REF which must contain
one of the two position (of the text-edit widget)
specifiers `position` or `bounds`:

- <**`position`**

    should be an ARRAY\_REF
    as the `X,Y` coordinates of the point to "tap" in order
    to get the focus of the text edit widget, preceding the
    text input.

- **`bounds`**

    should be an ARRAY\_REF of a bounding rectangle
    of the widget to tap, in order to get the focus, preceding
    the text input. Which contains two ARRAY\_REFs
    for the top-left and bottom-right coordinates, e.g.
    ` [ [tlX,tlY], [brX,brY] ] `. This is convenient
    when the widget is extracted from an XML dump of
    the UI (see ["dump\_current\_screen\_ui($params)"](#dump_current_screen_ui-params)) which
    contains exactly this bounding rectangle.

- **`num-characters`**

    how many times to press the backspace? Default is 250!
    But if you know the length of the text currently at



( run in 1.133 second using v1.01-cache-2.11-cpan-39bf76dae61 )