package app

import (
	"fmt"
	"log"
	"os/exec"
)

func runPythonOcrFromScreen() error {
	script := `
import sys
from pathlib import Path
root = Path(r"C:\Users\kenny\Documents\git\messpy\VRC\VRWT_Tool\VRC_OSC")
sys.path.insert(0, str(root / "src"))
from ocr.ocr_actions import runOcrFromScreen
runOcrFromScreen()
`
	cmd := exec.Command("python", "-c", script)
	cmd.Dir = `C:\Users\kenny\Documents\git\messpy\VRC\VRWT_Tool\VRC_OSC`
	out, err := cmd.CombinedOutput()
	if len(out) > 0 {
		log.Printf("ocr output: %s", string(out))
		SetOCRText(string(out))
		SetTranslateText("翻訳: 未実装")
	}
	if err != nil {
		return fmt.Errorf("ocr failed: %w", err)
	}
	return nil
}
