2

用户切换焦点后,我可以使用以下代码获取应用程序名称:

function applicationWatcher(appName, eventType, appObject)
  if (eventType == hs.application.watcher.activated) then
    print(appName)
  end
end

local appWatcher = hs.application.watcher.new(applicationWatcher)

appName但我想要这个锤子勺初始化。

4

1 回答 1

6

查看hs.application.frontmostApplication()功能:http ://www.hammerspoon.org/docs/hs.application.html#frontmostApplication :)

于 2017-12-07T13:43:31.110 回答