如何使用 python 从 GUI 可执行文件导出数据

How to export data from a GUI executable using python

这是一个我想从中获取令牌的程序(分配有红色):

我正在尝试使用子流程模块来完成它:

import subprocess
sda = subprocess.Popen(r'C:\Program Files (x86)\SDA New\Steam Desktop Authenticator.exe', stdout = subprocess.PIPE)
outs = sda.communicate(timeout=15)[0]
print(outs)

它 returns 一个 emtry 字符串。如何获得令牌?

解决方案:

from pywinauto import application
from pywinauto import clipboard

app = application.Application()
app.start(r'C:\Program Files (x86)\sda 1.06\Steam Desktop Authenticator.exe',
          timeout=5)
sda = app.window_(title_re="Steam Desktop Authenticator")
time.sleep(2)
sda.Copy.Click()
code = clipboard.GetData()
sda.Close()