我可以在用户使用以下代码切换焦点后获取应用程序名称:
function applicationWatcher(appName, eventType, appObject)
if (eventType == hs.application.watcher.activated) then
print(appName)
end
end
local appWatcher = hs.application.watcher.new(applicationWatcher)
答案 0 :(得分:2)
请参阅hs.application.frontmostApplication()
功能:http://www.hammerspoon.org/docs/hs.application.html#frontmostApplication:)