1

The "desktop" I am talking about is the one you create (on windows) when clicking Ctrl + Windows + D (the "desktop number" is the number you see above the desktop when you click Task View)

I'm making a small Java program and I need to be able to get the current desktop number (specifically, I need to know whether the user is on the 1st desktop or not)

It's a small program, so simple answers would be appreciated. Thanks!

John Doe
  • 21
  • 1
  • 3
  • There is a similar question http://stackoverflow.com/questions/8717999/how-to-get-list-of-all-window-handles-in-java-using-jna. I think you can refer to it. – Yibo Mar 07 '19 at 02:08

1 Answers1

1

There is no pure Java method to do this, and it's impossible to write one, so you'll need to use JNI for this. If you have a window on the current virtual desktop, then you can use the documented public API: GetWindowDesktopId. If you don't, you'll have to use GetCurrentDesktop inside of IVirtualDesktopManagerInternal, as explained by Altering Win10 virtual desktop behavior.