Global Shortcut Events
Overview
Shortcut events encapsulated in the global module.
Click Functions
clickPoint Click by coordinates
- Click at coordinates
- @param x X coordinate
- @param y Y coordinate
- @return boolean
function main() {
var result = clickPoint(100, 100);
if (result) {
logd("Click succeeded");
} else {
logd("Click failed");
}
}
main();
clickPointPressure Click coordinates with pressure
- Click at coordinates with pressure
- Requires EC standalone 2.1.0+
- @param x X coordinate
- @param y Y coordinate
- @param pressure Pressure value in the range 0–1
- @return
{boolean}
function main() {
var result = clickPointPressure(100, 100, 0.2);
if (result) {
logd("Click succeeded");
} else {
logd("Click failed");
}
}
main();
longClickPoint Long-click by coordinates
- Long-click at coordinates
- @param x X coordinate
- @param y Y coordinate
- @return
{boolean}
function main() {
var result = longClickPoint(100, 100);
if (result) {
logd("Click succeeded");
} else {
logd("Click failed");
}
}
main();
doubleClickPoint Double-click by coordinates
- Double-click at coordinates
- @param x X coordinate
- @param y Y coordinate
- @return
{boolean}
function main() {
var result = doubleClickPoint(100, 100);
if (result) {
logd("Click succeeded");
} else {
logd("Click failed");
}
}
main();
press Long-press by coordinates
- Long-press event
- @param x X coordinate
- @param y Y coordinate
- @param delay Long-press duration in milliseconds
- @return
{bool}true on success, false on failure
function main() {
var result = press(100, 100, 5000);
if (result) {
logd("Long press succeeded");
} else {
logd("Long press failed");
}
}
main();
Multi-touch
multiTouch Multi-touch
- Multi-touch
- Touch parameters: action — generally 0 = down, 1 = up, 2 = move, 3 = pause
- x: X coordinate
- y: Y coordinate
- pointer: Which finger touch point (1, 2, 3, etc.)
- delay: How many milliseconds to delay before executing this action
- @param touch1 Touch point array for finger 1, for example:
[{"action":0,"x":1,"y":1,"pointer":1,"delay":20},{"action":2,"x":1,"y":1,"pointer":1,"delay":20}] - @param touch2 Touch point array for finger 2
- @param touch3 Touch point array for finger 3
- @param touch4 Touch point array for finger 4
- @param touch5 Touch point array for finger 5
- @param timeout Total multi-touch execution timeout in milliseconds
- @return
{boolean}
function main() {
// First style: array-based
var touch1 = [
{"action": 0, "x": 500, "y": 1200, "pointer": 1, "delay": 1},
{"action": 2, "x": 500, "y": 1100, "pointer": 1, "delay": 20},
{"action": 2, "x": 500, "y": 1000, "pointer": 1, "delay": 20},
{"action": 1, "x": 1, "y": 1, "pointer": 1, "delay": 20}
]
// Second style: chained calls
var touch1 = MultiPoint
.get()
.action(0).x(500).y(1200).pointer(1).delay(1)
.next()
.action(2).x(500).y(1100).pointer(1).delay(1)
.next()
.action(2).x(500).y(1000).pointer(1).delay(1)
.next()
.action(2).x(500).y(900).pointer(1).delay(1)
.next()
.action(1).x(500).y(800).pointer(1).delay(1);
var touch2 = MultiPoint
.get()
.action(0).x(300).y(1200).pointer(2).delay(1)
.next()
.action(2).x(300).y(1100).pointer(2).delay(1)
.next()
.action(2).x(300).y(1000).pointer(2).delay(1)
.next()
.action(2).x(300).y(900).pointer(2).delay(1)
.next()
.action(1).x(300).y(800).pointer(2).delay(1);
var x = multiTouch(touch1, touch2, null, null, null, 30000);
logd("xxs " + x);
}
main();
Swipe Functions
swipeToPoint Swipe between coordinate points
- Swipe from one coordinate to another
- @param startX Start X coordinate
- @param startY Start Y coordinate
- @param endX End X coordinate
- @param endY End Y coordinate
- @param duration Duration in milliseconds
- @return
{boolean}true if swipe succeeded, false if swipe failed
function main() {
var result = swipeToPoint(10, 10, 100, 100, 200);
if (result) {
logd("Swipe succeeded");
} else {
logd("Swipe failed");
}
}
main();