diff --git a/CHANGELOG.md b/CHANGELOG.md index a85b8d3..64c4943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ What changed in each release, one line per change. Versions follow [Semantic Ver ### New - `iphone_tap` takes `count` (1–10): the taps go in one gesture, about 0.1 s apart, so a double tap or several quick taps work; separate calls are about 0.5 s apart. An older daemon ignores it and taps once. +- `iphone_batch` takes `one_gesture`: a batch of coordinate taps runs as one gesture, about twice as fast for pressing keys on a keyboard. ### Improvements diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index eaf95ee..5fc2d6e 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -9,6 +9,7 @@ ### 新功能 - `iphone_tap` 加 `count`(1~10):在一个手势里连点,每下间隔约 0.1 秒,双击、短时间内连点几下的入口都能点到;分开调用每下约隔 0.5 秒。旧版本守护进程不认这个参数,只点一下。 +- `iphone_batch` 新增 `one_gesture`:全是坐标点击的一批步骤放进一个手势里点完,在键盘上逐个按键快一倍左右。 ### 改进 diff --git a/crates/ictl-daemon/src/core.rs b/crates/ictl-daemon/src/core.rs index 06e41de..8d59c72 100644 --- a/crates/ictl-daemon/src/core.rs +++ b/crates/ictl-daemon/src/core.rs @@ -1214,6 +1214,7 @@ impl Daemon { text }), Request::Tap { x, y, count } => self.tap(g, x, y, count, view).await, + Request::TapSequence { points } => self.tap_sequence(g, &points).await, Request::TapElement { text, index, max_age_ms } => { self.tap_element(g, &text, index, Duration::from_millis(max_age_ms)).await.map(|(t, missed)| { outcome.tapped_nothing = missed; @@ -1337,6 +1338,7 @@ fn lane(req: &Request) -> Lane { | Request::Screenshot { .. } | Request::ListElements { .. } | Request::Tap { .. } + | Request::TapSequence { .. } | Request::TapElement { .. } | Request::LongPress { .. } | Request::Swipe { .. } diff --git a/crates/ictl-daemon/src/tasks.rs b/crates/ictl-daemon/src/tasks.rs index 510761e..6f7a28e 100644 --- a/crates/ictl-daemon/src/tasks.rs +++ b/crates/ictl-daemon/src/tasks.rs @@ -214,6 +214,7 @@ pub fn scope_check(req: &Request) -> Option { Request::LaunchApp { app } => Some(Check::Launch(app.clone())), Request::OpenUrl { url } => Some(Check::Url(url.clone())), Request::Tap { .. } + | Request::TapSequence { .. } | Request::TapElement { .. } | Request::LongPress { .. } | Request::Swipe { .. } diff --git a/crates/ictl-daemon/src/tools/input.rs b/crates/ictl-daemon/src/tools/input.rs index bee991e..b5b4fd7 100644 --- a/crates/ictl-daemon/src/tools/input.rs +++ b/crates/ictl-daemon/src/tools/input.rs @@ -91,6 +91,55 @@ impl Daemon { Ok(ictl_l10n::trf!("已点击 {pos}{times}(经 HID)", "Tapped {pos}{times} (via HID)")) } + /// 依次点几个点(`iphone_batch` 的 `one_gesture`):WDA 发一个手势([`WdaClient::tap_sequence`]),HID 在同一个会话里连发。 + /// 和 [`Self::tap`] 一样只有连不上 WDA 才退到 HID + pub(crate) async fn tap_sequence(&self, g: &mut Inner, points: &[(f64, f64)]) -> crate::error::Result { + if points.is_empty() || points.len() > crate::protocol::MAX_SEQUENCE_POINTS { + return Err(ictl_l10n::trf!( + "一个手势要点 1 到 {} 个点", + "a gesture takes 1 to {} points", + crate::protocol::MAX_SEQUENCE_POINTS + ) + .into()); + } + self.prepare_coordinates(g, None, true).await?; + let n = points.len(); + let list: Vec = points.iter().map(|(x, y)| format!("({},{})", fmt_g(*x), fmt_g(*y))).collect(); + let list = list.join(" "); + if let Some(w) = self.wda(g) { + match w.tap_sequence(points).await { + Ok(()) => { + return Ok(ictl_l10n::trf!( + "在一个手势里依次点了 {n} 个点:{list}", + "Tapped {n} points in one gesture: {list}" + )); + } + Err(WdaError::Unavailable(_)) => {} + Err(e) => return Err(e.into()), + } + } + let native = self.native(g); + let rot = self.hid_touch_rotation(g).await?; + let pts = points.to_vec(); + self.hid_do(g, move |h| { + Box::pin(async move { + h.rotation = rot; + for (i, (x, y)) in pts.into_iter().enumerate() { + if i > 0 { + tokio::time::sleep(Duration::from_millis(ictl_wda::SEQUENCE_GAP_MS)).await; + } + h.tap(x, y).await?; + } + Ok(()) + }) + }) + .await?; + if native { + return Ok(ictl_l10n::trf!("依次点了 {n} 个点:{list}", "Tapped {n} points: {list}")); + } + Ok(ictl_l10n::trf!("依次点了 {n} 个点(经 HID):{list}", "Tapped {n} points (via HID): {list}")) + } + /// Follow the viewer pointer with one HID report per call. The first event prepares the device. /// Later events reuse the open HID session and reject a change in display orientation. pub(crate) async fn touch( diff --git a/crates/ictl-mcp/src/lib.rs b/crates/ictl-mcp/src/lib.rs index 81e1dbd..b7fc613 100644 --- a/crates/ictl-mcp/src/lib.rs +++ b/crates/ictl-mcp/src/lib.rs @@ -557,7 +557,9 @@ then 在全部做完(或停下)后返回一次界面。", "Run several steps in "steps": {"type": "array", "items": {"type": "object"}, "description": ictl_l10n::tr!("要执行的步骤,1 到 20 个,例如 [{\"tool\": \"iphone_tap_element\", \"text\": \"通用\"}]", "the steps to run, 1 to 20, e.g. [{\"tool\": \"iphone_tap_element\", \"text\": \"General\"}]")}, "reuse_elements": {"type": "boolean", "default": false, - "description": ictl_l10n::tr!("这批操作不改变界面布局时(例如在同一个键盘上连按)设为 true:按名字点击复用最近读到的元素树,每步省 0.3~0.8 秒。会跳转页面的不要用,否则可能点到旧位置", "Set to true when the steps don't change the layout (e.g. pressing keys on the same keypad): tapping by text reuses the most recent element tree, saving 0.3-0.8 s per step. Don't use it for steps that navigate, or it may tap where things used to be")} + "description": ictl_l10n::tr!("这批操作不改变界面布局时(例如在同一个键盘上连按)设为 true:按名字点击复用最近读到的元素树,每步省 0.3~0.8 秒。会跳转页面的不要用,否则可能点到旧位置", "Set to true when the steps don't change the layout (e.g. pressing keys on the same keypad): tapping by text reuses the most recent element tree, saving 0.3-0.8 s per step. Don't use it for steps that navigate, or it may tap where things used to be")}, + "one_gesture": {"type": "boolean", "default": false, + "description": ictl_l10n::tr!("步骤全是 iphone_tap 时可设为 true:这些点在一个手势里依次点完(每个点一根手指,间隔约 0.04 秒),中间不等界面空闲。用于在同一个键盘上连按,例如输入框不接受 iphone_type_text 时逐个点数字键:7 个键约 1.9 秒,分开点约 3.6 秒。点的过程中不看界面,中途跳了页面后面的点也照样点下去;点完截图或读元素核对", "Only when every step is iphone_tap: set to true to tap the points one after another in a single gesture (one finger per point, about 0.04 s apart) without waiting for the interface in between. For pressing keys on the same keyboard, e.g. digit keys one by one when a field doesn't take iphone_type_text: 7 keys in about 1.9 s instead of about 3.6 s. Nothing is checked while it taps, so if a tap navigates, the remaining points still land; check the result with a screenshot or elements afterwards")} })), &["steps"], ), @@ -780,13 +782,14 @@ pub fn batch_steps(args: &Map) -> Result, String> { .and_then(Value::as_array) .ok_or(ictl_l10n::tr!("缺少 steps(数组)", "missing steps (array)"))?; let reuse = Args(args).b_or("reuse_elements", false)?; + let one_gesture = Args(args).b_or("one_gesture", false)?; if steps.is_empty() || steps.len() > BATCH_MAX_STEPS { return Err(ictl_l10n::trf!( "steps 要有 1 到 {BATCH_MAX_STEPS} 步", "steps must have 1 to {BATCH_MAX_STEPS} steps" )); } - steps + let steps: Vec = steps .iter() .enumerate() .map(|(i, s)| { @@ -823,7 +826,32 @@ pub fn batch_steps(args: &Map) -> Result, String> { }; Ok(Step::Request { tool: tool.to_owned(), req }) }) - .collect() + .collect::>()?; + if !one_gesture { + return Ok(steps); + } + // 全是坐标点击才能并成一个手势:别的步骤(按名字点、等待、输入)都要在点之间看界面或花时间 + let points = steps + .iter() + .map(|s| match s { + Step::Request { req: Request::Tap { x, y, count }, .. } => Some((*x, *y, *count)), + _ => None, + }) + .collect::>>() + .ok_or(ictl_l10n::tr!( + "one_gesture 只能用于步骤全是 iphone_tap(按坐标点)的批量", + "one_gesture only works when every step is iphone_tap (tap by coordinates)" + ))?; + // 一个手势里每个点只点一下;要连点用 iphone_tap 的 count,不悄悄当成点一下 + if points.iter().any(|p| p.2 != 1) { + return Err(ictl_l10n::tr!( + "one_gesture 里的 iphone_tap 不能带 count;要在一个点连点,单独调用 iphone_tap 并给 count", + "iphone_tap steps under one_gesture can't take count; to tap one point several times, call iphone_tap on its own with count" + ) + .into()); + } + let points = points.into_iter().map(|(x, y, _)| (x, y)).collect(); + Ok(vec![Step::Request { tool: "iphone_tap".into(), req: Request::TapSequence { points } }]) } /// tap_element 的结果是不是「没点到」(没找到、index 超出匹配个数、或整个被别的东西盖住) @@ -837,6 +865,7 @@ pub fn tap_missed(text: &str, outcome: Option) -> bool { pub fn wants_alert_check(req: &Request) -> bool { match req { Request::Tap { .. } + | Request::TapSequence { .. } | Request::TapElement { .. } | Request::LongPress { .. } | Request::Swipe { .. } @@ -1221,6 +1250,34 @@ mod tests { with_lang(Lang::Zh, || assert!(has_cjk(instructions()))); } + /// one_gesture 把全是坐标点击的批量并成一个 TapSequence;混了别的步骤就报错,一步都不执行 + #[test] + fn one_gesture_turns_taps_into_one_sequence() { + let steps = batch_steps(&args(json!({"one_gesture": true, "steps": [ + {"tool": "iphone_tap", "x": 60, "y": 548}, + {"tool": "iphone_tap", "x": 23, "y": 548.5} + ]}))); + let req = Request::TapSequence { points: vec![(60.0, 548.0), (23.0, 548.5)] }; + assert_eq!(steps, Ok(vec![Step::Request { tool: "iphone_tap".into(), req }])); + for other in [ + json!({"tool": "iphone_tap_element", "text": "1"}), + json!({"tool": "wait", "seconds": 0.1}), + json!({"tool": "iphone_type_text", "text": "1"}), + ] { + let steps = json!({"one_gesture": true, "steps": [{"tool": "iphone_tap", "x": 1, "y": 2}, other]}); + assert!(batch_steps(&args(steps)).is_err()); + } + // without it a batch of taps stays step by step + let steps = batch_steps(&args(json!({"steps": [{"tool": "iphone_tap", "x": 1, "y": 2}]}))).unwrap(); + assert_eq!( + steps, + vec![Step::Request { tool: "iphone_tap".into(), req: Request::Tap { x: 1.0, y: 2.0, count: 1 } }] + ); + // a step's count can't go into one gesture: an error, not one tap + let steps = json!({"one_gesture": true, "steps": [{"tool": "iphone_tap", "x": 1, "y": 2, "count": 2}]}); + assert!(batch_steps(&args(steps)).is_err()); + } + /// iphone_tap 不带 count 是点一下;count 要是 1 到 MAX_TAP_COUNT 的整数,给错了报错、不点,不悄悄改成 1 #[test] fn tap_count_defaults_to_one_and_rejects_out_of_range() { diff --git a/crates/ictl-protocol/src/lib.rs b/crates/ictl-protocol/src/lib.rs index bde4bf9..6bfab5b 100644 --- a/crates/ictl-protocol/src/lib.rs +++ b/crates/ictl-protocol/src/lib.rs @@ -53,6 +53,8 @@ fn one() -> u32 { fn is_one(n: &u32) -> bool { *n == 1 } +/// [`Request::TapSequence`] 一个手势最多点几个点(同 `iphone_batch` 最多几步) +pub const MAX_SEQUENCE_POINTS: usize = 20; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] @@ -95,6 +97,10 @@ pub enum Request { #[serde(default = "one", skip_serializing_if = "is_one")] count: u32, }, + /// 依次点几个点,一个手势(`iphone_batch` 的 `one_gesture`):同一个键盘上连按。旧版本守护进程不认识,报错,不会只点一部分 + TapSequence { + points: Vec<(f64, f64)>, + }, TapElement { text: String, index: usize, @@ -431,6 +437,7 @@ impl Request { match self { Self::Tap { .. } | Self::TapElement { .. } + | Self::TapSequence { .. } | Self::LongPress { .. } | Self::Swipe { .. } | Self::TypeText { .. } @@ -931,6 +938,10 @@ mod tests { let s = serde_json::to_string(&r).unwrap(); assert!(s.starts_with(r#"{"op":"swipe""#), "{s}"); assert_eq!(serde_json::from_str::(&s).unwrap(), r); + let r = Request::TapSequence { points: vec![(60.0, 548.0), (23.0, 548.0)] }; + let s = serde_json::to_string(&r).unwrap(); + assert_eq!(s, r#"{"op":"tap_sequence","points":[[60.0,548.0],[23.0,548.0]]}"#); + assert_eq!(serde_json::from_str::(&s).unwrap(), r); let e: Response = serde_json::from_str(r#"{"kind":"error","message":"x"}"#).unwrap(); assert_eq!(e, Response::error("x")); } diff --git a/crates/ictl-wda/src/client.rs b/crates/ictl-wda/src/client.rs index 81a48c9..905e740 100644 --- a/crates/ictl-wda/src/client.rs +++ b/crates/ictl-wda/src/client.rs @@ -46,6 +46,8 @@ impl StallReason { const SCREEN_RECHECK: Duration = Duration::from_secs(60); /// 普通点击按下的时长(毫秒)。太短可能不被识别成点击;解锁按键另有自己的时长 const TAP_PRESS_MS: u64 = 50; +/// 一个手势里依次点几个点时,前一个抬起到后一个按下停多久(毫秒)。真机上 20、40、60 都没有漏键、多键 +pub const SEQUENCE_GAP_MS: u64 = 40; /// 连点时两下之间停多久(毫秒):双击要在约 250 毫秒内,「800 毫秒内点 5 下」要每下不到 160 毫秒 pub const MULTI_TAP_GAP_MS: u64 = 100; @@ -88,6 +90,32 @@ pub fn swipe_steps(from: (f64, f64), to: (f64, f64), ms: u64) -> Vec Value { + let pause = |ms: u64| json!({"type": "pause", "duration": ms}); + let fingers: Vec = points + .iter() + .enumerate() + .map(|(k, &(x, y))| { + let mut actions = Vec::with_capacity(5 * k + 4); + for _ in 0..k { + actions.extend([pause(0), pause(0), pause(press_ms), pause(0), pause(gap_ms)]); + } + actions.extend([ + json!({"type": "pointerMove", "duration": 0, "x": x, "y": y}), + json!({"type": "pointerDown", "button": 0}), + pause(press_ms), + json!({"type": "pointerUp", "button": 0}), + ]); + json!({"type": "pointer", "id": format!("finger{}", k + 1), "parameters": {"pointerType": "touch"}, "actions": actions}) + }) + .collect(); + json!({"actions": fingers}) +} + /// `POST /session/{id}/actions` 的请求体 pub fn actions_body(steps: &[PointerStep]) -> Value { let actions: Vec = steps @@ -795,6 +823,14 @@ impl WdaClient { self.quick_gesture(&tap_steps(x, y, TAP_PRESS_MS), IdleSettings::NO_COOL_OFF).await } + /// 依次点几个点,一个手势([`tap_sequence_body`]):同一个键盘、键盘上连按时用。分开点每下都要等界面空闲, + /// 数字键盘上点 7 个键约 3.6 秒,一个手势约 1.9 秒。点的过程中界面变了(跳了页面)后面的点也照样点下去, + /// 所以只给点的时候布局不变的一串点用 + pub async fn tap_sequence(&mut self, points: &[(f64, f64)]) -> Result<()> { + let body = tap_sequence_body(points, TAP_PRESS_MS, SEQUENCE_GAP_MS); + self.quick_actions(body, IdleSettings::NO_COOL_OFF).await + } + /// 同一点连点 `count` 下(双击、「短时间内连点 N 下」的隐藏入口),一个 actions 手势,每下之间停 /// [`MULTI_TAP_GAP_MS`]。分开点每下都要等界面空闲(约 0.6 秒),`iphone_batch` 连点 5 下约 2.9 秒,赶不上这类入口的时间窗 pub async fn multi_tap(&mut self, x: f64, y: f64, count: u32) -> Result<()> { @@ -872,9 +908,13 @@ impl WdaClient { /// 发一个手势,期间把等待设置临时换成 `during`(见 [`Self::tap`]),做完恢复 async fn quick_gesture(&mut self, steps: &[PointerStep], during: IdleSettings) -> Result<()> { + self.quick_actions(actions_body(steps), during).await + } + + async fn quick_actions(&mut self, body: Value, during: IdleSettings) -> Result<()> { let baseline = self.baseline().await?; self.set_idle_settings(during).await?; - let r = self.actions(steps).await; + let r = self.post("/actions", body).await.map(drop); if let Err(e) = self.set_idle_settings(baseline).await { tracing::warn!( "{}", @@ -1260,6 +1300,28 @@ mod tests { assert_eq!(steps.iter().filter(|s| s["type"] == "pointerDown").count(), 1); } + /// 依次点几个点:每个点一根手指,第 k 根先空等前面的点按完;各手指的节拍数对得上,按下抬起一个接一个、不重叠 + #[test] + fn a_sequence_is_one_finger_per_point_in_turn() { + let body = tap_sequence_body(&[(10.0, 20.0), (30.0, 40.0), (50.0, 60.0)], 50, 40); + let fingers = body["actions"].as_array().unwrap(); + assert_eq!(fingers.len(), 3); + for (k, f) in fingers.iter().enumerate() { + let a = f["actions"].as_array().unwrap(); + assert_eq!(a.len(), 5 * k + 4, "finger {k}"); + // pauses only until its own turn, then move, down, hold, up at its point + assert!(a[..5 * k].iter().all(|s| s["type"] == "pause")); + assert_eq!(a[5 * k]["type"], "pointerMove"); + assert_eq!(a[5 * k]["x"].as_f64(), Some(10.0 + 20.0 * k as f64)); + assert_eq!(a[5 * k + 1]["type"], "pointerDown"); + assert_eq!(a[5 * k + 3]["type"], "pointerUp"); + assert_ne!(fingers[0]["id"], fingers[k.max(1)]["id"]); + } + // finger k waits 5 ticks per earlier point: move, down, hold, up, gap + assert_eq!(fingers[1]["actions"][2]["duration"], 50); + assert_eq!(fingers[1]["actions"][4]["duration"], 40); + } + /// 连点是一个 actions 请求:一根手指只移动一次,在同一点按下抬起 N 次,两下之间停 MULTI_TAP_GAP_MS; /// 5 下在 0.8 秒内点完 #[tokio::test] diff --git a/crates/ictl-wda/src/lib.rs b/crates/ictl-wda/src/lib.rs index fb5a59b..f71570c 100644 --- a/crates/ictl-wda/src/lib.rs +++ b/crates/ictl-wda/src/lib.rs @@ -9,7 +9,10 @@ pub mod elements; pub mod http; pub mod runner; -pub use client::{IdleSettings, Launch, MULTI_TAP_GAP_MS, WdaClient, multi_tap_steps, swipe_steps, tap_steps}; +pub use client::{ + IdleSettings, Launch, MULTI_TAP_GAP_MS, SEQUENCE_GAP_MS, WdaClient, multi_tap_steps, swipe_steps, + tap_sequence_body, tap_steps, +}; pub use runner::WdaRunner; #[derive(Debug, thiserror::Error)] diff --git a/docs/dev/regression-cases.md b/docs/dev/regression-cases.md index d675515..6358c98 100644 --- a/docs/dev/regression-cases.md +++ b/docs/dev/regression-cases.md @@ -151,3 +151,4 @@ | 145 | WDA 的短探测已正常应答或返回远端错误,却不清零超时计数,三个独立慢请求仍会触发重启;连接失败反而清零。日志还把长请求和短探测均未应答写成「连续 3 次」、宣称尚未检查的 `/status` 正常,请求超时本身缺端点日志 | 只有正常响应或远端错误清零,连接失败不清零;连续无应答和长请求后的失败探测分别记录原因及实际次数;超时诊断记录方法、短路径和耗时,不记录查询参数或正文 | 单测 `answered_probe_resets_stall_count_after_each_slow_request`、`connection_error_does_not_reset_unanswered_count`、`long_request_and_failed_probe_keep_the_actual_count_and_reason`、`three_short_unanswered_requests_report_a_consecutive_stall`、`answered_session_delete_does_not_mask_a_failed_probe`、`failed_request_log_keeps_endpoint_and_time_without_query`、`successful_request_log_does_not_include_response_body`;真机:同一 iPad、同一 WDA,把只读业务请求的客户端时限缩短到 20ms,短探测保留 5s,对照修复前后各 3 轮 | | 146 | App 内浏览器(WebView 在导航栏下面,y≈100)里元素坐标整体偏下一个 WebView 的 y:WKWebView 内部有一层节点报 (0,0)、和 WebView 一样大,被当成小组件、之后的子节点都加上偏移,按文字点击点到下面那一行(Safari 全屏的 WebView 从 0 开始,看不出来) | WebView 和它里面的节点不按小组件的相对坐标处理,用元素树里的屏幕坐标 | 单测 `web_contents_keep_screen_coordinates` + 真机(App 内浏览器页面:元素坐标和截图对上,按文字点击点中) | | 147 | 分开点击每下都要等界面空闲(每下约 0.5 秒,`iphone_batch` 连点 5 下约 2.8 秒):双击、要在短时间内连点几下的入口都点不出来(键盘上双击 Shift 只是开了又关,大写锁定没开) | `iphone_tap` 的 `count`:同一点在一个 actions 手势里连点,每下间隔 `MULTI_TAP_GAP_MS`(0.1 秒),一根手指只移动一次(一根手指在一个手势里移到别的点再按,每下会被识别两次);HID 在同一个会话里连发 | 单测 `multi_tap_is_one_request_at_one_point`、`tap_count_defaults_to_one_and_rejects_out_of_range`、`a_tap_without_count_is_one_tap_on_the_wire` + 真机(iPhone 12 mini / iOS 26.4.1:搜索框里 count 2/3/5/10 打出的字数一致;Shift 上 count=2 开大写锁定,分开点两下不开) | +| 148 | 输入框不接受 `iphone_type_text`(应用内网页里的输入框),只能逐个点键盘上的键:`iphone_batch` 每步都等界面空闲,7 个键 3.6 秒;把同一根手指在一个手势里挪到各个键上点,每个键会被按两次 | `one_gesture: true` 把全是 `iphone_tap` 的批量并成一个 W3C 手势,每个点一根手指,第 k 根先空等前面的点按完再按(间隔 0.04 秒),中间不等界面空闲;混了别的步骤直接报错、一步都不执行;没有 WDA 时退回逐个点 | 单测 `one_gesture_turns_taps_into_one_sequence`、`a_sequence_is_one_finger_per_point_in_turn` + 真机(iPhone 12 mini,iOS 26.4.1,Spotlight 数字键盘 7/16/20 位、字母键盘 10 个字母,各重复 3~5 次读回输入框的值全对)| diff --git a/docs/tools.md b/docs/tools.md index ee9d36e..a32ac26 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -96,6 +96,8 @@ Without `then`, the result still warns when a system alert covers the screen, be Steps run in order. The batch stops at the first error or the first `iphone_tap_element` that finds nothing, and reports which step it stopped at. `then` applies once, after the last step. `reuse_elements: true` lets `iphone_tap_element` reuse the element tree from the last 10 seconds; use it only when the steps don't change the layout (for example pressing keys on the same keypad). +`one_gesture: true` is for a batch made only of `iphone_tap` steps: the points are tapped one after another in a single WDA gesture, one finger per point, about 0.04 s apart, with no wait for the interface in between. Use it to press keys on one keyboard when a field doesn't take `iphone_type_text` (some in-app web views only take key taps): on an iPhone 12 mini, 7 digit keys took 1.9 s instead of 3.6 s, 20 took 4.6 s instead of 9.6 s. Nothing is checked between the taps, so check the result afterwards with `then` or a screenshot. Any other kind of step in the batch is an error and nothing runs. Without WDA it falls back to tapping the points one by one. + If the MCP client cancels the call, the remaining steps don't run; a request still queued for the device is dropped too. If no device was selected and the controlled device changes during a batch (for example it was unplugged and another one took over), the batch stops with an error. ```json diff --git a/website/en/guide/tools.md b/website/en/guide/tools.md index 91fba33..af9ee0a 100644 --- a/website/en/guide/tools.md +++ b/website/en/guide/tools.md @@ -26,7 +26,7 @@ With [auto-unlock](./auto-unlock) on, `iphone_screenshot`, `iphone_list_elements | `iphone_press_button` | `home`, `volume_up`, `volume_down`, `lock` | | `iphone_launch_app` / `iphone_terminate_app` | Launch / quit an app by name (e.g. `设置`) or bundle id | | `iphone_open_url` | Open a link or URL scheme | -| `iphone_batch` | Run up to 20 steps in one call, stopping at the first error. If the MCP client cancels the call, the remaining steps don't run; with no device selected, it also stops with an error if the controlled device changes | +| `iphone_batch` | Run up to 20 steps in one call, stopping at the first error. When every step is a coordinate tap, `one_gesture` taps them in turn within one gesture, for pressing keys on one keyboard. If the MCP client cancels the call, the remaining steps don't run; with no device selected, it also stops with an error if the controlled device changes | ## Several devices diff --git a/website/guide/tools.md b/website/guide/tools.md index 543c9cd..31b78a4 100644 --- a/website/guide/tools.md +++ b/website/guide/tools.md @@ -26,7 +26,7 @@ MCP 服务提供 17 个工具,开启[开发者工具](#开发者工具-显式 | `iphone_press_button` | `home`、`volume_up`、`volume_down`、`lock` | | `iphone_launch_app` / `iphone_terminate_app` | 启动 / 结束 App,可以用名字(如「设置」)或 Bundle ID | | `iphone_open_url` | 打开链接或 URL Scheme | -| `iphone_batch` | 一次执行最多 20 步,出错就停。MCP 客户端取消调用时,剩下的步骤不再执行;没选定设备时,执行中控制的设备变了也会停下报错 | +| `iphone_batch` | 一次执行最多 20 步,出错就停。步骤全是坐标点击时,`one_gesture` 把它们放进一个手势里依次点完,适合在同一个键盘上连按。MCP 客户端取消调用时,剩下的步骤不再执行;没选定设备时,执行中控制的设备变了也会停下报错 | ## 接着多台设备