在Libre Office中通过python打开.ods文件



请对我宽容点,我刚开始学Python。

我想做一个程序,节省我花在文件(工作)的时间。我可以打开Libre Office Calc:

subprocess.call(['C:Program FilesLibreOfficeprogramscalc.exe'])

但是这会打开一个新文件。如果我打开我想要处理的文件,Libre Office会生成一个带有新句柄的新窗口,我不知道这个句柄的ID(所以我无法测量这个句柄的运行时间)。

有没有可能直接打开文件?或者输入一个可以打开的链接?

我找到了一个解决办法:我没有使用Python打开程序,而是让pywinauto列出所有程序,然后写下程序的名称:

while True:
x=1
while x <= 2:
windows = Desktop(backend="uia").windows()
print("If you do not find your program in the list write '@'")
print("")
for w in windows:
if w.window_text()!="":
print(str(w.window_text()))
program_Open=str(input())
if program_Open!="@":
x=3

if w.window_text()!="":将删除由后台程序引起的列表中的空行。

最新更新