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

Commit

Permalink
Added support for fixed colors for wallpapers.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdias committed Aug 24, 2016
1 parent b26499b commit fef922b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ To change between both, go into the "icons" folder and extract either the "white

### 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.
To configure the wallpapers, edit the "settings.ini" file.
For each desktop, you can either set the wallpaper to be an image file or a fixed color.
To use images, set the path of the image, either absolute or relative (ex: "1=C:\wallpapers\1.jpg", "2=./wallpapers/2.jpg").
To use fixed colors, set the color in hexadecimal (ex: "3=ff0000" for red, "4=ff00" or "4=00ff00" for green).
If you set the config of that desktop to empty (ex: "5=") the wallpaper won't change when you switch to that desktop.

## Credits

Expand Down
38 changes: 26 additions & 12 deletions virtual-desktop-enhancer.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,36 @@ GetNumberOfDesktops() {
}

ChangeDesktop(n) {
if (n == 0) {
n := 10
}
DllCall(GoToDesktopNumberProc, Int, n-1)
if (n == 0) {
n := 10
}
DllCall(GoToDesktopNumberProc, Int, n-1)
}

ChangeBackground(n) {
filePath := Wallpapers%n%
isRelative := (substr(filePath, 1, 1) == ".")
if (isRelative) {
filePath := (A_WorkingDir . substr(filePath, 2))
line := Wallpapers%n%

isHex := RegExMatch(line, "^([0-9A-Fa-f]{1,6})", hexMatchTotal)

if (isHex) {
hexColorReversed := SubStr("00000" . hexMatchTotal1, -5)

RegExMatch(hexColorReversed, "^([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})", match)
hexColor := "0x" . match3 . match2 . match1, hexColor += 0

DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, "", UInt, 1)
DllCall("SetSysColors", "Int", 1, "Int*", 1, "UInt*", hexColor)
}
if (filePath and FileExist(filePath)) {
DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, filePath, UInt, 1)
else {
filePath := line

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)
}
}
}

Expand All @@ -115,5 +131,3 @@ Focus() {
WinActivate, ahk_class Shell_TrayWnd
SendEvent !{Esc}
}


0 comments on commit fef922b

Please sign in to comment.