Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

python - 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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...