Tuor
Tuor

Reputation: 1175

Switch between virtual desktops using Python?

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

Upvotes: 0

Views: 1247

Answers (1)

Tuor
Tuor

Reputation: 1175

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

Upvotes: 3

Related Questions