virtualdesktopsdeprecated

Node.js wrapper of (unofficial) C++ Virtual Desktop API for Windows 10.

Usage no npm install needed!

<script type="module">
  import virtualdesktops from 'https://cdn.skypack.dev/virtualdesktops';
</script>

README

!! DEPRACTED !!

Virtualdesktops

Node.js wrapper of (unofficial) C++ Virtual Desktop API for Windows 10. Gain control over your virtual desktops in Windows 10, without keyboard shortcuts.

Credits where credits due

Huge respect to the users Grabacr07, sstregg, NickoTin, and others for providing code samples, write-ups, hard work, and for making it bearable to work with the (undocumented) API for Virtual Desktops in Windows 10. Sources:

Installation

You'll need some dependencies before you are able to install and build this package, see also node-gyp installation.

  • node-gyp
  • Visual Studio 2013 (C++ redistributables)
  • Python (v2.7)
$ npm install virtualdesktops
const virtualdesktops = require('virtualdesktops');

Methods

Overview

Method Description Return value
moveLeft() Move the screen one desktop to the left true or false
moveRight() Move the screen one desktop to the right true or false
moveTo(index) Move the screen to a specific desktop true or false
getCurrentDesktopID() Get the ID of the current desktop (int) ID of desktop, 0 based
getTotalDesktops() Get the total number of virtual desktops (int) Total number of desktops
create() Create a new virtual desktop (int) ID of newly created desktop
remove(index) Remove a specific virtual desktop. true or false

moveLeft

Move the screen one desktop to the left. Nothing will happen if the current desktop is the first one.

virtualdesktops.moveLeft();

moveRight

Move the screen one desktop to the right. Nothing will happen if the current desktop is the last one, no new desktop will be created for you. It is possible to implement automatic creation, this feature is easy to implement by combing the methods: getTotalDesktops, getCurrentDesktopID, create, and moveRight.

virtualdesktops.moveRight();

moveTo(index)

Move the screen to a desktop with a certain index. Invalid values or non-existent indexes will be ignored and nothing will happen. No new desktop(s) will be created to fill a possible "gap". It is possible to implement automatic creations to fill a "gap" by combing the methods: getTotalDesktops, and create.

/**
 * @param int index (0-based)
 */
virtualdesktops.moveTo(index);

getCurrentDesktopID

Get the ID of the current desktop.

/**
 * @return int current desktop ID (0-based)
 */
virtualdesktops.getCurrentDesktopID();

getTotalDesktops

Get the total number of virtual desktops.

/**
 * @return int total desktops
 */
virtualdesktops.getTotalDesktops();

create

Create a new virtual desktop at the end of the existing list. The position of the current desktop will not automatically change to the newly created one. You can use moveTo in combination with the returned ID to provide this functionality.

/**
 * @return int new desktop ID
 */
var newDesktopID = virtualdesktops.create();

remove(index)

Remove a specific virtual desktop. The current running programs in this desktop n will be moved to the desktop n-1, as standard behavior, and will not be killed. If the removed desktop n is also the current desktop the screen will automatically switch to desktop n-1. The last existent desktop can not be deleted.

/**
 * @param int index to remove
 */
virtualdesktops.remove(index);

Building from source

Before you can build the source or make changes to it you will need the same dependencies as mentioned in Installation.

$ npm install
$ node-gyp configure
$ node-gyp build
$ npm test

License

MIT