Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Commit

Permalink
Committed the initial version of the app.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdias committed Aug 22, 2016
1 parent 481a3e8 commit 38647f2
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Windows 10 Virtual Desktop Assistant
===

This application will enhance the Windows 10 multiple desktops feature.
By default you can switch to the next/previous desktops by pressing [Windows + Ctrl + (Left or Right Arrow)].
This will allow you to switch to each specific desktop on demand with new keyboard shortcuts.
It will also allow you have a custom wallpaper per desktop.

## Installation

For "Virtual Desktop Assistant" to work, you first need to install "Visual C++ Redistributable for Visual Studio 2015".
It should be available [here](https://www.microsoft.com/en-us/download/details.aspx?id=48145).

To run this app, just run the "virtual-desktop-assistant.exe" program or install AutoHotkey and run the "virtual-desktop-assistant.ahk" script file.

## Usage

### Keyboard Shortcuts

While running, the following keyboard shortcuts are available:
- [Left Alt + (key under Esc)]

Goes to the desktop management screen.
This is additionally available (by default) by pressing [Windows + Tab].
You can move windows between desktops by dragging them while inside this screen.

- [Left Alt + (1-9)]

Switch to the desktop for the respective key (ex: [LAlt + 3] goes to Desktop 3).

Note that to add a new desktop you can press the "+ New Desktop" button on the desktop management screen.
A maximum of 9 desktops are supported.

### Tray Icon

A new tray icon will be available. It indicates the number of the current desktop (1-9).
If you click on it the desktop management screen will be displayed.

The icons will have white text over black background. An inverted color scheme is provided but will require minor tweaks to the script.

### Custom Wallpapers Per Desktop

To configure the wallpapers, edit the "settings.ini" file and set the paths of the wallpaper image files for the desktops you want.

A few are included by default. The paths can be relative (ex: "./wallpapers/1.jpg") or absolute (ex: "C:\wallpapers\1.jpg").

If you set the path to empty (ex: "1=" instead of "1=./wallpapers/1.jpg") the wallpaper won't change when you switch to that desktop.

## Credits

Credits to Ciantic (Jari Pennanen) for his library, which can be found [here](https://github.com/Ciantic/VirtualDesktopAccessor).
Credits to the creator of the ReadINI AHK library, found [here](https://autohotkey.com/board/topic/33506-read-ini-file-in-one-go/).
Binary file added icons/Black 1.ico
Binary file not shown.
Binary file added icons/Black 2.ico
Binary file not shown.
Binary file added icons/Black 3.ico
Binary file not shown.
Binary file added icons/Black 4.ico
Binary file not shown.
Binary file added icons/Black 5.ico
Binary file not shown.
Binary file added icons/Black 6.ico
Binary file not shown.
Binary file added icons/Black 7.ico
Binary file not shown.
Binary file added icons/Black 8.ico
Binary file not shown.
Binary file added icons/Black 9.ico
Binary file not shown.
Binary file added icons/Black New.zip
Binary file not shown.
Binary file added icons/White New.zip
Binary file not shown.
30 changes: 30 additions & 0 deletions read-ini.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

; https://autohotkey.com/board/topic/33506-read-ini-file-in-one-go/

ReadIni( filename = 0 )
; Read a whole .ini file and creates variables like this:
; %Section%%Key% = %value%
{
Local s, c, p, key, k

if not filename
filename := SubStr( A_ScriptName, 1, -3 ) . "ini"

FileRead, s, %filename%

Loop, Parse, s, `n`r, %A_Space%%A_Tab%
{
c := SubStr(A_LoopField, 1, 1)
if (c="[")
key := SubStr(A_LoopField, 2, -1)
else if (c=";")
continue
else {
p := InStr(A_LoopField, "=")
if p {
k := SubStr(A_LoopField, 1, p-1)
%key%%k% := SubStr(A_LoopField, p+1)
}
}
}
}
10 changes: 10 additions & 0 deletions settings.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Wallpapers]
1=.\wallpapers\1.jpg
2=.\wallpapers\2.jpg
3=.\wallpapers\3.jpg
4=
5=
6=
7=
8=
9=
Binary file added virtual-desktop-accessor.dll
Binary file not shown.
115 changes: 115 additions & 0 deletions virtual-desktop-assistant.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#SingleInstance, force
#WinActivateForce
; Credits to: https://github.com/Ciantic/VirtualDesktopAccessor

#Include, read-ini.ahk

; ======================================================================
; Setup
; ======================================================================

DetectHiddenWindows, On
hwnd := WinExist("ahk_pid " . DllCall("GetCurrentProcessId","Uint"))
hwnd += 0x1000 << 32

hVirtualDesktopAccessor := DllCall("LoadLibrary", "Str", ".\virtual-desktop-accessor.dll", "Ptr")

global GoToDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "GoToDesktopNumber", "Ptr")
global RegisterPostMessageHookProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "RegisterPostMessageHook", "Ptr")
global UnregisterPostMessageHookProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "UnregisterPostMessageHook", "Ptr")
global GetCurrentDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "GetCurrentDesktopNumber", "Ptr")
global GetDesktopCountProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "GetDesktopCount", "Ptr")

DllCall(RegisterPostMessageHookProc, Int, hwnd, Int, 0x1400 + 30)
OnMessage(0x1400 + 30, "VWMess")
VWMess(wParam, lParam, msg, hwnd) {
ChangeAppearance(lParam + 1)
ChangeBackground(lParam + 1)
Focus()
}

; ======================================================================
; Auto Execute
; ======================================================================

Menu, Tray, Add, &Manage Desktops, OpenDesktopManager
Menu, Tray, Default, &Manage Desktops
Menu, Tray, Click, 1

ReadIni("settings.ini")
ChangeAppearance(1)
ChangeDesktop(1)

; ======================================================================
; Keybindings
; ======================================================================

*<!1::
*<!2::
*<!3::
*<!4::
*<!5::
*<!6::
*<!7::
*<!8::
*<!9::
ChangeDesktop(substr(A_ThisHotkey, 0, 1))
Return

!SC029::
OpenDesktopManager()
Return

; ======================================================================
; Functions
; ======================================================================

GoToNextDesktop() {
i := (GetCurrentDesktopNumber() + 1)
if (i < GetNumberOfDesktops()) {
i := i + 1
}
else {
i := 1
}
ChangeDesktop(i)
}

OpenDesktopManager() {
Send #{Tab}
}

GetCurrentDesktopNumber() {
Return DllCall(GetCurrentDesktopNumberProc)
}

GetNumberOfDesktops() {
Return DllCall(GetDesktopCountProc)
}

ChangeDesktop(n) {
DllCall(GoToDesktopNumberProc, Int, n-1)
}

ChangeBackground(n) {
filePath := Wallpapers%n%
isRelative := (substr(filePath, 1, 1) == ".")
if (isRelative) {
filePath := (A_WorkingDir . substr(filePath, 2))
}
if (filePath and FileExist(filePath)) {
DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, filePath, UInt, 1)
}
}

ChangeAppearance(n) {
Menu, Tray, Tip, Desktop %n%
Menu, Tray, Icon, icons/Black %n%.ico
}

Focus() {
WinActivate, ahk_class Shell_TrayWnd
SendEvent !{Esc}
}


Binary file added virtual-desktop-assistant.exe
Binary file not shown.
Binary file added wallpapers/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wallpapers/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wallpapers/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 38647f2

Please sign in to comment.