cyongfrank's recent timeline updates
cyongfrank

cyongfrank

V2EX member #597484, joined on 2022-10-15 07:59:53 +08:00
cyongfrank's recent replies
客服说今天 35 ,不降价了。。。。
May 11, 2023
Replied to a topic by 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.)
May 9, 2023
Replied to a topic by cyongfrank Apple 新 Apple Watch Pride 表带 [可能]
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   938 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 21ms · UTC 21:22 · PVG 05:22 · LAX 14:22 · JFK 17:22
♥ Do have faith in what you're doing.