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?
Asked
Active
Viewed 321 times
0
-
https://stackoverflow.com/questions/2764356/python-get-windows-os-version-and-architecture – Ευάγγελος Γρηγορόπουλος Dec 30 '20 at 22:04
-
@ΕυάγγελοςΓρηγορόπουλος, how does that help OP with their question about the current [Windows desktop](https://support.microsoft.com/en-us/windows/multiple-desktops-in-windows-10-36f52e38-5b4a-557b-2ff9-e1a60c976434)? – ChrisGPT was on strike Dec 30 '20 at 22:36
-
I'm not on Windows, but see this answer [here](https://stackoverflow.com/a/60938828/9059420) and the linked `VirtualDesktopAccessor.dll`. Then it's probably `GetCurrentDesktopNumber()` what you need to call from that library. – Darkonaut Dec 31 '20 at 03:15
1 Answers
1
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)

DapperDuck
- 2,728
- 1
- 9
- 21