简体   繁体   中英

Move mouse cursor to second monitor using pyautogui

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM