简体   繁体   中英

How to detect which windows desktop I'm on in python3?

In Windows 10 you can create multiple desktops and switch between them. I want to run a python3 code when I am on a certain desktop. How do I detect which desktop I'm on?

Download the VirtualDesktopAccessor.dll from here and put it in your working directory.

Run the following code:

import ctypes

vda = ctypes.WinDLL("VirtualDesktopAccessor.dll")
num = vda.GetCurrentDesktopNumber()
print(num)

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