使用 pyautogui 将鼠标光标移动到第二台显示器 [英] Move mouse cursor to second monitor using pyautogui

查看:200
本文介绍了使用 pyautogui 将鼠标光标移动到第二台显示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我大约一个小时前开始使用 pyautogui.非常好,python 支持 GUI 自动化.我有一个问题.我使用了两个屏幕,看起来包装器无法将我的光标移动到我的辅助显示器上.例如:

<预><代码>>>>导入pyautogui>>>pyautogui.moveTo(2759,769)>>>pyautogui.position()(1919, 769)

如您所见,光标仍在我的第一个屏幕内.

如何强制 pyautogui 移动到我的第二个屏幕?

谢谢

解决方案

没关系,我已经从 github 帖子.

似乎可以使用

来完成将光标移动到第二台显示器

ctypes.windll.user32.SetCursorPos(2759,769)

甜!

I started using pyautogui about an hour ago. Very nice that python supports GUI automation. I'm having one problem though. I use two screens and it appears that the wrapper is unable to move my cursor to my secondary monitor. For instance:

>>> import pyautogui
>>> pyautogui.moveTo(2759,769)
>>> pyautogui.position()
 (1919, 769)

As you can see the cursor is still within my first screen.

How do I force pyautogui to move to my second screen?

Thanks

解决方案

Nevermind, I have found the answer from a github post.

It appears that moving the cursor to a second monitor can be accomplished using

ctypes.windll.user32.SetCursorPos(2759,769)

Sweet!

这篇关于使用 pyautogui 将鼠标光标移动到第二台显示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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