by Minh Le
Version 4 (September 17, 2024)
Download (43 downloads)
Updates: Escape keys and xPaths. Fixed long press with better math.
@AutoClicker run(api, clickActions, returnTo, toastDuration = 0, escapeKeys = [24])
/**
Executes a series of clicks or swipes based on clickActions input.
@param api (dictionary): contains api functions and variables. Used to start subsequent flow. Can be left null to stop flow when function ends
@param toastDuration (number): seconds to toast steps
@param escapeKeys (array of numbers): key codes for 'Key pressed' block to interrupt/pause and resume Autoclicker. Defaults to 24 (volume up). On resume, the delay of the interrupted click action will be skipped.
@param clickActions (array of arrays):
Each sub-array should be a click action array with a combination of 4-7 elements below:
[0] Name (string): Name of text to toast when completing the step.
[1] Delay (number or array of numbers): Time to wait BEFORE completing action. If an array is given, the action will be repeated for each delay time.
[2] startX (number): starting x pos (%) to click on
[3] startY (number): starting y pos (%) to click on
... followed by an optional combination of:
[4] pressTime (number): seconds to hold click
[4] endX (number): ending x pos (%) to swipe to
[5] endY (number): ending y pos (%) to swipe to
[6] swipeSpeed (number): pointer speed during swipe in dip/s. Defaults to 1000.
* 4 parameters [name, delay, startX, startY] will do a single click.
* 5 parameters [name, delay, startX, startY, pressTime] will do a long click for the given time. (It does this by swiping very slowly)
* 6 parameters [name, delay, startX, startY, endX, endY] will swipe with a default speed of 1000
* 7 parameters [name, delay, startX, startY, endX, endY, swipeSpeed] will swipe with the given speed
In lieu of direct x and y coordinates (parameters 2/3 and 4/5), an xPath can be used. The center of the specified element will be used. An optional input 4 can specify input arguments for an 'Interact' block. If normal optional arguments are used, the manual 'Interact touch' block will be used. If no optional parameters are provided, the element will be clicked.
[4] interactInputs (array): The first element is the action code (number). If included, the second, third, and fourth are the package name, argX, and argY.
*Even if only specifying the action code, it must be in an array -- number will be treated as press time or endX
*Autoclicker will pause until the element appears on screen
Example payload for double click, long press, down swipe, up swipe:
{extend(env, {"clickActions": [["Click", [2, 0.2], 50, 50], ["Long Press", 1, 50, 50, 5], ["Down Swipe", 2, 20, 1, 20, 50], ["Up Swipe", 1, 20, 50, 20, 1, 200]], "toastDuration": 1})
*/