我需要在acrobat中获取已打开PDF的文件名。由于脚本不知道PDF路径,因此需要查找活动窗口的标题。
我在Obtain Active window using Python上找到了这个脚本:
from win32gui import GetWindowText, GetForegroundWindow
print GetWindowText(GetForegroundWindow())
它正在运行但是因为我将脚本作为键盘快捷键启动,活动窗口发生变化:它从acrobat切换到python 。活动窗口不再是在acrobat中打开的pdf,而是启动脚本的快捷方式。
因此脚本打印"script.py"
,而不是"my pdf.pdf-adobe acrobat"
知道如何解决这个问题吗?