Skip to main content

Python implementation of the VirtualDesktopAccessor for manipulating Windows 10 virtual desktops.

Project description

py-VirtualDesktopAccessor

Implements a subset of the functionality offered by https://github.com/Ciantic/VirtualDesktopAccessor, written in pure Python and installable via pip.

pip install pyvda

Usage

The following functions are implemented. The only deliberate difference with the behaviour of Ciantic's original DLL is that desktops here are 1-indexed, as this reflects the numbers shown in the task view.

def GetCurrentDesktopNumber() -> int:
def GetDesktopCount() -> int:
def MoveWindowToDesktopNumber(hwnd: int, number: int) -> None:
def GoToDesktopNumber(number: int) -> None:
def GetWindowDesktopNumber(hwnd: int) -> int:

def PinWindow(hwnd: int) -> None:
def UnPinWindow(hwnd: int) -> None:
def IsPinnedWindow(hwnd: int) -> bool:
def PinApp(hwnd: int) -> None:
def UnPinApp(hwnd: int) -> None:
def IsPinnedApp(hwnd: int) -> bool:

def ViewIhsShownInSwitchers(hwnd: int) -> bool:
def ViewIsVisible(hwnd: int) -> bool:
def ViewGetLastActivationTimestamp(hwnd: int) -> int:
def ViewSetFocus(hwnd: int) -> int:
def ViewSwitchTo(hwnd: int) -> int:
def ViewGetByZOrder(switcher_windows: bool = True, current_desktop: bool = True) -> List[int]:

Example usage:

import pyvda
import win32gui

number_of_active_desktops = pyvda.GetDesktopCount()
current_desktop = pyvda.GetCurrentDesktopNumber()

current_window_handle = win32gui.GetForegroundWindow()
pyvda.MoveWindowToDesktopNumber(current_window_handle, 1)

pyvda.GoToDesktopNumber(3)

window_moved_to = pyvda.GetWindowDesktopNumber(current_window_handle)

Tips

Sometimes, after calling GoToDesktopNumber the focus will remain on the window in the previous desktop. This is at least partially fixed by calling:

from ctypes import windll
ASFW_ANY = -1
windll.user32.AllowSetForegroundWindow(ASFW_ANY)

before any call to GoToDesktopNumber. More details here and here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvda-0.0.8.tar.gz (7.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyvda-0.0.8-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

pyvda-0.0.8-py2-none-any.whl (8.8 kB view details)

Uploaded Python 2

File details

Details for the file pyvda-0.0.8.tar.gz.

File metadata

  • Download URL: pyvda-0.0.8.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for pyvda-0.0.8.tar.gz
Algorithm Hash digest
SHA256 d8d95002a2f4c1043d242d41ed1906444d0bfae7365030486da87199f4f551f6
MD5 c90479f461a48bf5a695bb4cef8ef5a7
BLAKE2b-256 3fad82fc362ccd42a732bfe2b7df978642c47b259072eb6d63b8e92aae45754a

See more details on using hashes here.

File details

Details for the file pyvda-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: pyvda-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for pyvda-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7ae3fc4b384167fe748409195f2ea005087615138bc74ff5643cd863f375304e
MD5 dcd6767319ea11a213667329a9363f34
BLAKE2b-256 dac4904287cdcddbd2f5338ccf639c094dd363e716067ac0fe2e51cbd74df72d

See more details on using hashes here.

File details

Details for the file pyvda-0.0.8-py2-none-any.whl.

File metadata

  • Download URL: pyvda-0.0.8-py2-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for pyvda-0.0.8-py2-none-any.whl
Algorithm Hash digest
SHA256 bbf7839a709d9b8a15dd9a75b95f76e5e1320e530c40795448c008e92df83e96
MD5 603d280637814d16b1d601c6e22a2a71
BLAKE2b-256 7bb2f0238d3254c9b453184b6bb693d56b10febf35476ace081a562d2e682a58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page