It's been a while since the script was released, however after using a few other software packages, and seeing a slight annoyance in modifying little changes in the changer, i modified the code to more reflect them. I personally feel this is the way it should have been when originally released.
Change 1) Closing the window does not quit the application. (It sends it to tray, per se) To quit, go to the tray Icon and click 'exit'
Change 2) Previous settings in the fields will autofilll, you can now change the radio button choices, or timer. Changing the directory will causes it to rescan.
Change 3) If you have settings already set once before, they will be used by default on startup. You will have to open up the GUI if you want to change it. This way you can use a shortcut and refer to it when windows boots up.
#SingleInstance Force
#Persistent
#NoEnv
SetBatchLines, -1
OnExit, Exit_Label
Gosub, TrayMenu
Img_Order = Fixed
Wallpaper_Changer_Dir = C:\Documents and Settings\%A_UserName%\Wallpaper Changer
IfNotExist, %Wallpaper_Changer_Dir%
FileCreateDir, %Wallpaper_Changer_Dir%
RegRead, Original_Wallpaper, HKEY_CURRENT_USER, Control Panel\Desktop, Wallpaper
RegRead, Original_TileWallpaper, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper
RegRead, Original_WallpaperStyle, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle
;Loads previous settings.
ifexist, %Wallpaper_Changer_Dir%\Wallpaper.ini
{
IniRead, Folder, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Path
IniRead, Interval, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Interval
IniRead, Position, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Position
IniRead, Img_Order, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Order
} else {
Interval := 30 ;default starting valur
}
Wallpaper_Changer:
FileDelete, C:\Documents and Settings\%A_UserName%\Local Settings\Temp\Wallpaper.tmp
;Defaults as none 'checked' R is short for Radio, 1-5
R1 =
R2 =
R3 =
R4 =
R5 =
;Match the position against the radio. If it's blank, first is defaulted.
if (position == "Center" || position == "")
R1 = Checked
else if (position == "Stretch")
R2 = Checked
else if (position == "Tile")
R3 = Checked
;Match the image order against the radio. If it's blank, first is defaulted.
if (Img_Order == "Random" || Img_Order == "")
R4 = Checked
else if (Img_Order == "Fixed")
R5 = Checked
if (Interval > 60) ;if it's been converted for Minutes already, convert back.
Interval /= 60000
SetTimer, Subroutine
Gui, Destroy
Gui, Font, s11
Gui, Add, GroupBox, x5 y5 w280 h50, Folder With Images
Gui, Add, GroupBox, x5 y60 w348 h65, Image Interval
Gui, Add, GroupBox, x5 y130 w185 h48, Image Position
Gui, Add, GroupBox, x200 y130 w153 h48, Image Order
Gui, Add, Edit, x10 y25 w270 h20 ReadOnly, %folder%
Gui, Add, Button, x290 y12 w65 h25, Browse
Gui, Add, Slider, x10 y80 w337 h30 gSubroutine AltSubmit Range1-60 ToolTip NoTicks Page1 Line1, %Interval%
Gui, Add, Radio, x12 y150 w60 h20 vRadio1 %R1%, Center
Gui, Add, Radio, x78 y150 w60 h20 vRadio2 %R2%, Stretch
Gui, Add, Radio, x144 y150 w40 h20 vRadio3 %R3%, Tile
Gui, Add, Radio, x210 y150 w75 h20 vRadio4 Group %R4%, Random
Gui, Add, Radio, x293 y150 w50 h20 vRadio5 %R5%, Fixed
Gui, Font, s8
Gui, Add, Text, x20 y110, 1 Min
Gui, Add, Text, x160 y110, 30 Min
Gui, Add, Text, x305 y110, 60 Min
Gui, Font, s12 Bold
Gui, Add, Button, x5 y182 w350 h30, Apply
if (!Folder) ;No folder, then we disable apply (first time?)
GuiControl, Disable, Apply
if (!firstRun && Folder)
gosub Set_to_Previous_Settings
else
Gui, Show, h215 w360 Center, Wallpaper Changer
firstRun = 1
Return
Subroutine:
GuiControlGet, Interval, , msctls_trackbar321
IfWinActive, Wallpaper Changer
ToolTip, %Interval% Min, 303, 75
IfWinNotActive, Wallpaper Changer
ToolTip
Return
Scanning_Images:
ToolTip, Scanning Images`nPlease Wait........, , , 2
Return
OnMessage(0x53, "WM_HELP")
WM_HELP(wParam, lParam)
{
Run, iexplore.exe http://www.IrfanView.com, Max
If ErrorLevel = Error
MsgBox, 8208, ERROR, Unable to load http`://www.IrfanView.com
Return
}
ButtonBrowse:
Gui, +OwnDialogs
GuiControl, Disable, Apply
FileSelectFolder, Folder, *%A_MyDocuments%\My Pictures, 0, `r
If Folder =
{
MsgBox, 8208, ERROR, No folder has been selected
Return
}
SetTimer, Scanning_Images
GuiControl, , Edit1, %Folder%
FileDelete, %Wallpaper_Changer_Dir%\*.*
Total_Img_Cnt = 0
Loop, %Folder%\*.*
{
If A_LoopFileExt in bmp,dib,gif,png,jpg,jpeg,jpe,jfif,tif,tiff
Total_Img_Cnt := Total_Img_Cnt + 1
}
Total_Bmp_Cnt = 0
Loop, %Folder%\*.bmp
Total_Bmp_Cnt = %A_Index%
If Total_Img_Cnt = %Total_Bmp_Cnt%
{
Loop, %Folder%\*.bmp
FileCopy, %A_LoopFileFullPath%, %Wallpaper_Changer_Dir%\%A_Index%.bmp
}
Else
{
SetTimer, Scanning_Images, Off
ToolTip, , , , 2
RegRead, IrfanView, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView, UninstallString
SplitPath, IrfanView, , IrfanView
IrfanView = %IrfanView%\i_view32.exe
IfNotExist, %IrfanView%
{
MsgBox, 16452, IrfanView,
(LTrim
All the images in "%Folder%" are not bitmap (.bmp) images.
IrfanView is required if all the images are not bitmap (.bmp) images.`n
Select the 'Help' button to read about IrfanView.
If you select the 'Yes' button, you will download IrfanView (Version 4.0).
If you select not to download IrfanView, just select another folder that contains ALL (.bmp) images.`n`n
Would you like to download IrfanView now?
)
}
IfMsgBox, Yes
{
Run, iexplore.exe https://ahknet.autohotkey.com/~ackrite/iview400_setup.exe, , Hide
WinMinimizeAll
Loop, 300000
{
Sleep, 1000
RegRead, IrfanView, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView, UninstallString
SplitPath, IrfanView, , IrfanView
IrfanView = %IrfanView%\i_view32.exe
IfExist, %IrfanView%
Loop, 300000
{
Sleep, 1000
IfWinNotExist, IrfanView Setup
{
WinActivate, Wallpaper Changer
MsgBox, 64, IrfanView, Download Complete!
Gui, Show, h215 w360 Center, Wallpaper Changer
WinActivate, Wallpaper Changer
Goto, IrfanView
}
}
}
IfNotExist, %IrfanView%
ExitApp
}
IfMsgBox, No
{
GuiControl, , Edit1
Goto, ButtonBrowse
}
IrfanView:
GuiControl, , Edit1, %Folder%
SetTimer, Scanning_Images
Total_Img_Cnt = 0
Loop, %Folder%\*.*
{
If A_LoopFileExt in bmp,dib,gif,png,jpg,jpeg,jpe,jfif,tif,tiff
{
Total_Img_Cnt := Total_Img_Cnt + 1
RunWait, "%IrfanView%" "%A_LoopFileFullPath%" /convert="%Wallpaper_Changer_Dir%\%Total_Img_Cnt%.bmp"
}
}
}
SetTimer, Scanning_Images, Off
ToolTip, , , , 2
If Total_Img_Cnt <= 1
{
MsgBox, 8208, ERROR, There is only one or no image files in "%Folder%".`n`nCheck the folder and try again or select a differnt folder.
GuiControl, , Edit1
Return
}
GuiControl, Enable, Apply
Return
ButtonApply:
Gui, Submit, NoHide
Menu, Tray, Enable, Set to Original Wallpaper
Menu, Tray, Enable, Set to Current Wallpaper
FileDelete, C:\Documents and Settings\%A_UserName%\Local Settings\Temp\Wallpaper.tmp
If Radio1 = 1
{
Position = Center
TileWallpaper = 0
WallpaperStyle = 0
}
If Radio2 = 1
{
Position = Stretch
TileWallpaper = 0
WallpaperStyle = 2
}
If Radio3 = 1
{
Position = Tile
TileWallpaper = 1
WallpaperStyle = 0
}
Img_Order = Random
If Radio4 = 1
Img_Order = Random
If Radio5 = 1
{
Img_Order = Fixed
Img_Cnt = 1
}
IniWrite, %Folder%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Path
IniWrite, %Interval%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Interval
IniWrite, %Position%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Position
IniWrite, %Img_Order%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Order
SetTimer, Subroutine, Off
ToolTip
Gui, Submit
Previous_Settings:
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper, %TileWallpaper%
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle, %WallpaperStyle%
Menu, Tray, Disable, Hide
Menu, Tray, Enable, Show
Interval *= 60000
;Interval = 3000
SetTimer, %Img_Order%, %Interval%
GoSub, %Img_Order%
Return
Random:
Random, Img, 1, %Total_Img_Cnt%
Img = %Img%.bmp
GoSub, Show_Img
Return
Fixed:
Loop, %Wallpaper_Changer_Dir%\*.bmp
{
If (Img_Cnt = Total_Img_Cnt + 1)
Img_Cnt = 1
If A_Index = %Img_Cnt%
{
Img = %A_LoopFileName%
Img_Cnt := Img_Cnt + 1
Break
}
}
GoSub, Show_Img
Return
Show_Img:
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, Wallpaper, %Wallpaper_Changer_Dir%\%Img%
Run, %A_WinDir%\System32\RUNDLL32.EXE user32.dll`,UpdatePerUserSystemParameters
Return
TrayMenu:
Menu, Tray, MainWindow
Menu, Tray, NoStandard
Menu, Tray, Add, Wallpaper Changer, Wallpaper_Changer
Menu, Tray, Add
Menu, Tray, Add, View Previous Settings, View_Previous_Settings
Menu, Tray, Add, Set to Previous Settings, Set_to_Previous_Settings
Menu, Tray, Add, Set to Original Wallpaper, Set_to_Original_Wallpaper
Menu, Tray, Add, Set to Current Wallpaper, Set_to_Current_Wallpaper
Menu, Tray, Add, Hide, Hide
Menu, Tray, Add, Show, Show
Menu, Tray, Add, Exit, Exit_Label
Menu, Tray, Disable, Set to Original Wallpaper
Menu, Tray, Disable, Set to Current Wallpaper
Menu, Tray, Default, Wallpaper Changer
Menu, Tray, Disable, Show
Return
Hide:
WinHide, Wallpaper Changer
Menu, Tray, ToggleEnable, Hide
Menu, Tray, ToggleEnable, Show
Return
Show:
Gui, Show, h215 w360 Center, Wallpaper Changer
WinActivate, Wallpaper Changer
Menu, Tray, ToggleEnable, Show
Menu, Tray, ToggleEnable, Hide
Return
View_Previous_Settings:
IniRead, Folder, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Path
IniRead, Interval, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Interval
IniRead, Position, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Position
IniRead, Order, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Order
MsgBox, 64, Wallpaper Changer Settings, Path = %Folder%`nInterval = %Interval%`nPosition = %Position%`nOrder = %Order%
Return
Set_to_Previous_Settings:
IniRead, Folder, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Path
IniRead, Interval, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Interval
IniRead, Position, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Position
IniRead, Img_Order, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Order
If Img_Order = Fixed
Img_Cnt = 1
If Position = Center
{
TileWallpaper = 0
WallpaperStyle = 0
}
If Position = Stretch
{
TileWallpaper = 0
WallpaperStyle = 2
}
If Position = Tile
{
TileWallpaper = 1
WallpaperStyle = 0
}
Loop, %Wallpaper_Changer_Dir%\*.bmp
Total_Img_Cnt = %A_Index%
WinHide, Wallpaper Changer
Goto, Previous_Settings
Set_to_Original_Wallpaper:
SetTimer, %Img_Order%, Off
FileAppend, , C:\Documents and Settings\%A_UserName%\Local Settings\Temp\Wallpaper.tmp
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, Wallpaper, %Original_Wallpaper%
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper, %Original_TileWallpaper%
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle, %Original_WallpaperStyle%
Run, %A_WinDir%\System32\RUNDLL32.EXE user32.dll`,UpdatePerUserSystemParameters
Menu, Tray, Disable, Set to Original Wallpaper
Menu, Tray, Disable, Set to Current Wallpaper
Return
Set_to_Current_Wallpaper:
SetTimer, %Img_Order%, Off
Menu, Tray, Disable, Set to Current Wallpaper
Return
GuiClose:
Gui, hide
return
Exit_Label:
IfExist, C:\Documents and Settings\%A_UserName%\Local Settings\Temp\Wallpaper.tmp
Goto, Skip
FileCopy, %Wallpaper_Changer_Dir%\%Img%, C:\Documents and Settings\%A_UserName%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp, 1
Skip:
Run, %A_WinDir%\System32\RUNDLL32.EXE user32.dll`,UpdatePerUserSystemParameters
ExitApp
EDIT: Including the More adaptive version.
;Updated by Era Scarecrow 12 Aug 2010
;fixes to how i think the program should run.
;You should only need to change TimeRange/ MinRange, and MaxRange.
;MaxRange is in Minutes, the other two are a fraction of the max range.
;ex: TimeRange = 100, MaxRange = 60, so a Interval of 8 is 8% of an hour
; (about 4 minutes 48 seconds)
#SingleInstance Force
#Persistent
#NoEnv
SetBatchLines, -1
OnExit, Exit_Label
Gosub, TrayMenu
Img_Order = Fixed
Wallpaper_Changer_Dir = C:\Documents and Settings\%A_UserName%\Wallpaper Changer
IfNotExist, %Wallpaper_Changer_Dir%
FileCreateDir, %Wallpaper_Changer_Dir%
RegRead, Original_Wallpaper, HKEY_CURRENT_USER, Control Panel\Desktop, Wallpaper
RegRead, Original_TileWallpaper, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper
RegRead, Original_WallpaperStyle, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle
;sets the range you can select, and uses the MaxRange to determine how much time each
;1 represents. Ex: 100 range with 10 minutes, means 6 seconds per 1. With a min of 5,
;starting minimum value would be 30 seconds.
TimeRange = 1200 ;range increments.
MinRange = 1 ;from TimeRange
MaxRange = 60 ;in minutes
;Loads previous settings.
ifexist, %Wallpaper_Changer_Dir%\Wallpaper.ini
{
IniRead, Folder, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Path
IniRead, Interval, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Interval
IniRead, Position, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Position
IniRead, Img_Order, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Order
} else {
Interval := (TimeRange - MinRange) // 2 ;start halfway in the middle.
Interval += MinRange
}
Wallpaper_Changer:
FileDelete, C:\Documents and Settings\%A_UserName%\Local Settings\Temp\Wallpaper.tmp
;Defaults as none 'checked' R is short for Radio Control, 1-5
R1 =
R2 =
R3 =
R4 =
R5 =
;Match the position against the radio. If it's blank, first is defaulted.
if (position == "Center" || position == "")
R1 = Checked
else if (position == "Stretch")
R2 = Checked
else if (position == "Tile")
R3 = Checked
;Match the image order against the radio. If it's blank, first is defaulted.
if (Img_Order == "Random" || Img_Order == "")
R4 = Checked
else if (Img_Order == "Fixed")
R5 = Checked
SetTimer, Subroutine
Gui, Destroy
Gui, Font, s9 ;changed from 11, since text was wrapping
Gui, Add, GroupBox, x5 y5 w280 h50, Folder With Images
Gui, Add, GroupBox, x5 y60 w348 h65, Image Interval
Gui, Add, GroupBox, x5 y130 w185 h48, Image Position
Gui, Add, GroupBox, x200 y130 w153 h48, Image Order
Gui, Add, Edit, x10 y25 w270 h20 ReadOnly, %folder%
Gui, Add, Button, x290 y12 w65 h25, Browse
Gui, Add, Slider, x10 y80 w337 h30 gSubroutine AltSubmit Range%MinRange%-%TimeRange% NoTicks Page1 Line1, %Interval%
Gui, Add, Radio, x12 y150 w60 h20 vRadio1 %R1%, Center
Gui, Add, Radio, x78 y150 w60 h20 vRadio2 %R2%, Stretch
Gui, Add, Radio, x144 y150 w40 h20 vRadio3 %R3%, Tile
Gui, Add, Radio, x210 y150 w75 h20 vRadio4 Group %R4%, Random
Gui, Add, Radio, x293 y150 w50 h20 vRadio5 %R5%, Fixed
Gui, Font, s8
t := TimeString(MinRange)
Gui, Add, Text, x20 y110, %t% Min
t := TimeString(((TimeRange - MinRange) // 2) + MinRange)
Gui, Add, Text, x160 y110, %t% Min
t := TimeString(TimeRange)
Gui, Add, Text, x305 y110, %t% Min
Gui, Font, s12 Bold
Gui, Add, Button, x5 y182 w350 h30, Apply
if (!Folder) ;No folder, then we disable apply (first time?)
GuiControl, Disable, Apply
if (!firstRun && Folder) ;on the first run if we have settings already
gosub Set_to_Previous_Settings
else
Gui, Show, h215 w360 Center, Wallpaper Changer
firstRun = 1
Return
;using Interval_tt (toolTip) So interval isn't modified. So if the GUI
;closes, we won't lose our previous settings.
Subroutine:
GuiControlGet, Interval_tt, , msctls_trackbar321
IfWinActive, Wallpaper Changer
{
t := TimeString(Interval_tt)
ToolTip, %t% Min(s), 303, 75
}
IfWinNotActive, Wallpaper Changer
ToolTip
Return
Scanning_Images:
ToolTip, Scanning Images`nPlease Wait........, , , 2
Return
OnMessage(0x53, "WM_HELP")
WM_HELP(wParam, lParam)
{
Run, iexplore.exe http://www.IrfanView.com, Max
If ErrorLevel = Error
MsgBox, 8208, ERROR, Unable to load http`://www.IrfanView.com
Return
}
ButtonBrowse:
Gui, +OwnDialogs
GuiControl, Disable, Apply
FileSelectFolder, Folder, *%A_MyDocuments%\My Pictures, 0, `r
If Folder =
{
MsgBox, 8208, ERROR, No folder has been selected
Return
}
SetTimer, Scanning_Images
GuiControl, , Edit1, %Folder%
FileDelete, %Wallpaper_Changer_Dir%\*.*
Total_Img_Cnt = 0
Loop, %Folder%\*.*
{
If A_LoopFileExt in bmp,dib,gif,png,jpg,jpeg,jpe,jfif,tif,tiff
Total_Img_Cnt := Total_Img_Cnt + 1
}
Total_Bmp_Cnt = 0
Loop, %Folder%\*.bmp
Total_Bmp_Cnt = %A_Index%
If Total_Img_Cnt = %Total_Bmp_Cnt%
{
Loop, %Folder%\*.bmp
FileCopy, %A_LoopFileFullPath%, %Wallpaper_Changer_Dir%\%A_Index%.bmp
}
Else
{
SetTimer, Scanning_Images, Off
ToolTip, , , , 2
RegRead, IrfanView, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView, UninstallString
SplitPath, IrfanView, , IrfanView
IrfanView = %IrfanView%\i_view32.exe
IfNotExist, %IrfanView%
{
MsgBox, 16452, IrfanView,
(LTrim
All the images in "%Folder%" are not bitmap (.bmp) images.
IrfanView is required if all the images are not bitmap (.bmp) images.`n
Select the 'Help' button to read about IrfanView.
If you select the 'Yes' button, you will download IrfanView (Version 4.0).
If you select not to download IrfanView, just select another folder that contains ALL (.bmp) images.`n`n
Would you like to download IrfanView now?
)
}
IfMsgBox, Yes
{
Run, iexplore.exe https://ahknet.autohotkey.com/~ackrite/iview400_setup.exe, , Hide
WinMinimizeAll
Loop, 300000
{
Sleep, 1000
RegRead, IrfanView, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView, UninstallString
SplitPath, IrfanView, , IrfanView
IrfanView = %IrfanView%\i_view32.exe
IfExist, %IrfanView%
Loop, 300000
{
Sleep, 1000
IfWinNotExist, IrfanView Setup
{
WinActivate, Wallpaper Changer
MsgBox, 64, IrfanView, Download Complete!
Gui, Show, h215 w360 Center, Wallpaper Changer
WinActivate, Wallpaper Changer
Goto, IrfanView
}
}
}
IfNotExist, %IrfanView%
ExitApp
}
IfMsgBox, No
{
GuiControl, , Edit1
Goto, ButtonBrowse
}
IrfanView:
GuiControl, , Edit1, %Folder%
SetTimer, Scanning_Images
Total_Img_Cnt = 0
Loop, %Folder%\*.*
{
If A_LoopFileExt in bmp,dib,gif,png,jpg,jpeg,jpe,jfif,tif,tiff
{
Total_Img_Cnt := Total_Img_Cnt + 1
RunWait, "%IrfanView%" "%A_LoopFileFullPath%" /convert="%Wallpaper_Changer_Dir%\%Total_Img_Cnt%.bmp"
}
}
}
SetTimer, Scanning_Images, Off
ToolTip, , , , 2
If Total_Img_Cnt <= 1
{
MsgBox, 8208, ERROR, There is only one or no image files in "%Folder%".`n`nCheck the folder and try again or select a differnt folder.
GuiControl, , Edit1
Return
}
GuiControl, Enable, Apply
Return
ButtonApply:
Gui, Submit, NoHide
Menu, Tray, Enable, Set to Original Wallpaper
Menu, Tray, Enable, Set to Current Wallpaper
FileDelete, C:\Documents and Settings\%A_UserName%\Local Settings\Temp\Wallpaper.tmp
If Radio1 = 1
{
Position = Center
TileWallpaper = 0
WallpaperStyle = 0
}
If Radio2 = 1
{
Position = Stretch
TileWallpaper = 0
WallpaperStyle = 2
}
If Radio3 = 1
{
Position = Tile
TileWallpaper = 1
WallpaperStyle = 0
}
Img_Order = Random
If Radio4 = 1
Img_Order = Random
If Radio5 = 1
{
Img_Order = Fixed
Img_Cnt = 1
}
;get interval, not automatically updated with the rest of the data.
GuiControlGet, Interval, , msctls_trackbar321
IniWrite, %Folder%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Path
IniWrite, %Interval%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Interval
IniWrite, %Position%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Position
IniWrite, %Img_Order%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Order
;added for changes, when restart it will still use the previous settings til changed.
IniWrite, %TimeRange%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, TimeRange
IniWrite, %MaxRange%, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, MaxRange
SetTimer, Subroutine, Off
ToolTip
Gui, Submit
Previous_Settings:
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper, %TileWallpaper%
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle, %WallpaperStyle%
Menu, Tray, Disable, Hide
Menu, Tray, Enable, Show
if (A_ThisLabel == "Previous_Settings") {
IniRead, tr, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, TimeRange
IniRead, mr, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, MaxRange
;default settings from original script.
if (tr == "ERROR")
tr = 60
if (mr == "ERROR")
mr = 60
conv := (mr * 60000) / tr ;conversion ratio (60 seconds per minute of max range)
t := floor(Interval * conv) ;use conversion rate for seconds to ms.
;convert ms to an acceptible Interval
conv := (MaxRange * 60000) / TimeRange
Interval := round(t / conv) ;convert ms back to Closest Interval
} else {
conv := (MaxRange * 60) / TimeRange ;conversion ratio
t := floor(Interval * 1000 * conv) ;use conversion rate for seconds to ms.
}
SetTimer, %Img_Order%, %t%
GoSub, %Img_Order%
Return
Random:
Random, Img, 1, %Total_Img_Cnt%
Img = %Img%.bmp
GoSub, Show_Img
Return
Fixed:
Loop, %Wallpaper_Changer_Dir%\*.bmp
{
If (Img_Cnt = Total_Img_Cnt + 1)
Img_Cnt = 1
If A_Index = %Img_Cnt%
{
Img = %A_LoopFileName%
Img_Cnt := Img_Cnt + 1
Break
}
}
GoSub, Show_Img
Return
Show_Img:
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, Wallpaper, %Wallpaper_Changer_Dir%\%Img%
Run, %A_WinDir%\System32\RUNDLL32.EXE user32.dll`,UpdatePerUserSystemParameters
Return
TrayMenu:
Menu, Tray, MainWindow
Menu, Tray, NoStandard
Menu, Tray, Add, Wallpaper Changer, Wallpaper_Changer
Menu, Tray, Add
Menu, Tray, Add, View Previous Settings, View_Previous_Settings
Menu, Tray, Add, Set to Previous Settings, Set_to_Previous_Settings
Menu, Tray, Add, Set to Original Wallpaper, Set_to_Original_Wallpaper
Menu, Tray, Add, Set to Current Wallpaper, Set_to_Current_Wallpaper
Menu, Tray, Add, Hide, Hide
Menu, Tray, Add, Show, Show
Menu, Tray, Add, Exit, Exit_Label
Menu, Tray, Disable, Set to Original Wallpaper
Menu, Tray, Disable, Set to Current Wallpaper
Menu, Tray, Default, Wallpaper Changer
Menu, Tray, Disable, Show
Return
Hide:
WinHide, Wallpaper Changer
Menu, Tray, ToggleEnable, Hide
Menu, Tray, ToggleEnable, Show
Return
Show:
Gui, Show, h215 w360 Center, Wallpaper Changer
WinActivate, Wallpaper Changer
Menu, Tray, ToggleEnable, Show
Menu, Tray, ToggleEnable, Hide
Return
View_Previous_Settings:
IniRead, Folder, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Path
IniRead, Interval, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Interval
IniRead, Position, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Position
IniRead, Order, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Order
IniRead, tr, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, TimeRange
IniRead, mr, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, MaxRange
t := TimeString(Interval, tr, mr)
MsgBox, 64, Wallpaper Changer Settings, Path = %Folder%`nInterval = %t% Min`nPosition = %Position%`nOrder = %Order%
Return
Set_to_Previous_Settings:
IniRead, Folder, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Path
IniRead, Interval, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Interval
IniRead, Position, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Position
IniRead, Img_Order, %Wallpaper_Changer_Dir%\Wallpaper.ini, Wallpaper Changer Settings, Order
If Img_Order = Fixed
Img_Cnt = 1
If Position = Center
{
TileWallpaper = 0
WallpaperStyle = 0
}
If Position = Stretch
{
TileWallpaper = 0
WallpaperStyle = 2
}
If Position = Tile
{
TileWallpaper = 1
WallpaperStyle = 0
}
Loop, %Wallpaper_Changer_Dir%\*.bmp
Total_Img_Cnt = %A_Index%
WinHide, Wallpaper Changer
Goto, Previous_Settings
Set_to_Original_Wallpaper:
SetTimer, %Img_Order%, Off
FileAppend, , C:\Documents and Settings\%A_UserName%\Local Settings\Temp\Wallpaper.tmp
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, Wallpaper, %Original_Wallpaper%
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper, %Original_TileWallpaper%
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle, %Original_WallpaperStyle%
Run, %A_WinDir%\System32\RUNDLL32.EXE user32.dll`,UpdatePerUserSystemParameters
Menu, Tray, Disable, Set to Original Wallpaper
Menu, Tray, Disable, Set to Current Wallpaper
Return
Set_to_Current_Wallpaper:
SetTimer, %Img_Order%, Off
Menu, Tray, Disable, Set to Current Wallpaper
Return
GuiClose:
Gui, hide
return
Exit_Label:
IfExist, C:\Documents and Settings\%A_UserName%\Local Settings\Temp\Wallpaper.tmp
Goto, Skip
FileCopy, %Wallpaper_Changer_Dir%\%Img%, C:\Documents and Settings\%A_UserName%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp, 1
Skip:
Run, %A_WinDir%\System32\RUNDLL32.EXE user32.dll`,UpdatePerUserSystemParameters
ExitApp
;returns M{1-2}:[SS].[1/100] string.
;if TimeRange and MaxRange equal, only minutes
;if there's less in TimeRange than seconds for MaxRange, adds seconds
;if it's more, than adds 1/100th seconds in.
TimeString(tt, tr = 0, mr = 0) {
global TimeRange ;increment, could be seconds.
global MaxRange ;in minutes
if (!tr || !mr) {
tr := TimeRange
mr := MaxRange
}
conv := (mr * 60) / tr ;conversion ratio
t := floor(tt * conv) ;convert to seconds
;since the time (tt) should now be in seconds, convert to time.
m := t // 60
s := mod(t, 60)
if (s < 10)
s = 0%s%
;add 1/100th increments check
if ((mr * 60) < tr) {
t := floor(tt * 100 * conv)
t := mod(t, 100)
if (t < 10)
s .= ".0" . t
else
s .= "." . t
}
if (tr != mr)
tt = %m%:%s%
else ;when it's exact, we know we are only working with minutes.
tt = %m%
return tt
}