如何使用PyWinAuto单击一个按钮

时间:2016-10-11 14:27:05

标签: python button click pywinauto

我正在尝试做某事(我认为)应该很简单我试图选择一个名为&#34的按钮;开始"。我一直在寻找描述如何点击按钮的文档(带有下降示例)。我一直找不到。无论如何,这是我得到的错误:

Traceback (most recent call last):
  File "C:\Python Scripts\TestVBApp2.py", line 18, in <module>
vbButton1 = ButtonWrapper(vbapp.Button.WrapperObject("Start")).Click
TypeError: WrapperObject() takes 1 positional argument but 2 were given

以下是代码:

from pywinauto.application import Application
from time import sleep
from pywinauto.controls.win32_controls import ButtonWrapper
import pyautogui
pyautogui.FAILSAFE = True

app = Application().Start(cmd_line=u'"C:\\VBPrograms\\SimpleWPFApp.exe"')
app.MainWindow.Wait('ready')
vbapp = app.window_(title_re="MainWindow")
vbButton1 = ButtonWrapper(vbapp.Button.WrapperObject("Start")).Click

附件是应用程序的屏幕截图,其中包含&#34;开始&#34;按钮。

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试将最后一行更改为hey 318 0.08 sol 497 0.22 mat 498 0.06