multiple monitors and random wallpapers
Posted: Tue Oct 28, 2003 1:50 am
Code updated For 5.20+
want to change your wallpapers? here's something small
i'll polish it a little the coming days, it shows some unexpected behaviour in combination with ultramon profiles i've been told, looks like ultramon replaces whatever background with its own... hmm...
want to change your wallpapers? here's something small
i'll polish it a little the coming days, it shows some unexpected behaviour in combination with ultramon profiles i've been told, looks like ultramon replaces whatever background with its own... hmm...
Code: Select all
; twowalls v1 28.10.2003
;
; manage (well, sort of) wallpapers for dual monitor setups
;
; what does it do?
;
; - read all images in current subdir
; - read a 'preselection' list
; - generate combo bitmap
; - tile and refresh
;
; how to install
;
; - put all images )bmp and / or jpg) in a folder
; - add twowall.exe to the mix
; - edit the _combolist.txt if you want (format: <filename1> , <filename2> <cr>)
; - doubleclick twowall.exe and voila, different backgrounds
; - add twowall.exe to startup to change the paper on every reboot
; - add a parameter if you don't want the refresh now (twowall.exe /no)
;
; notes on filenames:
;
; - images that start with the same two letters are often combined
; - images that start with du_ are treated differently (dual screen images)
;
; path.s="c:\software\backgnds\"
path.s=""
;
UseJPEGImageDecoder()
;
NewList namelist.s()
;
; retrieve screen size
;
screen_w = GetSystemMetrics_(#SM_CXSCREEN)
screen_h = GetSystemMetrics_(#SM_CYSCREEN)
;
; set desktop wallpaper tiling on using the registry
;
topkey = #HKEY_CURRENT_USER
subkey.s = "Control Panel\Desktop"
handle = 0
RegOpenKeyEx_(topkey,subkey,0,#KEY_ALL_ACCESS,@handle)
value.s = "TileWallPaper"
buffer.s = "1"
buffer_l = Len(buffer)
RegSetValueEx_(handle,@value,0,#REG_SZ,buffer,buffer_l)
RegCloseKey_(handle)
;
variation = Random(5) ; decide how to combine two images
;
If variation = 0 ; use something from the preselect list
If FileSize(path+"_combolist.txt")>0
OpenFile(1,path+"_combolist.txt")
Repeat
name.s = LCase(Trim(ReadString(1)))
If FindString(name,",",1)>0
AddElement(namelist())
namelist() = name
EndIf
Until Eof(1)
CloseFile(1)
pick = Random(CountList(namelist())-1)
SelectElement(namelist(),pick)
file1.s = Trim(Left(namelist(),FindString(namelist(),",",1)-1))
file2.s = Trim(Mid(namelist(),FindString(namelist(),",",1)+1,255))
EndIf
Else
; ; okay, so not from the preselect list
;
If ExamineDirectory(1,path,"*.*")
Repeat
type = NextDirectoryEntry(1)
If type = 1
name.s = LCase(DirectoryEntryName(1))
If Left(name,1) <> "_"
If Right(name,4) = ".bmp" Or Right(name,4) = ".jpg"
AddElement(namelist())
namelist() = name
EndIf
EndIf
EndIf
Until type = 0
EndIf
namelist_n = CountList(namelist())
;
pick1 = Random(namelist_n-1)
SelectElement(namelist(),pick1)
file1.s = namelist()
Repeat ; no dual screen images for monitor 2
pick2 = Random(namelist_n-1)
SelectElement(namelist(),pick2)
file2.s = namelist()
Until Left(file2,2)<>"du"
;
Select variation
Case 1 ; both screens random
Case 2 ; 1 = random , 2 = old screen 1
file2 = "_single.bmp"
Case 3 ; both screens identical
file2 = file1
Default ; (4 and 5) pick 2 starting with the same 2 chars
n = 0
Repeat
pick2 = Random(namelist_n-1)
SelectElement(namelist(),pick2)
file2.s = namelist()
Until Left(file2,2) = Left(file1,2) Or n = 25
EndSelect
EndIf
;
; almost done, now cover dual screen images
;
If Left(file1,2)="DU"
If LoadImage(1,path+file1)<>0
ResizeImage(1,screen_w*2,screen_h)
SaveImage(1,path+"_combo.bmp")
FreeImage(1)
EndIf
Else
If LoadImage(1,path+file1)<>0
If LoadImage(2,path+file2)<>0
ResizeImage(1,screen_w,screen_h)
ResizeImage(2,screen_w,screen_h)
CreateImage(3,screen_w*2,screen_h)
StartDrawing(ImageOutput(3))
DrawImage(ImageID(1),0,0)
DrawImage(ImageID(2),screen_w,0)
StopDrawing()
SaveImage(1,path+"_single.bmp")
SaveImage(3,path+"_combo.bmp")
FreeImage(1)
FreeImage(2)
FreeImage(3)
EndIf
EndIf
EndIf
;
; change the wallpaper and tell windows to refresh the desktop
;
file.s = path+"_combo.bmp"
;
If ProgramParameter()=""
SystemParametersInfo_(#SPI_SETDESKWALLPAPER,0,@file,#SPIF_SENDWININICHANGE)
EndIf