mrob95 / pyvda

Python module for manipulating Windows 10/11 windows and virtual desktops.
MIT License
90 stars 13 forks source link

Expanding on Features available #5

Closed gitagogaming closed 2 years ago

gitagogaming commented 2 years ago

This is not technically an issue, but an idea/request.

Would like to be able to do the following: Get Virtual Desktop Name Change Virtual Desktop Name Change Virtual Desktop Background Create New Virtual Desktop Delete Virtual Desktop

I've seen this option in C# but would love to be able to use it within your module

macsunmood commented 2 years ago

Great, I fully support this.

mrob95 commented 2 years ago

It looks like these should be possible by exposing a few more objects/APIs. I'll try and take a look this weekend

mrob95 commented 2 years ago

https://github.com/mrob95/pyvda/pull/7 adds support for:

https://github.com/mrob95/pyvda/pull/9 adds support for:

These are included in version 0.2.3 and all work on Windows 10. I'm not able to test on 11 atm though, so if somebody could confirm that these are all working on Windows 11 (or fix them if not) that would be awesome.

It looks like 'Change Virtual Desktop Background' is only available on Windows 11. I've added the interface definitions for these functions to https://github.com/mrob95/pyvda/blob/master/pyvda/com_defns.py#L216-L220 but have not linked these up to the VirtualDesktop class. Again, if someone is on Windows 11 and can make a PR for a set_wallpaper method that would be great. It should raise an error if BUILD_OVER_21313 is not True.

gitagogaming commented 2 years ago

7 adds support for:

  • Create Virtual Desktop

9 adds support for:

  • Get Virtual Desktop Name
  • Change Virtual Desktop Name
  • Delete Virtual Desktop

great to see these implemented!
I've got another idea, and forgive me if its possible as I am a bit of a novice and nearly requested other things that are clearly in place:) 1) The ability to name a virtual desktop upon creation. - Ive done this in my script, but i think for future folks it would be useful. 2) Option to get the 'Default' VD Name, when getting a default name it returns empty. - I know i can certainly do this myself, but my concern is when folks with other languages use it, i dont want it to be in english for them with "Desktop 3" for example


def get_vd_name(number):
    name = VirtualDesktop(number).name
    if not name:
         name = f"Desktop {number}"
    return name
print(get_vd_name(2))
mrob95 commented 2 years ago
  1. The ability to name a virtual desktop upon creation. - Ive done this in my script, but i think for future folks it would be useful.

Given that this is just one extra line of code for people to write I'm inclined to leave it as it is. At the moment the module exposes the Windows APIs pretty directly, I'd like to keep it that way and let people build abstractions on top of it in other libraries rather than trying to guess what people need.

new = VirtualDesktop.create()
new.rename("New name")
  1. Option to get the 'Default' VD Name, when getting a default name it returns empty. - I know i can certainly do this myself, but my concern is when folks with other languages use it, i dont want it to be in english for them with "Desktop 3" for example

Yeah it's strange that it returns an empty string rather than the default name. Again I'm not sure there's much we can do about this - to fix it for all languages we would need an enormous list of translations since as far as I know Windows won't give us those default values itself.

mrob95 commented 2 years ago

Created https://github.com/mrob95/pyvda/issues/13 to track implementation of virtual desktop backgrounds on windows 11. Going to close this. Feel free to create another issue you come across any problems :)