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