@mediar-ai/terminator 0.24.7 → 0.24.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -604,9 +604,12 @@ export declare class Desktop {
604
604
  * @param {number} [yPercentage=50] - Y position within bounds as percentage (0-100). Defaults to 50 (center).
605
605
  * @param {ClickType} [clickType='left'] - Type of click: 'left', 'double', or 'right'.
606
606
  * @param {boolean} [restoreCursor=true] - If true, restore cursor to original position after clicking.
607
+ * @param {string} [process] - Process name for window screenshot capture. If provided, enables window screenshots.
608
+ * @param {boolean} [includeWindowScreenshot=true] - Whether to capture window screenshot (requires process).
609
+ * @param {boolean} [includeMonitorScreenshots=false] - Whether to capture monitor screenshots after clicking.
607
610
  * @returns {ClickResult} Result with clicked coordinates and method details.
608
611
  */
609
- clickAtBounds(x: number, y: number, width: number, height: number, xPercentage?: number | undefined | null, yPercentage?: number | undefined | null, clickType?: ClickType | undefined | null, restoreCursor?: boolean | undefined | null): ClickResult
612
+ clickAtBounds(x: number, y: number, width: number, height: number, xPercentage?: number | undefined | null, yPercentage?: number | undefined | null, clickType?: ClickType | undefined | null, restoreCursor?: boolean | undefined | null, process?: string | undefined | null, includeWindowScreenshot?: boolean | undefined | null, includeMonitorScreenshots?: boolean | undefined | null): ClickResult
610
613
  /**
611
614
  * Click on an element by its index from the last tree/vision query.
612
615
  *
@@ -619,9 +622,12 @@ export declare class Desktop {
619
622
  * @param {number} [yPercentage=50] - Y position within bounds as percentage (0-100).
620
623
  * @param {ClickType} [clickType='Left'] - Type of click: 'Left', 'Double', or 'Right'.
621
624
  * @param {boolean} [restoreCursor=true] - If true, restore cursor to original position after clicking.
625
+ * @param {string} [process] - Process name for window screenshot capture. If provided, enables window screenshots.
626
+ * @param {boolean} [includeWindowScreenshot=true] - Whether to capture window screenshot (requires process).
627
+ * @param {boolean} [includeMonitorScreenshots=false] - Whether to capture monitor screenshots after clicking.
622
628
  * @returns {ClickResult} Result with clicked coordinates, element info, and method details.
623
629
  */
624
- clickByIndex(index: number, visionType?: VisionType | undefined | null, xPercentage?: number | undefined | null, yPercentage?: number | undefined | null, clickType?: ClickType | undefined | null, restoreCursor?: boolean | undefined | null): ClickResult
630
+ clickByIndex(index: number, visionType?: VisionType | undefined | null, xPercentage?: number | undefined | null, yPercentage?: number | undefined | null, clickType?: ClickType | undefined | null, restoreCursor?: boolean | undefined | null, process?: string | undefined | null, includeWindowScreenshot?: boolean | undefined | null, includeMonitorScreenshots?: boolean | undefined | null): ClickResult
625
631
  /**
626
632
  * (async) Run a shell command.
627
633
  *
@@ -770,8 +776,11 @@ export declare class Desktop {
770
776
  * Open a file with its default application.
771
777
  *
772
778
  * @param {string} filePath - Path to the file to open.
779
+ * @param {string} [process] - Process name for window screenshot capture. If provided, enables window screenshots.
780
+ * @param {boolean} [includeWindowScreenshot=true] - Whether to capture window screenshot (requires process).
781
+ * @param {boolean} [includeMonitorScreenshots=false] - Whether to capture monitor screenshots after opening.
773
782
  */
774
- openFile(filePath: string): void
783
+ openFile(filePath: string, process?: string | undefined | null, includeWindowScreenshot?: boolean | undefined | null, includeMonitorScreenshots?: boolean | undefined | null): void
775
784
  /**
776
785
  * Activate a browser window by title.
777
786
  *
@@ -949,8 +958,11 @@ export declare class Desktop {
949
958
  * (async) Press a key globally.
950
959
  *
951
960
  * @param {string} key - The key to press (e.g., "Enter", "Ctrl+C", "F1").
961
+ * @param {string} [process] - Process name for window screenshot capture. If provided, enables window screenshots.
962
+ * @param {boolean} [includeWindowScreenshot=true] - Whether to capture window screenshot (requires process).
963
+ * @param {boolean} [includeMonitorScreenshots=false] - Whether to capture monitor screenshots after key press.
952
964
  */
953
- pressKey(key: string): Promise<void>
965
+ pressKey(key: string, process?: string | undefined | null, includeWindowScreenshot?: boolean | undefined | null, includeMonitorScreenshots?: boolean | undefined | null): Promise<void>
954
966
  /**
955
967
  * (async) Execute JavaScript in a browser tab.
956
968
  * Finds the browser window by process name and executes the script.
@@ -1236,8 +1248,9 @@ export declare class Element {
1236
1248
  * @param {number} startY - Starting Y coordinate.
1237
1249
  * @param {number} endX - Ending X coordinate.
1238
1250
  * @param {number} endY - Ending Y coordinate.
1251
+ * @param {ActionOptions} [options] - Optional action options.
1239
1252
  */
1240
- mouseDrag(startX: number, startY: number, endX: number, endY: number): void
1253
+ mouseDrag(startX: number, startY: number, endX: number, endY: number, options?: ActionOptions | undefined | null): void
1241
1254
  /**
1242
1255
  * Press and hold mouse at coordinates.
1243
1256
  *
@@ -1252,8 +1265,12 @@ export declare class Element {
1252
1265
  * @param {number} y - Y coordinate.
1253
1266
  */
1254
1267
  mouseMove(x: number, y: number): void
1255
- /** Release mouse button. */
1256
- mouseRelease(): void
1268
+ /**
1269
+ * Release mouse button.
1270
+ *
1271
+ * @param {ActionOptions} [options] - Optional action options.
1272
+ */
1273
+ mouseRelease(options?: ActionOptions | undefined | null): void
1257
1274
  /**
1258
1275
  * Create a locator from this element.
1259
1276
  * Accepts either a selector string or a Selector object.
@@ -1356,9 +1373,10 @@ export declare class Element {
1356
1373
  * It only performs an action if the control is not already in the desired state.
1357
1374
  *
1358
1375
  * @param {boolean} state - The desired toggle state.
1376
+ * @param {ActionOptions} [options] - Optional action options.
1359
1377
  * @returns {void}
1360
1378
  */
1361
- setToggled(state: boolean): void
1379
+ setToggled(state: boolean, options?: ActionOptions | undefined | null): void
1362
1380
  /**
1363
1381
  * Checks if an element is selected (e.g., list item, tree node, tab).
1364
1382
  *
@@ -1384,9 +1402,10 @@ export declare class Element {
1384
1402
  * Sets the value of a range-based control like a slider.
1385
1403
  *
1386
1404
  * @param {number} value - The value to set.
1405
+ * @param {ActionOptions} [options] - Optional action options.
1387
1406
  * @returns {void}
1388
1407
  */
1389
- setRangeValue(value: number): void
1408
+ setRangeValue(value: number, options?: ActionOptions | undefined | null): void
1390
1409
  /**
1391
1410
  * Gets the value attribute of an element (text inputs, combo boxes, etc.).
1392
1411
  *
package/package.json CHANGED
@@ -38,8 +38,8 @@
38
38
  }
39
39
  },
40
40
  "optionalDependencies": {
41
- "@mediar-ai/terminator-win32-arm64-msvc": "0.24.7",
42
- "@mediar-ai/terminator-win32-x64-msvc": "0.24.7"
41
+ "@mediar-ai/terminator-win32-arm64-msvc": "0.24.9",
42
+ "@mediar-ai/terminator-win32-x64-msvc": "0.24.9"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",
@@ -57,5 +57,5 @@
57
57
  "test-hook": "powershell.exe -ExecutionPolicy Bypass -File \"../../.git/hooks/pre-push.ps1\""
58
58
  },
59
59
  "types": "wrapper.d.ts",
60
- "version": "0.24.7"
60
+ "version": "0.24.9"
61
61
  }
package/src/desktop.rs CHANGED
@@ -201,6 +201,9 @@ impl Desktop {
201
201
  /// @param {number} [yPercentage=50] - Y position within bounds as percentage (0-100). Defaults to 50 (center).
202
202
  /// @param {ClickType} [clickType='left'] - Type of click: 'left', 'double', or 'right'.
203
203
  /// @param {boolean} [restoreCursor=true] - If true, restore cursor to original position after clicking.
204
+ /// @param {string} [process] - Process name for window screenshot capture. If provided, enables window screenshots.
205
+ /// @param {boolean} [includeWindowScreenshot=true] - Whether to capture window screenshot (requires process).
206
+ /// @param {boolean} [includeMonitorScreenshots=false] - Whether to capture monitor screenshots after clicking.
204
207
  /// @returns {ClickResult} Result with clicked coordinates and method details.
205
208
  #[napi]
206
209
  #[allow(clippy::too_many_arguments)]
@@ -214,6 +217,9 @@ impl Desktop {
214
217
  y_percentage: Option<u8>,
215
218
  click_type: Option<ClickType>,
216
219
  restore_cursor: Option<bool>,
220
+ process: Option<String>,
221
+ include_window_screenshot: Option<bool>,
222
+ include_monitor_screenshots: Option<bool>,
217
223
  ) -> napi::Result<ClickResult> {
218
224
  let bounds = (x, y, width, height);
219
225
  let click_position = match (x_percentage, y_percentage) {
@@ -225,10 +231,27 @@ impl Desktop {
225
231
  let click_type = click_type.unwrap_or(ClickType::Left);
226
232
  let restore_cursor = restore_cursor.unwrap_or(true);
227
233
 
228
- self.inner
234
+ let result = self
235
+ .inner
229
236
  .click_at_bounds(bounds, click_position, click_type.into(), restore_cursor)
230
237
  .map(ClickResult::from)
231
- .map_err(map_error)
238
+ .map_err(map_error);
239
+
240
+ // Get PID from process name if provided
241
+ let pid = process
242
+ .as_ref()
243
+ .and_then(|p| find_pid_for_process(&self.inner, p).ok());
244
+
245
+ // Capture screenshots if requested
246
+ let _screenshots = capture_screenshots(
247
+ &self.inner,
248
+ pid,
249
+ include_window_screenshot.unwrap_or(true) && pid.is_some(),
250
+ include_monitor_screenshots.unwrap_or(false),
251
+ "clickAtBounds",
252
+ );
253
+
254
+ result
232
255
  }
233
256
 
234
257
  /// Click on an element by its index from the last tree/vision query.
@@ -242,8 +265,12 @@ impl Desktop {
242
265
  /// @param {number} [yPercentage=50] - Y position within bounds as percentage (0-100).
243
266
  /// @param {ClickType} [clickType='Left'] - Type of click: 'Left', 'Double', or 'Right'.
244
267
  /// @param {boolean} [restoreCursor=true] - If true, restore cursor to original position after clicking.
268
+ /// @param {string} [process] - Process name for window screenshot capture. If provided, enables window screenshots.
269
+ /// @param {boolean} [includeWindowScreenshot=true] - Whether to capture window screenshot (requires process).
270
+ /// @param {boolean} [includeMonitorScreenshots=false] - Whether to capture monitor screenshots after clicking.
245
271
  /// @returns {ClickResult} Result with clicked coordinates, element info, and method details.
246
272
  #[napi]
273
+ #[allow(clippy::too_many_arguments)]
247
274
  pub fn click_by_index(
248
275
  &self,
249
276
  index: u32,
@@ -252,6 +279,9 @@ impl Desktop {
252
279
  y_percentage: Option<u8>,
253
280
  click_type: Option<ClickType>,
254
281
  restore_cursor: Option<bool>,
282
+ process: Option<String>,
283
+ include_window_screenshot: Option<bool>,
284
+ include_monitor_screenshots: Option<bool>,
255
285
  ) -> napi::Result<ClickResult> {
256
286
  let vision_type = vision_type.unwrap_or(VisionType::UiTree);
257
287
  let click_position = match (x_percentage, y_percentage) {
@@ -263,7 +293,8 @@ impl Desktop {
263
293
  let click_type = click_type.unwrap_or(ClickType::Left);
264
294
  let restore_cursor = restore_cursor.unwrap_or(true);
265
295
 
266
- self.inner
296
+ let result = self
297
+ .inner
267
298
  .click_by_index(
268
299
  index,
269
300
  vision_type.into(),
@@ -272,7 +303,23 @@ impl Desktop {
272
303
  restore_cursor,
273
304
  )
274
305
  .map(ClickResult::from)
275
- .map_err(map_error)
306
+ .map_err(map_error);
307
+
308
+ // Get PID from process name if provided
309
+ let pid = process
310
+ .as_ref()
311
+ .and_then(|p| find_pid_for_process(&self.inner, p).ok());
312
+
313
+ // Capture screenshots if requested
314
+ let _screenshots = capture_screenshots(
315
+ &self.inner,
316
+ pid,
317
+ include_window_screenshot.unwrap_or(true) && pid.is_some(),
318
+ include_monitor_screenshots.unwrap_or(false),
319
+ "clickByIndex",
320
+ );
321
+
322
+ result
276
323
  }
277
324
 
278
325
  /// (async) Run a shell command.
@@ -1631,9 +1678,34 @@ impl Desktop {
1631
1678
  /// Open a file with its default application.
1632
1679
  ///
1633
1680
  /// @param {string} filePath - Path to the file to open.
1681
+ /// @param {string} [process] - Process name for window screenshot capture. If provided, enables window screenshots.
1682
+ /// @param {boolean} [includeWindowScreenshot=true] - Whether to capture window screenshot (requires process).
1683
+ /// @param {boolean} [includeMonitorScreenshots=false] - Whether to capture monitor screenshots after opening.
1634
1684
  #[napi]
1635
- pub fn open_file(&self, file_path: String) -> napi::Result<()> {
1636
- self.inner.open_file(&file_path).map_err(map_error)
1685
+ pub fn open_file(
1686
+ &self,
1687
+ file_path: String,
1688
+ process: Option<String>,
1689
+ include_window_screenshot: Option<bool>,
1690
+ include_monitor_screenshots: Option<bool>,
1691
+ ) -> napi::Result<()> {
1692
+ let result = self.inner.open_file(&file_path).map_err(map_error);
1693
+
1694
+ // Get PID from process name if provided
1695
+ let pid = process
1696
+ .as_ref()
1697
+ .and_then(|p| find_pid_for_process(&self.inner, p).ok());
1698
+
1699
+ // Capture screenshots if requested
1700
+ let _screenshots = capture_screenshots(
1701
+ &self.inner,
1702
+ pid,
1703
+ include_window_screenshot.unwrap_or(true) && pid.is_some(),
1704
+ include_monitor_screenshots.unwrap_or(false),
1705
+ "openFile",
1706
+ );
1707
+
1708
+ result
1637
1709
  }
1638
1710
 
1639
1711
  /// Activate a browser window by title.
@@ -2315,9 +2387,34 @@ impl Desktop {
2315
2387
  /// (async) Press a key globally.
2316
2388
  ///
2317
2389
  /// @param {string} key - The key to press (e.g., "Enter", "Ctrl+C", "F1").
2390
+ /// @param {string} [process] - Process name for window screenshot capture. If provided, enables window screenshots.
2391
+ /// @param {boolean} [includeWindowScreenshot=true] - Whether to capture window screenshot (requires process).
2392
+ /// @param {boolean} [includeMonitorScreenshots=false] - Whether to capture monitor screenshots after key press.
2318
2393
  #[napi]
2319
- pub async fn press_key(&self, key: String) -> napi::Result<()> {
2320
- self.inner.press_key(&key).await.map_err(map_error)
2394
+ pub async fn press_key(
2395
+ &self,
2396
+ key: String,
2397
+ process: Option<String>,
2398
+ include_window_screenshot: Option<bool>,
2399
+ include_monitor_screenshots: Option<bool>,
2400
+ ) -> napi::Result<()> {
2401
+ let result = self.inner.press_key(&key).await.map_err(map_error);
2402
+
2403
+ // Get PID from process name if provided
2404
+ let pid = process
2405
+ .as_ref()
2406
+ .and_then(|p| find_pid_for_process(&self.inner, p).ok());
2407
+
2408
+ // Capture screenshots if requested
2409
+ let _screenshots = capture_screenshots(
2410
+ &self.inner,
2411
+ pid,
2412
+ include_window_screenshot.unwrap_or(true) && pid.is_some(),
2413
+ include_monitor_screenshots.unwrap_or(false),
2414
+ "pressKey",
2415
+ );
2416
+
2417
+ result
2321
2418
  }
2322
2419
 
2323
2420
  /// (async) Execute JavaScript in a browser tab.
package/src/element.rs CHANGED
@@ -259,7 +259,8 @@ impl Element {
259
259
  #[napi]
260
260
  pub async fn click(&self, options: Option<ActionOptions>) -> napi::Result<ClickResult> {
261
261
  let opts = options.unwrap_or_default();
262
- let restore_focus = opts.restore_focus.unwrap_or(true);
262
+ // Default false: clicking means user wants focus on clicked element
263
+ let restore_focus = opts.restore_focus.unwrap_or(false);
263
264
 
264
265
  // FOCUS RESTORATION: Save focus state BEFORE any window operations
265
266
  #[cfg(target_os = "windows")]
@@ -387,7 +388,8 @@ impl Element {
387
388
  #[napi]
388
389
  pub fn double_click(&self, options: Option<ActionOptions>) -> napi::Result<ClickResult> {
389
390
  let opts = options.unwrap_or_default();
390
- let restore_focus = opts.restore_focus.unwrap_or(true);
391
+ // Default false: clicking means user wants focus on clicked element
392
+ let restore_focus = opts.restore_focus.unwrap_or(false);
391
393
 
392
394
  // FOCUS RESTORATION: Save focus state BEFORE any window operations
393
395
  #[cfg(target_os = "windows")]
@@ -434,7 +436,8 @@ impl Element {
434
436
  #[napi]
435
437
  pub fn right_click(&self, options: Option<ActionOptions>) -> napi::Result<()> {
436
438
  let opts = options.unwrap_or_default();
437
- let restore_focus = opts.restore_focus.unwrap_or(true);
439
+ // Default false: clicking means user wants focus on clicked element
440
+ let restore_focus = opts.restore_focus.unwrap_or(false);
438
441
 
439
442
  // FOCUS RESTORATION: Save focus state BEFORE any window operations
440
443
  #[cfg(target_os = "windows")]
@@ -451,6 +454,14 @@ impl Element {
451
454
  let _ = self.inner.activate_window();
452
455
  let result = self.inner.right_click().map_err(map_error);
453
456
 
457
+ // Capture screenshots if requested
458
+ let _screenshots = capture_element_screenshots(
459
+ &self.inner,
460
+ opts.include_window_screenshot.unwrap_or(true),
461
+ opts.include_monitor_screenshots.unwrap_or(false),
462
+ "rightClick",
463
+ );
464
+
454
465
  // FOCUS RESTORATION: Restore focus state after action if we saved it
455
466
  #[cfg(target_os = "windows")]
456
467
  if let Some(state) = saved_focus {
@@ -467,7 +478,8 @@ impl Element {
467
478
  #[napi]
468
479
  pub fn hover(&self, options: Option<ActionOptions>) -> napi::Result<()> {
469
480
  let opts = options.unwrap_or_default();
470
- let restore_focus = opts.restore_focus.unwrap_or(true);
481
+ // Default false: hover shouldn't steal focus
482
+ let restore_focus = opts.restore_focus.unwrap_or(false);
471
483
 
472
484
  // FOCUS RESTORATION: Save focus state BEFORE any window operations
473
485
  #[cfg(target_os = "windows")]
@@ -484,6 +496,14 @@ impl Element {
484
496
  let _ = self.inner.activate_window();
485
497
  let result = self.inner.hover().map_err(map_error);
486
498
 
499
+ // Capture screenshots if requested
500
+ let _screenshots = capture_element_screenshots(
501
+ &self.inner,
502
+ opts.include_window_screenshot.unwrap_or(true),
503
+ opts.include_monitor_screenshots.unwrap_or(false),
504
+ "hover",
505
+ );
506
+
487
507
  // FOCUS RESTORATION: Restore focus state after action if we saved it
488
508
  #[cfg(target_os = "windows")]
489
509
  if let Some(state) = saved_focus {
@@ -720,7 +740,8 @@ impl Element {
720
740
  #[napi]
721
741
  pub fn invoke(&self, options: Option<ActionOptions>) -> napi::Result<ActionResult> {
722
742
  let opts = options.unwrap_or_default();
723
- let restore_focus = opts.restore_focus.unwrap_or(true);
743
+ // Default false: invoking is like clicking
744
+ let restore_focus = opts.restore_focus.unwrap_or(false);
724
745
 
725
746
  // FOCUS RESTORATION: Save focus state BEFORE any window operations
726
747
  #[cfg(target_os = "windows")]
@@ -852,6 +873,7 @@ impl Element {
852
873
  /// @param {number} startY - Starting Y coordinate.
853
874
  /// @param {number} endX - Ending X coordinate.
854
875
  /// @param {number} endY - Ending Y coordinate.
876
+ /// @param {ActionOptions} [options] - Optional action options.
855
877
  #[napi]
856
878
  pub fn mouse_drag(
857
879
  &self,
@@ -859,10 +881,28 @@ impl Element {
859
881
  start_y: f64,
860
882
  end_x: f64,
861
883
  end_y: f64,
884
+ options: Option<ActionOptions>,
862
885
  ) -> napi::Result<()> {
863
- self.inner
886
+ let opts = options.unwrap_or_default();
887
+
888
+ if opts.highlight_before_action.unwrap_or(false) {
889
+ let _ = self.inner.highlight_before_action("mouse_drag");
890
+ }
891
+
892
+ let result = self
893
+ .inner
864
894
  .mouse_drag(start_x, start_y, end_x, end_y)
865
- .map_err(map_error)
895
+ .map_err(map_error);
896
+
897
+ // Capture screenshots if requested
898
+ let _screenshots = capture_element_screenshots(
899
+ &self.inner,
900
+ opts.include_window_screenshot.unwrap_or(true),
901
+ opts.include_monitor_screenshots.unwrap_or(false),
902
+ "mouseDrag",
903
+ );
904
+
905
+ result
866
906
  }
867
907
 
868
908
  /// Press and hold mouse at coordinates.
@@ -884,9 +924,27 @@ impl Element {
884
924
  }
885
925
 
886
926
  /// Release mouse button.
927
+ ///
928
+ /// @param {ActionOptions} [options] - Optional action options.
887
929
  #[napi]
888
- pub fn mouse_release(&self) -> napi::Result<()> {
889
- self.inner.mouse_release().map_err(map_error)
930
+ pub fn mouse_release(&self, options: Option<ActionOptions>) -> napi::Result<()> {
931
+ let opts = options.unwrap_or_default();
932
+
933
+ if opts.highlight_before_action.unwrap_or(false) {
934
+ let _ = self.inner.highlight_before_action("mouse_release");
935
+ }
936
+
937
+ let result = self.inner.mouse_release().map_err(map_error);
938
+
939
+ // Capture screenshots if requested
940
+ let _screenshots = capture_element_screenshots(
941
+ &self.inner,
942
+ opts.include_window_screenshot.unwrap_or(true),
943
+ opts.include_monitor_screenshots.unwrap_or(false),
944
+ "mouseRelease",
945
+ );
946
+
947
+ result
890
948
  }
891
949
 
892
950
  /// Create a locator from this element.
@@ -1084,6 +1142,14 @@ impl Element {
1084
1142
  }
1085
1143
  let result = self.inner.select_option(&option_name).map_err(map_error);
1086
1144
 
1145
+ // Capture screenshots if requested
1146
+ let _screenshots = capture_element_screenshots(
1147
+ &self.inner,
1148
+ opts.include_window_screenshot.unwrap_or(true),
1149
+ opts.include_monitor_screenshots.unwrap_or(false),
1150
+ "selectOption",
1151
+ );
1152
+
1087
1153
  // FOCUS RESTORATION: Restore focus state after action if we saved it
1088
1154
  #[cfg(target_os = "windows")]
1089
1155
  if let Some(state) = saved_focus {
@@ -1114,10 +1180,27 @@ impl Element {
1114
1180
  /// It only performs an action if the control is not already in the desired state.
1115
1181
  ///
1116
1182
  /// @param {boolean} state - The desired toggle state.
1183
+ /// @param {ActionOptions} [options] - Optional action options.
1117
1184
  /// @returns {void}
1118
1185
  #[napi]
1119
- pub fn set_toggled(&self, state: bool) -> napi::Result<()> {
1120
- self.inner.set_toggled(state).map_err(map_error)
1186
+ pub fn set_toggled(&self, state: bool, options: Option<ActionOptions>) -> napi::Result<()> {
1187
+ let opts = options.unwrap_or_default();
1188
+
1189
+ if opts.highlight_before_action.unwrap_or(false) {
1190
+ let _ = self.inner.highlight_before_action("set_toggled");
1191
+ }
1192
+
1193
+ let result = self.inner.set_toggled(state).map_err(map_error);
1194
+
1195
+ // Capture screenshots if requested
1196
+ let _screenshots = capture_element_screenshots(
1197
+ &self.inner,
1198
+ opts.include_window_screenshot.unwrap_or(true),
1199
+ opts.include_monitor_screenshots.unwrap_or(false),
1200
+ "setToggled",
1201
+ );
1202
+
1203
+ result
1121
1204
  }
1122
1205
 
1123
1206
  /// Checks if an element is selected (e.g., list item, tree node, tab).
@@ -1153,6 +1236,14 @@ impl Element {
1153
1236
  }
1154
1237
  let result = self.inner.set_selected(state).map_err(map_error);
1155
1238
 
1239
+ // Capture screenshots if requested
1240
+ let _screenshots = capture_element_screenshots(
1241
+ &self.inner,
1242
+ opts.include_window_screenshot.unwrap_or(true),
1243
+ opts.include_monitor_screenshots.unwrap_or(false),
1244
+ "setSelected",
1245
+ );
1246
+
1156
1247
  // FOCUS RESTORATION: Restore focus state after action if we saved it
1157
1248
  #[cfg(target_os = "windows")]
1158
1249
  if let Some(state) = saved_focus {
@@ -1174,10 +1265,27 @@ impl Element {
1174
1265
  /// Sets the value of a range-based control like a slider.
1175
1266
  ///
1176
1267
  /// @param {number} value - The value to set.
1268
+ /// @param {ActionOptions} [options] - Optional action options.
1177
1269
  /// @returns {void}
1178
1270
  #[napi]
1179
- pub fn set_range_value(&self, value: f64) -> napi::Result<()> {
1180
- self.inner.set_range_value(value).map_err(map_error)
1271
+ pub fn set_range_value(&self, value: f64, options: Option<ActionOptions>) -> napi::Result<()> {
1272
+ let opts = options.unwrap_or_default();
1273
+
1274
+ if opts.highlight_before_action.unwrap_or(false) {
1275
+ let _ = self.inner.highlight_before_action("set_range_value");
1276
+ }
1277
+
1278
+ let result = self.inner.set_range_value(value).map_err(map_error);
1279
+
1280
+ // Capture screenshots if requested
1281
+ let _screenshots = capture_element_screenshots(
1282
+ &self.inner,
1283
+ opts.include_window_screenshot.unwrap_or(true),
1284
+ opts.include_monitor_screenshots.unwrap_or(false),
1285
+ "setRangeValue",
1286
+ );
1287
+
1288
+ result
1181
1289
  }
1182
1290
 
1183
1291
  /// Gets the value attribute of an element (text inputs, combo boxes, etc.).