pywinauto qwidget 点击触发无动作 [英] pywinauto qwidget click triggers no action

查看:99
本文介绍了pywinauto qwidget 点击触发无动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很明显,一个QWidget按钮被按下和释放,不幸的是没有触发任何动作.

环境类似于

解决方案

Qt 应用可以使用 Application(backend='uia') 自动化.请阅读专为 pywinauto 0.6.0+ 编写的入门指南新后端.它解释了核心概念和许多有用的技巧.

附言我已经下载了这个精简版的应用程序,稍后会尝试为您制作一个示例.

It is visibly that a QWidget button is pressed and released, unfortunately no action is triggered.

The environment is similar to find qwidget object text by using pywinauto. The code has resorted to use of absolute coordinates from How to click a 'next' button of a window using python.

Once the program runs, the target window will get focus. The cursor starts to be somewhere close to the center of the target window. Then it moves to the button, presses the button since the color changes to the down-color. Then it releases the button, and the cursor moves back to the center of window. Only one thing missing, no action is taken from the target window application.

There is one fix: If I move the mouse to the title of the window and click at the right time, the automatic click on the button will trigger a real action. This makes me puzzled as to why this is happening, and unable to think about a solution for it.

app1 = Application()
app1.connect(title_re='^Quartus Prime Programmer.*$')
app1.QWidget.print_control_identifiers()

win1 = app1.QWidget
rect1 = win1.rectangle()
coor1 = (rect1.left+64,rect1.top+350) # 64, 350: "add file"
win11 = win1.TopLevelParent()
for i in range(3):
    win11.SetFocus()
    win11.PressMouseInput(coords=coor1)
    time.sleep(1.3)
    win11.ReleaseMouseInput()
    time.sleep(3.0)

The code repeats it three time so a human intervention can be easily inserted into the process.

解决方案

Qt apps can be automated using Application(backend='uia'). Please read the Getting Started Guide written specially for pywinauto 0.6.0+ with the new backend. It explains the core concept and many useful tricks.

P.S. I've downloaded this Lite edition app and will try to make an example for you later.

这篇关于pywinauto qwidget 点击触发无动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆