The shortcut of win + shift + left
does not work well in pyautogui
, but it works well in pynput
.
Moving the Active Window to a Different Monitor: You’re right; PyAutoGUI doesn’t directly support moving windows across monitors with the elegance of a swan gliding across a lake. But fear not! We have a workaround. Instead of PyAutoGUI, let’s enlist the help of another Python library called pynput. Here’s how you can move that window like a digital nomad:
from pynput.keyboard import Key, Controller
keyboard = Controller()
# Press the Windows key (also known as the meta key)
keyboard.press(Key.cmd)
keyboard.press(Key.shift)
keyboard.press(Key.left)
keyboard.release(Key.cmd)
keyboard.release(Key.shift)
keyboard.release(Key.left)
AI-generated code. Review and use carefully. More info on FAQ.
This delightful snippet will gracefully slide your active window to the left monitor.
标签:Python,three,shortcut,release,Key,keyboard,press,pynput,left From: https://www.cnblogs.com/alex-bn-lee/p/18315809