cyongfrank 最近的时间轴更新
cyongfrank

cyongfrank

V2EX 第 597484 号会员,加入于 2022-10-15 07:59:53 +08:00
cyongfrank 最近回复了
客服说今天 35 ,不降价了。。。。
352 天前
回复了 dalang 创建的主题 MacBook Pro mac 使用时窗口经常无故自己切换
> [How do I tell which app stole my focus in OS X?]( https://superuser.com/questions/734007/how-do-i-tell-which-app-stole-my-focus-in-os-x)

```python
#!/usr/bin/python

try:
from AppKit import NSWorkspace
except ImportError:
print("Can't import AppKit -- try `pip install PyObjC`")
print("(see instructions for running in a venv with PyObjC)")
exit(1)

from datetime import datetime
from time import sleep

last_active_name = None
while True:
active_app = NSWorkspace.sharedWorkspace().activeApplication()
if active_app['NSApplicationName'] != last_active_name:
last_active_name = active_app['NSApplicationName']
print('%s: %s [%s]' % (
datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
active_app['NSApplicationName'],
active_app['NSApplicationPath']
))
sleep(1)
```

1. Create a directory, and save the script above into it as "focus-stealer.py"
2. In a terminal in that directory enter these commands:

```sh
/usr/bin/python3 -m venv venv
./venv/bin/python -m pip install PyObjC
```

(This creates a new, isolated Python virtual environment, just for this script, and installs PyObjC into it. This avoids modifying your system Python installation or needing to use sudo.)

3. Now you can run the script. In a terminal in that same directory run:

```sh
./venv/bin/python ./focus-stealer.py
```

(In the future, you can skip directly to this step—no need to reinstall things.)
354 天前
回复了 cyongfrank 创建的主题 Apple 新 Apple Watch Pride 表带 [可能]
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1481 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 16:57 · PVG 00:57 · LAX 09:57 · JFK 12:57
Developed with CodeLauncher
♥ Do have faith in what you're doing.