diff --git a/visual_workflow_builder/backend/api_v3/dag_execute.py b/visual_workflow_builder/backend/api_v3/dag_execute.py index 3e4c41957..0c3d95c96 100644 --- a/visual_workflow_builder/backend/api_v3/dag_execute.py +++ b/visual_workflow_builder/backend/api_v3/dag_execute.py @@ -921,10 +921,23 @@ def execute_windows(): if vwb_type in _ANCHOR_CLICK_TYPES: anchor_id = action.get('anchor_id') if anchor_id: + anchor_meta = _load_anchor_metadata(anchor_id) + + # Calculer les coordonnées du centre du bbox (fallback si visual échoue) + if anchor_meta: + bbox = anchor_meta.get('bounding_box', {}) + orig = anchor_meta.get('original_size', {}) + orig_w = orig.get('width', 1920) + orig_h = orig.get('height', 1080) + if bbox.get('x') is not None and orig_w > 0 and orig_h > 0: + cx = (bbox['x'] + bbox.get('width', 0) / 2) / orig_w + cy = (bbox['y'] + bbox.get('height', 0) / 2) / orig_h + action['x_pct'] = round(cx, 4) + action['y_pct'] = round(cy, 4) + + # Tenter aussi le visual_mode (template matching) anchor_b64 = _load_anchor_image_b64(anchor_id) if anchor_b64: - # Charger les métadonnées pour le bounding_box de référence - anchor_meta = _load_anchor_metadata(anchor_id) target_spec = { 'anchor_image_base64': anchor_b64, 'anchor_id': anchor_id,