Switch between virtual desktops using Python?

1k Views Asked by At

How can I automate switching between virtual desktops using Python on Windows 10?

1

There are 1 best solutions below

0
On

pyautogui can send keyboard presses to the current window, but system-wide commands will, obviously, work on any window. The shortcuts to switch virtual desktops are win+ctrl+right & win+ctrl+left. The Python code to use these with pyautogui is

import pyautogui as pa
pa.hotkey('win','ctrl','left') #will switch one desktop to the left
pa.hotkey('win','ctrl','right') #will switch one desktop to the right