31 lines
824 B
Go
31 lines
824 B
Go
//go:build darwin
|
|
|
|
package winapi
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
// ActivateAppWindow — đưa cửa sổ app lên trước
|
|
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)
|
|
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
|
|
}
|