This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user