Hooker UI Automation
Use this skill when the task is to inspect, navigate, and operate an Android app through Hooker UI automation endpoints or the Hooker UI MCP server.
Core Rules
- Prefer
inspect_current_ui to discover controls before acting.
- Prefer
click_view over coordinate clicks whenever a reliable target exists.
- Treat
hooker_id as ephemeral. Do not assume an old hooker_id is still valid after page refresh, list recycling, dialog changes, navigation, or data reload.
- After every meaningful action, verify the result with
inspect_current_ui, get_activity_stack, get_screen_info, inspect_overlay, or screenshot tools.
- If a click causes an unexpected page jump or modal state, recover immediately with
go_back, then re-inspect.
- Use coordinate-based actions only as a fallback for WebView, React Native, canvas-like hot zones, or overlay-heavy pages.
Default Workflow
- Inspect first.
- Identify the target using stable traits:
text, content_description, view_type, class_name, screen_rectangle, visible position, parent context.
- Choose the safest action:
click_view, set_text, send_search_action, swipe_view, set_checked, tab_layout_select, etc.
- Verify the result immediately:
inspect again, compare activity stack, or use overlay/screenshot.
- If verification fails, recover:
retry with a fresh inspect, use a different target, or go back.
Element Selection Strategy
Use this priority order:
- Stable resource id or current-turn
hooker_id
- Text or content description
- View type plus nearby text
- Screen position from
screen_rectangle
- Coordinate fallback
Do not reuse an old hooker_id across turns or after UI changes unless a fresh inspect confirms it is still present.
Choosing Actions
Preferred actions by scenario:
- Native button, text row, image row:
click_view
- Search box or text input:
set_text then send_search_action
- Scrollable native container:
swipe_view or dedicated scroll tool
- List/grid item without stable node identity: inspect, then click the current match only
- Toggle/radio/checkbox:
set_checked
- WebView / React Native / hybrid page:
inspect_overlay, then coordinate fallback if tree actions are unreliable
Use click_by_position only when all view-based options are unreliable.
Coordinate Safety
Do not assume screenshot pixels equal tappable screen coordinates.
Before using coordinates:
- Read screenshot metadata:
image_width, image_height, display_width, display_height, real_display_width, real_display_height, rotation, orientation, app_window
- Prefer
screen_rectangle from inspect_current_ui over guessing from raw screenshot pixels
- If the model sees a scaled image, convert back into device coordinates before tapping
For overlays, prefer the center of screen_rectangle:
Inspect vs Screenshot
Use these outputs for different jobs:
inspect_current_ui
Best for machine-readable structure, current hooker_id, type, text, and screen_rectangle
inspect_overlay
Best for model-facing visual reasoning because it draws boxes directly onto the screenshot
capture_media_projection_screenshot
Best when you need the raw screen image and metadata
When possible, inspect and overlay should be paired:
inspect_current_ui
inspect_overlay
- action
- re-inspect
WebView and React Native
For WebView and React Native:
- Expect partial or misleading control trees
- Do not trust
is_clickable alone
- Prefer
inspect_overlay to anchor the visible layout
- Use coordinate taps or swipes only after identifying the right region visually
- Re-verify after every interaction because hot zones may trigger unexpected navigation
If a close button or dismiss area is visually obvious but not reliably clickable through the tree:
- use
click_by_position or long_click_view fallback only after confirming the region via overlay
Validation After Actions
After risky actions, always verify at least one of:
top_activity unchanged when it should stay on the same page
- target text disappeared or changed
- dialog count or visible controls changed as expected
- screenshot visually reflects the intended result
High-risk actions include:
- taps near hot zones
- WebView taps
- privacy agreement or permission-related controls
- taps outside dialogs
- overlay close attempts
Recovery Patterns
If something goes wrong:
- stale
hooker_id: re-run inspect and reacquire the target
- inspect failure or null state: confirm current activity, wait briefly, then retry inspect
- unexpected Activity:
go_back, inspect again, and continue from a stable page
- screenshot unauthorized: call media projection status/permission before depending on screenshots
- hybrid page mismatch: switch from tree-first to overlay-plus-coordinate strategy
Common Failure Modes
Stale hooker_id
Symptom:
- action returns not found
- action applies to the wrong recycled list item
Response:
- re-run inspect
- reacquire the current target
Inspect null state
Symptom:
- page just closed
- top activity missing
- decor/root view invalid
Response:
- query activity stack
- retry after the page stabilizes
- avoid acting until inspect succeeds again
Unexpected navigation
Symptom:
- new Activity after a tap that should have stayed in place
Response:
- inspect activity stack
- go back if it is unintended
- mark the tapped region as risky
Screenshot mismatch
Symptom:
- AI points to the correct place visually but tap lands elsewhere
Response:
- use screenshot metadata
- use
screen_rectangle
- prefer overlay + current inspect instead of direct pixel guessing
Practical Guidance For Agents
- Keep each step small and verifiable.
- Do not batch multiple risky actions without an inspection checkpoint between them.
- If there is ambiguity between two nearby targets, inspect again with tighter filters or use overlay.
- On unstable pages, favor repeated inspect/verify loops over aggressive clicking.
- When in doubt, choose the action that is easiest to verify and reverse.
1---2name: hooker-ui-automation3description: Use when operating Android apps through Hooker UI MCP or the /hooker/ui and /hooker/mediaprojection endpoints. Covers stable UI automation strategy, element selection, screenshot/inspect alignment, WebView and React Native handling, validation after actions, and recovery from common failures such as stale hooker_id, inspect null states, and unexpected page jumps.4---56# Hooker UI Automation78Use this skill when the task is to inspect, navigate, and operate an Android app through Hooker UI automation endpoints or the Hooker UI MCP server.910## Core Rules1112- Prefer `inspect_current_ui` to discover controls before acting.13- Prefer `click_view` over coordinate clicks whenever a reliable target exists.14- Treat `hooker_id` as ephemeral. Do not assume an old `hooker_id` is still valid after page refresh, list recycling, dialog changes, navigation, or data reload.15- After every meaningful action, verify the result with `inspect_current_ui`, `get_activity_stack`, `get_screen_info`, `inspect_overlay`, or screenshot tools.16- If a click causes an unexpected page jump or modal state, recover immediately with `go_back`, then re-inspect.17- Use coordinate-based actions only as a fallback for WebView, React Native, canvas-like hot zones, or overlay-heavy pages.1819## Default Workflow20211. Inspect first.222. Identify the target using stable traits:23 `text`, `content_description`, `view_type`, `class_name`, `screen_rectangle`, visible position, parent context.243. Choose the safest action:25 `click_view`, `set_text`, `send_search_action`, `swipe_view`, `set_checked`, `tab_layout_select`, etc.264. Verify the result immediately:27 inspect again, compare activity stack, or use overlay/screenshot.285. If verification fails, recover:29 retry with a fresh inspect, use a different target, or go back.3031## Element Selection Strategy3233Use this priority order:3435- Stable resource id or current-turn `hooker_id`36- Text or content description37- View type plus nearby text38- Screen position from `screen_rectangle`39- Coordinate fallback4041Do not reuse an old `hooker_id` across turns or after UI changes unless a fresh inspect confirms it is still present.4243## Choosing Actions4445Preferred actions by scenario:4647- Native button, text row, image row: `click_view`48- Search box or text input: `set_text` then `send_search_action`49- Scrollable native container: `swipe_view` or dedicated scroll tool50- List/grid item without stable node identity: inspect, then click the current match only51- Toggle/radio/checkbox: `set_checked`52- WebView / React Native / hybrid page: `inspect_overlay`, then coordinate fallback if tree actions are unreliable5354Use `click_by_position` only when all view-based options are unreliable.5556## Coordinate Safety5758Do not assume screenshot pixels equal tappable screen coordinates.5960Before using coordinates:6162- Read screenshot metadata:63 `image_width`, `image_height`, `display_width`, `display_height`, `real_display_width`, `real_display_height`, `rotation`, `orientation`, `app_window`64- Prefer `screen_rectangle` from `inspect_current_ui` over guessing from raw screenshot pixels65- If the model sees a scaled image, convert back into device coordinates before tapping6667For overlays, prefer the center of `screen_rectangle`:6869- `center_x`70- `center_y`7172## Inspect vs Screenshot7374Use these outputs for different jobs:7576- `inspect_current_ui`77 Best for machine-readable structure, current `hooker_id`, type, text, and `screen_rectangle`78- `inspect_overlay`79 Best for model-facing visual reasoning because it draws boxes directly onto the screenshot80- `capture_media_projection_screenshot`81 Best when you need the raw screen image and metadata8283When possible, inspect and overlay should be paired:84851. `inspect_current_ui`862. `inspect_overlay`873. action884. re-inspect8990## WebView and React Native9192For WebView and React Native:9394- Expect partial or misleading control trees95- Do not trust `is_clickable` alone96- Prefer `inspect_overlay` to anchor the visible layout97- Use coordinate taps or swipes only after identifying the right region visually98- Re-verify after every interaction because hot zones may trigger unexpected navigation99100If a close button or dismiss area is visually obvious but not reliably clickable through the tree:101102- use `click_by_position` or `long_click_view` fallback only after confirming the region via overlay103104## Validation After Actions105106After risky actions, always verify at least one of:107108- `top_activity` unchanged when it should stay on the same page109- target text disappeared or changed110- dialog count or visible controls changed as expected111- screenshot visually reflects the intended result112113High-risk actions include:114115- taps near hot zones116- WebView taps117- privacy agreement or permission-related controls118- taps outside dialogs119- overlay close attempts120121## Recovery Patterns122123If something goes wrong:124125- stale `hooker_id`: re-run inspect and reacquire the target126- inspect failure or null state: confirm current activity, wait briefly, then retry inspect127- unexpected Activity: `go_back`, inspect again, and continue from a stable page128- screenshot unauthorized: call media projection status/permission before depending on screenshots129- hybrid page mismatch: switch from tree-first to overlay-plus-coordinate strategy130131## Common Failure Modes132133### Stale hooker_id134135Symptom:136- action returns not found137- action applies to the wrong recycled list item138139Response:140- re-run inspect141- reacquire the current target142143### Inspect null state144145Symptom:146- page just closed147- top activity missing148- decor/root view invalid149150Response:151- query activity stack152- retry after the page stabilizes153- avoid acting until inspect succeeds again154155### Unexpected navigation156157Symptom:158- new Activity after a tap that should have stayed in place159160Response:161- inspect activity stack162- go back if it is unintended163- mark the tapped region as risky164165### Screenshot mismatch166167Symptom:168- AI points to the correct place visually but tap lands elsewhere169170Response:171- use screenshot metadata172- use `screen_rectangle`173- prefer overlay + current inspect instead of direct pixel guessing174175## Practical Guidance For Agents176177- Keep each step small and verifiable.178- Do not batch multiple risky actions without an inspection checkpoint between them.179- If there is ambiguity between two nearby targets, inspect again with tighter filters or use overlay.180- On unstable pages, favor repeated inspect/verify loops over aggressive clicking.181- When in doubt, choose the action that is easiest to verify and reverse.