0

我正在 Linux Mint 中使用 Python 3.8(从不在 Windows 中),并使用 Autokey 95.10 将以下代码拼凑成(日期 + 时间 + 窗口标题)戳记。该代码在 Python 终端中运行良好,但在 Autokey 95.10 中使用时失败率为 75%。有没有另一个图书馆呢?

# win + INS insert current date, time, and filename

import time, datetime, gi, threading
gi.require_version("Wnck", "3.0")
from gi.repository import Wnck

paste = "<ctrl>+v"

time.sleep(0.1)
scr = Wnck.Screen.get_default()
time.sleep(0.1)
scr.force_update()
time.sleep(0.1)
active_title = (scr.get_active_window().get_name())
time.sleep(0.1)
ts = time.time()
time.sleep(0.1)
time_stamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M')
time.sleep(0.1)
combined = time_stamp + " " +active_title 
time.sleep(0.1)
clipboard.fill_clipboard(combined)
time.sleep(0.1)
keyboard.send_keys(paste) 
4

0 回答 0