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

时间:2016-05-12 18:44:14

标签: python subprocess screen-scraping ui-automation pywinauto

这是一个我想从中获取令牌的程序(用红色分配): enter image description here

我正在尝试使用子进程模块:

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)

它返回一个emtry字符串。我怎样才能获得令牌?

1 个答案:

答案 0 :(得分:2)

解决方案:

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()