0

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

Tuor
  • 875
  • 1
  • 8
  • 32

1 Answers1

2

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
Tuor
  • 875
  • 1
  • 8
  • 32