在不移动光标的情况下单击鼠标[Python] [英] Mouse Click without moving Cursor [Python]

查看:1018
本文介绍了在不移动光标的情况下单击鼠标[Python]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到这个问题的具体答案.如何在不移动光标的情况下单击屏幕上的坐标?我正在开发一个可以自动安装程序的项目,但仍希望在处理安装过程中控制鼠标来执行其他任务.有任何想法吗?一些例子也很棒.谢谢

I can't seem to find a specific answer to this question. How do I click coordinates on the screen without moving the cursor? I am working on a project that will automate installations of programs, but would still like control of the mouse to do other tasks while installations are being processed. Any ideas? Some examples would be awesome as well. Thanks

推荐答案

感谢那些试图帮助我的人.经过进一步研究,我找到了解决方案.我找到了一种使用 PyAutoIt 将AutoIt导入Python的方法.我一直在寻找ControlClick函数,它无需移动鼠标光标即可单击控件.这是一个示例:

Thank you to those who have tried to help me out. After further research I have found a solution. I have found a way to import AutoIt into Python by using PyAutoIt. There is a ControlClick function that I have been looking for that clicks a control without moving the mouse cursor. Here is an example:

import autoit
import time

autoit.run("notepad.exe")
autoit.win_wait_active("[CLASS:Notepad]", 3)
autoit.control_send("[CLASS:Notepad]", "Edit1", "hello world{!}")
time.sleep(5)
autoit.win_close("[CLASS:Notepad]")
autoit.control_click("[Class:#32770]", "Button2")

再次感谢.可以将该线程标记为已回答并关闭:)

Thanks again. This thread can be marked answered and closed :)

这篇关于在不移动光标的情况下单击鼠标[Python]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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