fix ui
All checks were successful
Deploy on Master Change / deploy (push) Successful in 1m15s

This commit is contained in:
2026-07-13 10:04:56 +07:00
parent 58c96609b6
commit b4c3155564
11 changed files with 587 additions and 97 deletions

View File

@@ -4,14 +4,23 @@ package winapi
import (
"fmt"
"os"
"os/exec"
)
// ActivateAppWindow — đưa cửa sổ app lên trước
// ActivateAppWindow — đưa cửa sổ Simple Care đang chạy lên trước (theo tên process / title).
func ActivateAppWindow(titleHint string) {
pid := os.Getpid()
script := fmt.Sprintf(`tell application "System Events" to set frontmost of first process whose unix id is %d to true`, pid)
hint := titleHint
if hint == "" {
hint = "Simple Care"
}
script := fmt.Sprintf(`
tell application "System Events"
set candidates to every process whose name contains %q or name contains "simple_care" or name contains "SimpleCare"
if (count of candidates) > 0 then
set frontmost of item 1 of candidates to true
end if
end tell
`, hint)
cmd := exec.Command("osascript", "-e", script)
_ = cmd.Run()
}