import GboxSDK from "gbox-sdk";
const gboxSDK = new GboxSDK({
apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});
async function main() {
const box = await gboxSDK.create({ type: "android" });
// Long press at coordinates (350, 250)
await box.action.longPress({
x: 350,
y: 250,
});
// Long press with custom duration (500ms)
await box.action.longPress({
x: 200,
y: 300,
duration: "500ms"
});
// Long press using natural language target
await box.action.longPress({
target: "Chrome icon",
duration: "1s"
});
}
main();import os
from gbox_sdk import GboxSDK
def main():
gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"]) # This is the default and can be omitted
# Create Android box
box = gbox_sdk.create(type="android")
# Long press at coordinates (350, 250)
box.action.long_press(x=350, y=250)
# Long press with custom duration (500ms)
box.action.long_press(x=200, y=300, duration="500ms")
# Long press using natural language target
box.action.long_press(target="Chrome icon", duration="1s")
if __name__ == "__main__":
main()curl --request POST \
--url https://gbox.ai/api/v1/boxes/{boxId}/actions/long-press \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"x": 350,
"y": 250
}
'{
"message": "Action executed successfully",
"actionId": "c9bdc193-b54b-4ddb-a035-5ac0c598d32d",
"actual": {
"x": 350,
"y": 250,
"duration": "1s"
},
"screenshot": {
"trace": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"before": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"after": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
}
}
}Long press
Perform a long press action at specified coordinates for a specified duration. Useful for triggering context menus, drag operations, or other long-press interactions.
import GboxSDK from "gbox-sdk";
const gboxSDK = new GboxSDK({
apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});
async function main() {
const box = await gboxSDK.create({ type: "android" });
// Long press at coordinates (350, 250)
await box.action.longPress({
x: 350,
y: 250,
});
// Long press with custom duration (500ms)
await box.action.longPress({
x: 200,
y: 300,
duration: "500ms"
});
// Long press using natural language target
await box.action.longPress({
target: "Chrome icon",
duration: "1s"
});
}
main();import os
from gbox_sdk import GboxSDK
def main():
gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"]) # This is the default and can be omitted
# Create Android box
box = gbox_sdk.create(type="android")
# Long press at coordinates (350, 250)
box.action.long_press(x=350, y=250)
# Long press with custom duration (500ms)
box.action.long_press(x=200, y=300, duration="500ms")
# Long press using natural language target
box.action.long_press(target="Chrome icon", duration="1s")
if __name__ == "__main__":
main()curl --request POST \
--url https://gbox.ai/api/v1/boxes/{boxId}/actions/long-press \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"x": 350,
"y": 250
}
'{
"message": "Action executed successfully",
"actionId": "c9bdc193-b54b-4ddb-a035-5ac0c598d32d",
"actual": {
"x": 350,
"y": 250,
"duration": "1s"
},
"screenshot": {
"trace": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"before": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"after": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
}
}
}Authorizations
Enter your API Key in the format: Bearer . Get it from https://gbox.ai
Path Parameters
Box ID
"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"
Body
- Long Press Action
- Long Press Action with Natural Language
- Long Press Action by Element
Long press action configuration.
Operation flow:
- Touch finger at specified coordinates
- Hold for the specified duration
- Release finger
This is useful for triggering context menus, drag operations, or other long-press interactions.
X coordinate of the long press
350
Y coordinate of the long press
250
Duration to hold the press (e.g. '1s', '500ms')
Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: "500ms", "30s", "5m", "1h" Default: 1s
"1s"
Action options. When options.screenshot is provided, ALL deprecated screenshot fields (outputFormat, presignedExpiresIn, screenshotDelay, screenshotRange, includeScreenshot) will be completely ignored.
Show child attributes
Show child attributes
{
"screenshot": {
"outputFormat": "base64",
"presignedExpiresIn": "30m",
"delay": "500ms",
"phases": ["before", "after"]
}
}
Response
Long press action executed successfully. The response includes the actual coordinates and duration of the long press.
Result of long press action execution with actual parameters used
message
"Action executed successfully"
Unique identifier for each action. Use this ID to locate the action and report issues.
"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"
Actual parameters used when executing the long press action
Show child attributes
Show child attributes
{ "x": 350, "y": 250, "duration": "1s" }
Optional screenshot data. Only present when screenshots are requested via options.screenshot.phases or deprecated fields
Show child attributes
Show child attributes
{
"trace": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"before": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
},
"after": {
"uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
}
}
Was this page helpful?