macos 莫名失去焦点

执行下述 python 代码,观测除了当前应用程序外,还有谁占用了焦点

1
2
3
4
5
6
7
8
9
#!/usr/bin/python

from AppKit import NSWorkspace
import time
t = range(1,100)
for i in t:
time.sleep(3)
activeAppName = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName']
print activeAppName

查看输出即可