Files
rikkei_simple_care/client/internal/winapi/window_darwin.go
PhuocNTB b4c3155564
All checks were successful
Deploy on Master Change / deploy (push) Successful in 1m15s
fix ui
2026-07-13 10:04:56 +07:00

40 lines
1.0 KiB
Go

//go:build darwin
package winapi
import (
"fmt"
"os/exec"
)
// ActivateAppWindow — đưa cửa sổ Simple Care đang chạy lên trước (theo tên process / title).
func ActivateAppWindow(titleHint string) {
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()
}
// PlayNotifySound — beep hệ thống macOS
func PlayNotifySound() {
cmd := exec.Command("osascript", "-e", "beep")
_ = cmd.Run()
}
// ShowWarningMessageBox hiển thị hộp thoại cảnh báo macOS bất đồng bộ
func ShowWarningMessageBox(title, message string) {
script := fmt.Sprintf(`display alert %q message %q`, title, message)
cmd := exec.Command("osascript", "-e", script)
_ = cmd.Start() // Run asynchronously
}