如何找到当前专注于 macos 的程序?

How do I find the program with current focus on macos?

是否有 API 函数调用 returns 一个标识符来找出哪个程序具有当前焦点。

我正在寻找这个问题的答案,但关于 MacOS How do I find the program with the current focus?

或者 frontmostApplication or menuBarOwningApplication,具体取决于 "focus" 的具体含义。