 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Mon Jan 09, 2006 10:54 am Post subject: Automatic Wallpaper Changer [AHK Script, requires IrfanView] |
|
|
I am posting this script after a request in the following forum topic:
http://www.autohotkey.com/forum/viewtopic.php?t=6951
Simply put, my script does one thing, it keeps changing the wallpapers with a preset duration. It takes the image file's name from a text file (which is conceptually similar to a .M3U playlist) and passes the filename as a parameter to IrfanView executable which takes care of setting the wallpaper.
Existing IrfanView users can save this script to the same folder where i_view32.exe resides
You may download IrfanView 3.97 by clicking the following link http://www.download.com/3001-2192_4-10387524.html
You may download directly the .ZIP file (My Script [Auto-WPC.AHK] and the i_view32.exe] But be sure to run a Virus Scanner on i_view32.exe before executing my Script http://www.geocities.com/venneye/Auto-WPC/Auto-WPC-20060106000003.zip
Open this code as a Text file by clicking http://www.geocities.com/venneye/Auto-WPC/Auto-WPC.txt
| Code: | FileCreationTime=20060106000003 ; The first three lines facilitates the updation of this
;script from my webpage.
WebLocation=http://www.geocities.com/venneye/Auto-WPC/ ;Do not alter or move it
#Persistent
;----------------------------------------------------------------------------------------
; Modify the Variable Values (to suit your needs)
;----------------------------------------------------------------------------------------
Duration=1 ; .1 to 60 Duration between Wallpaper Changes (In Mins)
ListFile=MyFavouriteImages.Txt ; File name of the Image List
WallpaperSetType=2 ; 0,1,2 0=Centered 1=Tiled 2=Stretched
SetRandomWallpaper=1 ; 0 or 1 0 to Disable
RepeatList=1 ; 0 or 1 0 to Disable
MinimizeAllWindows=1 ; 0 or 1 0 to Disable
;- While exiting this Script you can set a Wallpaper of your preference
ChangeWallpaperOnExit=1 ; 0 or 1 0 to Disable WallpaperOnExit
WallPaperOnExit=SomeImage.GIF ; Wallpaper to set when script exits
;-While Wallpaper is changed, sound will be played the filename is shown as Tooltip
DisplayTooltip=1 ; 0 or 1 0 to Disable
TooltipDisplayDuration=1000 ; 500-5000 in MilliSeconds
Play_A_Wave_Sound=1 ; 0 or 1 1 plays Clicking.Wav, 0 Mutes it
WaveFileName=Clicking.Wav ; The Default Wave File
;----------------------------------------------------------------------------------------
; Following Settings Influence Creation and Additions to "ListFile"
;----------------------------------------------------------------------------------------
ValidImageExtensions=|JPG|PNG|BMP|GIF| ; Leave this unmodified
RecurseSubFolders=1 ; 0 to Disable
MinJPGSize=100 ; in KiloBytes
MinBMPSize=1440 ; in KiloBytes
MinPNGSize=500 ; in KiloBytes
MinGIFSize=200 ; in KiloBytes
OverWriteMode=1 ; 0 to Disable
;----------------------------------------------------------------------------------------
; Alter following Hotkey-Labels as required, and remove the semi-colon in the beginning
;#Q::Menu,Tray,Show,5,5 ; Shows the "Tray Menu" on TOP-LEFT of Screen
;#Z::Gosub,Exitt ; Exit this Script
;#F5::Reload ; Reload This Script
#SingleInstance Ignore
CoordMode, Menu, Screen
CoordMode, Mouse, Screen
OnExit, Exitt
SetWorkingDir,%A_ScriptDir%
IfNotExist,I_VIEW32.EXE ; IrfanView Executable
{
L1=IrfanView Executable I_VIEW32.EXE is required for functioning of
L2=Script!..Download and install IrfanView and copy I_VIEW32.EXE to
MsgBox,16,Missing File: %A_ScriptDir%\I_VIEW32.EXE,%L1%`n%L2%`n`n%A_ScriptDir%\
Errors=1
GoSub,Exitt
}
IFExist,Auto-WPC.GIF ; When a new version of the script is Installed
{
Runwait, i_view32.exe "Auto-WPC.GIF" /wall=1 /killmesoftly
FileDelete,Auto-WPC.GIF
WinMinimizeAll
Sleep,5000
}
IfnotExist,%ListFile% ; The Image Listing File
{
Errors=1
GoSub,CreateListFile
}
GoSub,CheckVariables
SleepValue:=Duration
EnvMult,SleepValue,(60*1000) ; Convert Duration into MilliSeconds
Menu, Tray, NoStandard
Menu, Tray, Add,&Open %ListFile% in Editor,EditListFile
if OverWriteMode
Menu, Tray, Add,&Create a New %ListFile%,CreateListFile
else
Menu, Tray, Add,&Add Images to %ListFile%,CreateListFile
Menu, Tray, Add, ; ----------------------------------------------------------
if Play_A_Wave_Sound
Menu, Tray, Add,Turn &Sound OFF ,ToggleSound
else
Menu, Tray, Add,Turn &Sound ON,ToggleSound
If DisplayTooltip
Menu, Tray, Add,Turn Tooltip &Display OFF,ToggleSound
else
Menu, Tray, Add,Turn Tooltip &Display ON ,ToggleSound
Menu, Tray, Add, ; ----------------------------------------------------------
Menu, Tray, Add,&Visit the Webpage [www.geocities.com] ,OpenWebPage
Menu, Tray, Add,e-Mail &Goyyah [arian.suresh@gmail.com],MailtoAuthor
Menu, Tray, Add,Check for an &Update [%A_ScriptName%],CheckForUpdate
Menu, Tray, Add,Fetch my &External IP Address,GetExternalIP
Menu, Tray, Add, ; ----------------------------------------------------------
Menu, Tray, Add,Bac&kup a Copy of %A_ScriptName%,BackupScript
Menu, Tray, Add,View &Readme.Txt,ViewReadme
Menu, Tray, Add,E&xit Automatic Wallpaper Changer,Exitt
Menu, Tray, Default,E&xit Automatic Wallpaper Changer
Menu, Tray, Tip,Double-Click to Exit %A_ScriptName%
ifExist,Auto-WPC.ICO
Menu, Tray, Icon,Auto-WPC.ICO
If PopupTrayMenu
SetTimer, CheckMousePosition, 500
; Read "ListFile" one line at a time, Check whether the file exists, and append
; it to a variable named "Flist"
Flist:=
FirstLine=1
FileCount=0
Loop, Read,%ListFile%
{
ImageFile=%A_LoopReadLine%
ifexist,%ImageFile%
FileCount+=1
if FirstLine=1
{
Flist=%ImageFile%
FirstLine=0
}
else
Flist=%Flist%`n%ImageFile%
}
FileDelete,RandList.txt
If SetRandomWallPaper
Sort,FLIST,Random
FileAppend,%Flist%,RandList.Txt ; The Random list file is created
If WallPaperOnExit=
FileReadLine,WallPaperOnExit,RandList.TXT,1
;----------------------------------------------------------------------------------------
; // The Main Loop //
;----------------------------------------------------------------------------------------
LineNumber=1
Loop,
{
FileReadLine,ImageFileName,RandList.TXT,%LineNumber%
if DisplayTooltip
Tooltip, Changing Wallpaper to %ImageFileName%,30,30
if Play_A_Wave_Sound
Soundplay,%WaveFileName%
; IrfanView Steps in
Runwait, i_view32.exe "%ImageFileName%" /wall=%WallpaperSetType% /killmesoftly
if DisplayTooltip
{
Sleep,%TooltipDisplayDuration%
Tooltip
}
Sleep,%SleepValue%
LineNumber+=1
If LineNumber > %FileCount%
{
if ! Repeatlist
GoSub,Exitt
else
LineNumber=1
}
}
Return
;----------------------------------------------------------------------------------------
CheckVariables: ; and assign default values to erroneous values
if Duration < .1
Duration=.1
if Duration > 60
Duration=60
If ListFile=
ListFile=FileList.Txt
if (WallPaperSetType !=0 and WallPaperSetType !=1 and WallPaperSetType !=2)
WallpaperSetType=2
if (SetRandomWallpaper !=0 and SetRandomWallpaper !=1)
SetRandomWallpaper=1
if (RepeatList !=0 and RepeatList !=1)
RepeatList=1
if (PopupTrayMenu !=0 and PopupTrayMenu !=1)
PopupTrayMenu=1
IFNotExist,%WallPaperOnExit%
WallpaperOnExit=
if (ChangeWallpaperOnExit !=0 and ChangeWallpaperOnExit !=1)
ChangeWallpaperOnExit=1
if (DisplayTooltip !=0 and DisplayTooltip !=1)
DisplayTooltip=1
if (DisplayTooltipDuration <500 and DisplayTooltipDuration >5000)
DisplayTooltipDuration=2345
if DisplayTooltip
EnvSub,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display
if (RecurseSubFolders !=0 and RecurseSubFolders !=1)
RecurseSubFolders=1
Return
;----------------------------------------------------------------------------------------
CreateListFile:
WriteFile=%A_ScriptDir%\%ListFile%
FileSelectFolder,ImageFolder,*%A_ScriptDir%,3,Select a Folder Containing Images
if ImageFolder= ; The user pressed Escape in Select Folder Dialog
if Errors
Gosub,Exitt
else
reload
StringRight,LastChar,ImageFolder,1
if LastChar != \
ImageFolder=%ImageFolder%\*.*
else
ImageFolder=%ImageFolder%*.*
If OverWriteMode
FileRecycle,%WriteFile%
FirstLine=1
Loop,%ImageFolder%,0,%RecurseSubFolders%
{
ImageFile:=A_LoopFileLongPath
SplitPath,ImageFile,,,ImageExt,,
if ImageExt=
Continue
IfNotInString,ValidImageExtensions,%ImageExt%
{
Tooltip,Skipping: %ImageFile%
Continue
}
FileGetSize,FileSize,%ImageFile%,K
MinSize=Min%ImageExt%Size
MinImageSize:=%MinSize%
if FileSize < %MinImageSize%
{
Tooltip,Skipping: %ImageFile%
Continue
}
Tooltip,Adding: %ImageFile% %FileSize%
if FirstLine
{
FileAppend,%ImageFile%,%WriteFile%
FirstLine=0
}
else
FileAppend,`n%ImageFile%,%WriteFile%
Sleep,100
}
reload
Return
;----------------------------------------------------------------------------------------
EditListFile:
ToolTip,
RunWait,%ListFile%
Return
;----------------------------------------------------------------------------------------
GetExternalIP:
Tooltip,Resolving External IP Address,30,30
ExternalIP=0.0.0.0
TmpFile=IPAddress.TMP
UrlDownloadToFile,http://www.whatismyip.org/,%TmpFile%
FileReadLine,ExternalIP,%TmpFile%,1
FileDelete,%TmpFile%
Tooltip,
LastMenuItem = %A_ThisMenuItem%
if LastMenuItem=Fetch my &External IP Address
Msgbox,64,[Auto-WPC] External IP Address,External IP Address: %ExternalIP%
Return
;----------------------------------------------------------------------------------------
OpenWebPage:
URL=%WebLocation%index.htm
GoSub,GetExternalIP
if ExternalIP!=0.0.0.0
Run,%URL%
Return
;----------------------------------------------------------------------------------------
MailtoAuthor:
Run,mailto:arian.suresh@gmail.com?Subject=Re:Auto-WPC [%FileCreationTime%]
Return
;----------------------------------------------------------------------------------------
CheckForUpdate:
GoSub,GetExternalIP
if ExternalIP=0.0.0.0
Exit
DownloadFolder=%A_ScriptDir%\Download\
ifNotExist,%DownloadFolder%
FileCreateDir,%DownloadFolder%
FormatTime,TimeStamp,,[yy-MM-dd] @ [H.mm.ss]
DownloadFileName=%DownloadFolder%%TimeStamp% - %A_ScriptName%
URL=%WebLocation%\Auto-WPC.txt
URLDownloadToFile,%URL%,%DownloadFileName%
FileReadline,DL_Version,%DownloadFileName%,1
StringMid,DL_Version,DL_Version,18,14
if DL_Version > %FileCreationTime%
{
L1=The latest version of this script has been downloaded!
L2=Would like to replace this Script with the new one?
L3=Current %A_ScriptName% will be copied to BackUp\ folder.
MsgBox,36,Automatic Wallpaper Changer - Internet Update
,%L1%`n%L2%`n`n%L3%`n`nProceed?
ifMsgBox,Yes
{
inUpdationMode=1
GoSub,BackupScript
FileCopy,%DownloadFileName%,%A_ScriptFullPath%,1 ; Overwrites Current Script!
Readme=%A_ScriptDir%\Readme.txt
ReadmeURL=%Weblocation%readme/%DL_Version%.txt
URLDownloadToFile,%ReadmeURL%,%Readme%
ImageURL=%Weblocation%splash.gif
URLDownloadToFile,%ImageURL%,Auto-WPC.GIF
Reload
}
}
Return
;----------------------------------------------------------------------------------------
CheckMousePosition:
; When the Mouse is moved up to the TOP-LEFT corner, this routine Pop-up's the
; Tray Menu and minimizes all Visible Windows. Combined this with the Shift key
; Displays Tray Menu without Minimizing any Windows. Requires "PopupTrayMenu=1"
MouseGetPos, Xpos, Ypos
GetKeyState, ShiftStatus, Shift
Pos:=Xpos+Ypos
if Pos=0
{
if ShiftStatus=U
WinMinimizeAll
Sleep,361
MouseGetPos, Xpos, Ypos
Pos:=Xpos+Ypos
if Pos=0
{
MouseMove, 20, 20,5
Menu,Tray,Show,5,5
}
}
Return
;----------------------------------------------------------------------------------------
ToggleSound: ; and also Tooltip Display
MenuItem:=A_ThisMenuItem
if MenuItem=Turn &Sound ON
{
Play_A_Wave_Sound=1
Menu, Tray, Rename,Turn &Sound ON,Turn &Sound OFF
}
if MenuItem=Turn &Sound OFF
{
Play_A_Wave_Sound=0
Menu, Tray, Rename,Turn &Sound OFF,Turn &Sound ON
}
if MenuItem=Turn Tooltip &Display OFF
{
DisplayTooltip=0
Menu, Tray, Rename,Turn Tooltip &Display OFF,Turn Tooltip &Display ON
EnvAdd,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display Time
}
if MenuItem=Turn Tooltip &Display ON
{
DisplayTooltip=1
Menu, Tray, Rename,Turn Tooltip &Display ON,Turn Tooltip &Display OFF
EnvSub,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display Time
}
return
;----------------------------------------------------------------------------------------
BackupScript:
BackupFolder=%A_ScriptDir%\Backup\
ifNotExist, %BackUpFolder%
FileCreateDir,%BackupFolder%
FormatTime,TimeStamp,,[yy-MM-dd] @ [H.mm.ss]
BackupFileName=%BackUpFolder%%TimeStamp% - %A_ScriptName%
FileCopy,%A_ScriptName%,%BAckupFileName%
If ! inUpdationMode
MsgBox,64,This Script [%A_ScriptName%] has been Archived,%BackupFileName%,10
Return
;----------------------------------------------------------------------------------------
ViewReadMe:
Run,Readme.Txt
return
;----------------------------------------------------------------------------------------
Exitt:
if Errors
Exitapp
if ChangeWallpaperOnExit
Run, i_view32.exe "%WallpaperOnExit%" /wall=%WallpaperSetType% /killmesoftly
FileDelete,RandList.TXT
ExitApp
Return
;----------------------------------------------------------------------------------------
;* - Script written by Goyyah [ arian.suresh@gmail.com ] |
for more info on the script visit http://www.geocities.com/venneye/Auto-WPC/index.htm
 _________________ URLGet - Internet Explorer based Downloader |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Jan 09, 2006 1:11 pm Post subject: Re: Automatic Wallpaper Changer [AHK Script, requires IrfanV |
|
|
Why not go to the source instead: http://www.irfanview.com/? Current version is 3.98. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Mon Jan 09, 2006 1:22 pm Post subject: |
|
|
Yes! I know that .. I wanted to provide a direct link and picked up this link from their download page. They are yet to update with download.com _________________ URLGet - Internet Explorer based Downloader |
|
| Back to top |
|
 |
TheLeO
Joined: 11 Jun 2005 Posts: 264 Location: England ish
|
Posted: Wed Jan 11, 2006 8:28 am Post subject: |
|
|
i originaly asked for it.. Wow. Kinda feel happy that some ones spends so much time on some thing i asked for.. Thanks alot.  _________________ ::
I Have Spoken
:: |
|
| Back to top |
|
 |
quatermass
Joined: 14 Dec 2005 Posts: 216
|
Posted: Wed Feb 15, 2006 11:25 am Post subject: |
|
|
Before I knew about AHK, I set up a batch scripts years ago to randomly download off the Internet jpeg images from my own web site and display them on the desktop with Irfanview.
I even wrote scripts to take images off web sites like the Dilbert cartoon and other sites like the Weather map or a daily Babe image.
So every 30 mins I got a new desktop image.
There are hundreds of web site out there with large images on it.
Food for thought?
I used 'setdesk.exe' to put the image on the desktop and only used Irfanview to resize the images or convert jpg or gif to bmp. I used CURL to download the images.
http://desktopian.org/addons/setdesk.zip
I may convert my scripts to AHK.
http://www.quantumsoft.co.uk/files/clipart/jpegs/
http://www.quantumsoft.co.uk/files/clipart/jpegs/cars/ _________________ Stuart Halliday |
|
| Back to top |
|
 |
sashabe
Joined: 09 Oct 2006 Posts: 21
|
Posted: Tue Aug 14, 2007 5:23 pm Post subject: |
|
|
Hi, i edited the script a bit to my taste and decided to upload here.
The major change is that this version of script exits itself immediately after changing wallpaper. Thus, there's no memory footprint left. It's an optimal case for those who like wallpaper only be changed on start-up. Wallpaper may still be changed by an interval with Windows' native service "Scheduled Tasks". Then, it's possible to get back to the original permanently-running mode by changing the new variable "ExitOnChange" at the beginning of the document.
And I added the to the tray menu "Reload Script" and "Edit Script" items. Also, the size of images was decreased a bit (because with default values from the folder with 10 images, all 1280x1024 pixels WxH, only 5 were chosen).
BTW, it would be great to see these changes implemented by Skan in his wonderful script 'officially' And enormous thanks to him for such a REALLY invaluable piece of work!
| Code: | FileCreationTime=20060106000003 ; The first three lines facilitates the updation of this
;script from my webpage.
WebLocation=http://www.geocities.com/venneye/Auto-WPC/ ;Do not alter or move it
#Persistent
;----------------------------------------------------------------------------------------
; Modify the Variable Values (to suit your needs)
;----------------------------------------------------------------------------------------
Duration=60 ; .1 to 60 Duration between Wallpaper Changes (In Mins)
ListFile=MyFavouriteImages.Txt ; File name of the Image List
WallpaperSetType=2 ; 0,1,2 0=Centered 1=Tiled 2=Stretched
SetRandomWallpaper=1 ; 0 or 1 0 to Disable
RepeatList=1 ; 0 or 1 0 to Disable
MinimizeAllWindows=0 ; 0 or 1 0 to Disable
;- While exiting this Script you can set a Wallpaper of your preference
ChangeWallpaperOnExit=0 ; 0 or 1 0 to Disable WallpaperOnExit
WallPaperOnExit=SomeImage.GIF ; Wallpaper to set when script exits
;-While Wallpaper is changed, sound will be played the filename is shown as Tooltip
DisplayTooltip=0
ExitOnChange=1 ; 0 or 1 0 to Disable
TooltipDisplayDuration=1000 ; 500-5000 in MilliSeconds
Play_A_Wave_Sound=1 ; 0 or 1 1 plays a defined wave file, 0 Mutes it
WaveFileName=Clicking.Wav ; The Default Wave File
;----------------------------------------------------------------------------------------
; Following Settings Influence Creation and Additions to "ListFile"
;----------------------------------------------------------------------------------------
ValidImageExtensions=|JPG|PNG|BMP|GIF| ; Leave this unmodified
RecurseSubFolders=1 ; 0 to Disable
MinJPGSize=10 ; in KiloBytes
MinBMPSize=200 ; in KiloBytes
MinPNGSize=50 ; in KiloBytes
MinGIFSize=10 ; in KiloBytes
OverWriteMode=1 ; 0 to Disable
;----------------------------------------------------------------------------------------
; Alter following Hotkey-Labels as required, and remove the semi-colon in the beginning
;#Q::Menu,Tray,Show,5,5 ; Shows the "Tray Menu" on TOP-LEFT of Screen
;#Z::Gosub,Exitt ; Exit this Script
;#F5::Reload ; Reload This Script
#SingleInstance Ignore
CoordMode, Menu, Screen
CoordMode, Mouse, Screen
OnExit, Exitt
SetWorkingDir,%A_ScriptDir%
IfNotExist,I_VIEW32.EXE ; IrfanView Executable
{
L1=IrfanView Executable I_VIEW32.EXE is required for functioning of
L2=Script!..Download and install IrfanView and copy I_VIEW32.EXE to
MsgBox,16,Missing File: %A_ScriptDir%\I_VIEW32.EXE,%L1%`n%L2%`n`n%A_ScriptDir%\
Errors=1
GoSub,Exitt
}
IFExist,Auto-WPC.GIF ; When a new version of the script is Installed
{
Runwait, i_view32.exe "Auto-WPC.GIF" /wall=1 /killmesoftly
FileDelete,Auto-WPC.GIF
WinMinimizeAll
Sleep,5000
}
IfnotExist,%ListFile% ; The Image Listing File
{
Errors=1
GoSub,CreateListFile
}
GoSub,CheckVariables
SleepValue:=Duration
EnvMult,SleepValue,(60*1000) ; Convert Duration into MilliSeconds
Menu, Tray, NoStandard
Menu, Tray, Add,&Edit images list,EditListFile
if OverWriteMode
Menu, Tray, Add,C&hoose images directory,CreateListFile
else
Menu, Tray, Add,&Add Images to the list,CreateListFile
Menu, Tray, Add, ; ----------------------------------------------------------
if Play_A_Wave_Sound
Menu, Tray, Add,Turn &Sound OFF ,ToggleSound
else
Menu, Tray, Add,Turn &Sound ON,ToggleSound
If DisplayTooltip
Menu, Tray, Add,Turn Tooltip &Display OFF,ToggleSound
else
Menu, Tray, Add,Turn Tooltip &Display ON ,ToggleSound
Menu, Tray, Add, ; ----------------------------------------------------------
Menu, Tray, Add,View &Readme.Txt,ViewReadme
Menu, Tray, Add,&Visit the Webpage [www.geocities.com] ,OpenWebPage
Menu, Tray, Add,e-Mail &Goyyah [arian.suresh@gmail.com],MailtoAuthor
Menu, Tray, Add,Check for an &Update [%A_ScriptName%],CheckForUpdate
Menu, Tray, Add,Fetch my &External IP Address,GetExternalIP
Menu, Tray, Add, ; ----------------------------------------------------------
Menu, Tray, Add,Reload s&cript,ReloadScript
Menu, Tray, Add,Edit &script,EditScript
Menu, Tray, Add,Bac&kup script,BackupScript
Menu, Tray, Add,E&xit Automatic Wallpaper Changer,Exitt
Menu, Tray, Default,E&xit Automatic Wallpaper Changer
Menu, Tray, Tip,Double-Click to Exit %A_ScriptName%
ifExist,Auto-WPC.ICO
Menu, Tray, Icon,Auto-WPC.ICO
If PopupTrayMenu
SetTimer, CheckMousePosition, 500
; Read "ListFile" one line at a time, Check whether the file exists, and append
; it to a variable named "Flist"
Flist:=
FirstLine=1
FileCount=0
Loop, Read,%ListFile%
{
ImageFile=%A_LoopReadLine%
ifexist,%ImageFile%
FileCount+=1
if FirstLine=1
{
Flist=%ImageFile%
FirstLine=0
}
else
Flist=%Flist%`n%ImageFile%
}
FileDelete,RandList.txt
If SetRandomWallPaper
Sort,FLIST,Random
FileAppend,%Flist%,RandList.Txt ; The Random list file is created
If WallPaperOnExit=
FileReadLine,WallPaperOnExit,RandList.TXT,1
;----------------------------------------------------------------------------------------
; // The Main Loop //
;----------------------------------------------------------------------------------------
LineNumber=1
Loop,
{
FileReadLine,ImageFileName,RandList.TXT,%LineNumber%
if DisplayTooltip
Tooltip, Changing Wallpaper to %ImageFileName%,30,30
if Play_A_Wave_Sound
Soundplay,%WaveFileName%
Sleep, 1100
; IrfanView Steps in
Runwait, i_view32.exe "%ImageFileName%" /wall=%WallpaperSetType% /killmesoftly
if DisplayTooltip
{
Sleep,%TooltipDisplayDuration%
Tooltip
}
if ExitOnChange=1
{
ExitApp
}
else
{
return
}
;ExitApp ;COMMENT THIS LINE TO MAKE SCRIPT RUNNING WITHOUT EXITING
Sleep,%SleepValue%
LineNumber+=1
If LineNumber > %FileCount%
{
if ! Repeatlist
GoSub,Exitt
else
LineNumber=1
}
}
Return
;----------------------------------------------------------------------------------------
CheckVariables: ; and assign default values to erroneous values
if Duration < .1
Duration=.1
if Duration > 60
Duration=60
If ListFile=
ListFile=FileList.Txt
if (WallPaperSetType !=0 and WallPaperSetType !=1 and WallPaperSetType !=2)
WallpaperSetType=2
if (SetRandomWallpaper !=0 and SetRandomWallpaper !=1)
SetRandomWallpaper=1
if (RepeatList !=0 and RepeatList !=1)
RepeatList=1
if (PopupTrayMenu !=0 and PopupTrayMenu !=1)
PopupTrayMenu=1
IFNotExist,%WallPaperOnExit%
WallpaperOnExit=
if (ChangeWallpaperOnExit !=0 and ChangeWallpaperOnExit !=1)
ChangeWallpaperOnExit=1
if (DisplayTooltip !=0 and DisplayTooltip !=1)
DisplayTooltip=1
if (ExitOnChange !=0 and ExitOnChange !=1)
ExitOnChange=0
if (DisplayTooltipDuration <500 and DisplayTooltipDuration >5000)
DisplayTooltipDuration=2345
if DisplayTooltip
EnvSub,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display
if (RecurseSubFolders !=0 and RecurseSubFolders !=1)
RecurseSubFolders=1
Return
;----------------------------------------------------------------------------------------
CreateListFile:
WriteFile=%A_ScriptDir%\%ListFile%
FileSelectFolder,ImageFolder,*%A_ScriptDir%,3,Select a Folder Containing Images
if ImageFolder= ; The user pressed Escape in Select Folder Dialog
if Errors
Gosub,Exitt
else
reload
StringRight,LastChar,ImageFolder,1
if LastChar != \
ImageFolder=%ImageFolder%\*.*
else
ImageFolder=%ImageFolder%*.*
If OverWriteMode
FileRecycle,%WriteFile%
FirstLine=1
Loop,%ImageFolder%,0,%RecurseSubFolders%
{
ImageFile:=A_LoopFileLongPath
SplitPath,ImageFile,,,ImageExt,,
if ImageExt=
Continue
IfNotInString,ValidImageExtensions,%ImageExt%
{
Tooltip,Skipping: %ImageFile%
Continue
}
FileGetSize,FileSize,%ImageFile%,K
MinSize=Min%ImageExt%Size
MinImageSize:=%MinSize%
if FileSize < %MinImageSize%
{
Tooltip,Skipping: %ImageFile%
Continue
}
Tooltip,Adding: %ImageFile% %FileSize%
if FirstLine
{
FileAppend,%ImageFile%,%WriteFile%
FirstLine=0
}
else
FileAppend,`n%ImageFile%,%WriteFile%
Sleep,100
}
reload
Return
;----------------------------------------------------------------------------------------
EditListFile:
ToolTip,
RunWait,%ListFile%
Return
;----------------------------------------------------------------------------------------
GetExternalIP:
Tooltip,Resolving External IP Address,30,30
ExternalIP=0.0.0.0
TmpFile=IPAddress.TMP
UrlDownloadToFile,http://www.whatismyip.org/,%TmpFile%
FileReadLine,ExternalIP,%TmpFile%,1
FileDelete,%TmpFile%
Tooltip,
LastMenuItem = %A_ThisMenuItem%
if LastMenuItem=Fetch my &External IP Address
Msgbox,64,[Auto-WPC] External IP Address,External IP Address: %ExternalIP%
Return
;----------------------------------------------------------------------------------------
OpenWebPage:
URL=%WebLocation%index.htm
GoSub,GetExternalIP
if ExternalIP!=0.0.0.0
Run,%URL%
Return
;----------------------------------------------------------------------------------------
MailtoAuthor:
Run,mailto:arian.suresh@gmail.com?Subject=Re:Auto-WPC [%FileCreationTime%]
Return
;----------------------------------------------------------------------------------------
CheckForUpdate:
GoSub,GetExternalIP
if ExternalIP=0.0.0.0
Exit
DownloadFolder=%A_ScriptDir%\Download\
ifNotExist,%DownloadFolder%
FileCreateDir,%DownloadFolder%
FormatTime,TimeStamp,,[yy-MM-dd] @ [H.mm.ss]
DownloadFileName=%DownloadFolder%%TimeStamp% - %A_ScriptName%
URL=%WebLocation%\Auto-WPC.txt
URLDownloadToFile,%URL%,%DownloadFileName%
FileReadline,DL_Version,%DownloadFileName%,1
StringMid,DL_Version,DL_Version,18,14
if DL_Version > %FileCreationTime%
{
L1=The latest version of this script has been downloaded!
L2=Would like to replace this Script with the new one?
L3=Current %A_ScriptName% will be copied to BackUp\ folder.
MsgBox,36,Automatic Wallpaper Changer - Internet Update
,%L1%`n%L2%`n`n%L3%`n`nProceed?
ifMsgBox,Yes
{
inUpdationMode=1
GoSub,BackupScript
FileCopy,%DownloadFileName%,%A_ScriptFullPath%,1 ; Overwrites Current Script!
Readme=%A_ScriptDir%\Readme.txt
ReadmeURL=%Weblocation%readme/%DL_Version%.txt
URLDownloadToFile,%ReadmeURL%,%Readme%
ImageURL=%Weblocation%splash.gif
URLDownloadToFile,%ImageURL%,Auto-WPC.GIF
Reload
}
}
Return
;----------------------------------------------------------------------------------------
CheckMousePosition:
; When the Mouse is moved up to the TOP-LEFT corner, this routine Pop-up's the
; Tray Menu and minimizes all Visible Windows. Combined this with the Shift key
; Displays Tray Menu without Minimizing any Windows. Requires "PopupTrayMenu=1"
MouseGetPos, Xpos, Ypos
GetKeyState, ShiftStatus, Shift
Pos:=Xpos+Ypos
if Pos=0
{
if ShiftStatus=U
WinMinimizeAll
Sleep,361
MouseGetPos, Xpos, Ypos
Pos:=Xpos+Ypos
if Pos=0
{
MouseMove, 20, 20,5
Menu,Tray,Show,5,5
}
}
Return
;----------------------------------------------------------------------------------------
ToggleSound: ; and also Tooltip Display
MenuItem:=A_ThisMenuItem
if MenuItem=Turn &Sound ON
{
Play_A_Wave_Sound=1
Menu, Tray, Rename,Turn &Sound ON,Turn &Sound OFF
}
if MenuItem=Turn &Sound OFF
{
Play_A_Wave_Sound=0
Menu, Tray, Rename,Turn &Sound OFF,Turn &Sound ON
}
if MenuItem=Turn Tooltip &Display OFF
{
DisplayTooltip=0
Menu, Tray, Rename,Turn Tooltip &Display OFF,Turn Tooltip &Display ON
EnvAdd,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display Time
}
if MenuItem=Turn Tooltip &Display ON
{
DisplayTooltip=1
Menu, Tray, Rename,Turn Tooltip &Display ON,Turn Tooltip &Display OFF
EnvSub,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display Time
}
return
;----------------------------------------------------------------------------------------
BackupScript:
BackupFolder=%A_ScriptDir%\Backup\
ifNotExist, %BackUpFolder%
FileCreateDir,%BackupFolder%
FormatTime,TimeStamp,,[yy-MM-dd] @ [H.mm.ss]
BackupFileName=%BackUpFolder%%TimeStamp% - %A_ScriptName%
FileCopy,%A_ScriptName%,%BAckupFileName%
If ! inUpdationMode
MsgBox,64,This Script [%A_ScriptName%] has been Archived,%BackupFileName%,10
Return
;----------------------------------------------------------------------------------------
ViewReadMe:
Run,Readme.Txt
return
;----------------------------------------------------------------------------------------
EditScript:
Edit,Auto-WPC.ahk
return
;----------------------------------------------------------------------------------------
ReloadScript:
Reload
return
;----------------------------------------------------------------------------------------
Exitt:
if Errors
Exitapp
if ChangeWallpaperOnExit
Run, i_view32.exe "%WallpaperOnExit%" /wall=%WallpaperSetType% /killmesoftly
FileDelete,RandList.TXT
ExitApp
Return
;----------------------------------------------------------------------------------------
;* - Script written by Goyyah [ arian.suresh@gmail.com ] |
|
|
| Back to top |
|
 |
rtcvb32
Joined: 17 Feb 2008 Posts: 289
|
Posted: Sun Aug 08, 2010 12:40 am Post subject: |
|
|
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.
| Code: |
#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 http://www.autohotkey.net/~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.
| Code: |
;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 http://www.autohotkey.net/~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
}
|
Last edited by rtcvb32 on Mon Aug 16, 2010 3:49 am; edited 1 time in total |
|
| Back to top |
|
 |
soggos
Joined: 27 Mar 2008 Posts: 129 Location: France
|
Posted: Thu Aug 12, 2010 2:08 pm Post subject: |
|
|
Oh SKAN you are good for us!
Thanks for this script...
i post here a way for verified if irfan is installed (with RegRead):
| Code: | ; =========================================================== %
IrfanView:
IfExist %A_ScriptDir%\IrfanView\i_view32.exe ; test si existe en local
{
IrfanView = %A_ScriptDir%\IrfanView\i_view32.exe
Return
}
; test si existe sur le PC
RegRead, IrfanView, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView, UninstallString
if ErrorLevel=1
{
MsgBox , 4160 , , IrfanView not installed!
IrfanView=
}
Else
{
SplitPath, IrfanView, , IrfanView
IrfanView = %IrfanView%\i_view32.exe
}
Return
; ============================================
|
in your script,
i have change all i_view32.exe by %IrfanView%
and make a gosub to label IrfanView: | Code: | FileCreationTime=20060106000003 ; The first three lines facilitates the updation of this
;script from my webpage.
WebLocation=http://www.geocities.com/venneye/Auto-WPC/ ;Do not alter or move it
#Persistent
;----------------------------------------------------------------------------------------
; Modify the Variable Values (to suit your needs)
;----------------------------------------------------------------------------------------
Duration=1 ; .1 to 60 Duration between Wallpaper Changes (In Mins)
ListFile=MyFavouriteImages.Txt ; File name of the Image List
WallpaperSetType=2 ; 0,1,2 0=Centered 1=Tiled 2=Stretched
SetRandomWallpaper=1 ; 0 or 1 0 to Disable
RepeatList=1 ; 0 or 1 0 to Disable
MinimizeAllWindows=1 ; 0 or 1 0 to Disable
;- While exiting this Script you can set a Wallpaper of your preference
ChangeWallpaperOnExit=1 ; 0 or 1 0 to Disable WallpaperOnExit
WallPaperOnExit=SomeImage.GIF ; Wallpaper to set when script exits
;-While Wallpaper is changed, sound will be played the filename is shown as Tooltip
DisplayTooltip=1 ; 0 or 1 0 to Disable
TooltipDisplayDuration=1000 ; 500-5000 in MilliSeconds
Play_A_Wave_Sound=1 ; 0 or 1 1 plays Clicking.Wav, 0 Mutes it
WaveFileName=Clicking.Wav ; The Default Wave File
;----------------------------------------------------------------------------------------
; Following Settings Influence Creation and Additions to "ListFile"
;----------------------------------------------------------------------------------------
ValidImageExtensions=|JPG|PNG|BMP|GIF| ; Leave this unmodified
RecurseSubFolders=1 ; 0 to Disable
MinJPGSize=100 ; in KiloBytes
MinBMPSize=1440 ; in KiloBytes
MinPNGSize=500 ; in KiloBytes
MinGIFSize=200 ; in KiloBytes
OverWriteMode=1 ; 0 to Disable
;----------------------------------------------------------------------------------------
; Alter following Hotkey-Labels as required, and remove the semi-colon in the beginning
;#Q::Menu,Tray,Show,5,5 ; Shows the "Tray Menu" on TOP-LEFT of Screen
;#Z::Gosub,Exitt ; Exit this Script
;#F5::Reload ; Reload This Script
#SingleInstance Ignore
CoordMode, Menu, Screen
CoordMode, Mouse, Screen
OnExit, Exitt
SetWorkingDir,%A_ScriptDir%
Gosub IrfanView
IfNotExist,%IrfanView% ; IrfanView Executable
{
L1=IrfanView Executable I_VIEW32.EXE is required for functioning of
L2=Script!..Download and install IrfanView and copy I_VIEW32.EXE to
MsgBox,16,Missing File: %A_ScriptDir%\I_VIEW32.EXE,%L1%`n%L2%`n`n%A_ScriptDir%\
Errors=1
GoSub,Exitt
}
IFExist,Auto-WPC.GIF ; When a new version of the script is Installed
{
Runwait, %IrfanView% "Auto-WPC.GIF" /wall=1 /killmesoftly
FileDelete,Auto-WPC.GIF
WinMinimizeAll
Sleep,5000
}
IfnotExist,%ListFile% ; The Image Listing File
{
Errors=1
GoSub,CreateListFile
}
GoSub,CheckVariables
SleepValue:=Duration
EnvMult,SleepValue,(60*1000) ; Convert Duration into MilliSeconds
Menu, Tray, NoStandard
Menu, Tray, Add,&Open %ListFile% in Editor,EditListFile
if OverWriteMode
Menu, Tray, Add,&Create a New %ListFile%,CreateListFile
else
Menu, Tray, Add,&Add Images to %ListFile%,CreateListFile
Menu, Tray, Add, ; ----------------------------------------------------------
if Play_A_Wave_Sound
Menu, Tray, Add,Turn &Sound OFF ,ToggleSound
else
Menu, Tray, Add,Turn &Sound ON,ToggleSound
If DisplayTooltip
Menu, Tray, Add,Turn Tooltip &Display OFF,ToggleSound
else
Menu, Tray, Add,Turn Tooltip &Display ON ,ToggleSound
Menu, Tray, Add, ; ----------------------------------------------------------
Menu, Tray, Add,&Visit the Webpage [www.geocities.com] ,OpenWebPage
Menu, Tray, Add,e-Mail &Goyyah [arian.suresh@gmail.com],MailtoAuthor
Menu, Tray, Add,Check for an &Update [%A_ScriptName%],CheckForUpdate
Menu, Tray, Add,Fetch my &External IP Address,GetExternalIP
Menu, Tray, Add, ; ----------------------------------------------------------
Menu, Tray, Add,Bac&kup a Copy of %A_ScriptName%,BackupScript
Menu, Tray, Add,View &Readme.Txt,ViewReadme
Menu, Tray, Add,E&xit Automatic Wallpaper Changer,Exitt
Menu, Tray, Default,E&xit Automatic Wallpaper Changer
Menu, Tray, Tip,Double-Click to Exit %A_ScriptName%
ifExist,Auto-WPC.ICO
Menu, Tray, Icon,Auto-WPC.ICO
If PopupTrayMenu
SetTimer, CheckMousePosition, 500
; Read "ListFile" one line at a time, Check whether the file exists, and append
; it to a variable named "Flist"
Flist:=
FirstLine=1
FileCount=0
Loop, Read,%ListFile%
{
ImageFile=%A_LoopReadLine%
ifexist,%ImageFile%
FileCount+=1
if FirstLine=1
{
Flist=%ImageFile%
FirstLine=0
}
else
Flist=%Flist%`n%ImageFile%
}
FileDelete,RandList.txt
If SetRandomWallPaper
Sort,FLIST,Random
FileAppend,%Flist%,RandList.Txt ; The Random list file is created
If WallPaperOnExit=
FileReadLine,WallPaperOnExit,RandList.TXT,1
;----------------------------------------------------------------------------------------
; // The Main Loop //
;----------------------------------------------------------------------------------------
LineNumber=1
Loop,
{
FileReadLine,ImageFileName,RandList.TXT,%LineNumber%
if DisplayTooltip
Tooltip, Changing Wallpaper to %ImageFileName%,30,30
if Play_A_Wave_Sound
Soundplay,%WaveFileName%
; IrfanView Steps in
Runwait, %IrfanView% "%ImageFileName%" /wall=%WallpaperSetType% /killmesoftly
if DisplayTooltip
{
Sleep,%TooltipDisplayDuration%
Tooltip
}
Sleep,%SleepValue%
LineNumber+=1
If LineNumber > %FileCount%
{
if ! Repeatlist
GoSub,Exitt
else
LineNumber=1
}
}
Return
;----------------------------------------------------------------------------------------
CheckVariables: ; and assign default values to erroneous values
if Duration < .1
Duration=.1
if Duration > 60
Duration=60
If ListFile=
ListFile=FileList.Txt
if (WallPaperSetType !=0 and WallPaperSetType !=1 and WallPaperSetType !=2)
WallpaperSetType=2
if (SetRandomWallpaper !=0 and SetRandomWallpaper !=1)
SetRandomWallpaper=1
if (RepeatList !=0 and RepeatList !=1)
RepeatList=1
if (PopupTrayMenu !=0 and PopupTrayMenu !=1)
PopupTrayMenu=1
IFNotExist,%WallPaperOnExit%
WallpaperOnExit=
if (ChangeWallpaperOnExit !=0 and ChangeWallpaperOnExit !=1)
ChangeWallpaperOnExit=1
if (DisplayTooltip !=0 and DisplayTooltip !=1)
DisplayTooltip=1
if (DisplayTooltipDuration <500 and DisplayTooltipDuration >5000)
DisplayTooltipDuration=2345
if DisplayTooltip
EnvSub,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display
if (RecurseSubFolders !=0 and RecurseSubFolders !=1)
RecurseSubFolders=1
Return
;----------------------------------------------------------------------------------------
CreateListFile:
WriteFile=%A_ScriptDir%\%ListFile%
FileSelectFolder,ImageFolder,*%A_ScriptDir%,3,Select a Folder Containing Images
if ImageFolder= ; The user pressed Escape in Select Folder Dialog
if Errors
Gosub,Exitt
else
reload
StringRight,LastChar,ImageFolder,1
if LastChar != \
ImageFolder=%ImageFolder%\*.*
else
ImageFolder=%ImageFolder%*.*
If OverWriteMode
FileRecycle,%WriteFile%
FirstLine=1
Loop,%ImageFolder%,0,%RecurseSubFolders%
{
ImageFile:=A_LoopFileLongPath
SplitPath,ImageFile,,,ImageExt,,
if ImageExt=
Continue
IfNotInString,ValidImageExtensions,%ImageExt%
{
Tooltip,Skipping: %ImageFile%
Continue
}
FileGetSize,FileSize,%ImageFile%,K
MinSize=Min%ImageExt%Size
MinImageSize:=%MinSize%
if FileSize < %MinImageSize%
{
Tooltip,Skipping: %ImageFile%
Continue
}
Tooltip,Adding: %ImageFile% %FileSize%
if FirstLine
{
FileAppend,%ImageFile%,%WriteFile%
FirstLine=0
}
else
FileAppend,`n%ImageFile%,%WriteFile%
Sleep,100
}
reload
Return
;----------------------------------------------------------------------------------------
EditListFile:
ToolTip,
RunWait,%ListFile%
Return
;----------------------------------------------------------------------------------------
GetExternalIP:
Tooltip,Resolving External IP Address,30,30
ExternalIP=0.0.0.0
TmpFile=IPAddress.TMP
UrlDownloadToFile,http://www.whatismyip.org/,%TmpFile%
FileReadLine,ExternalIP,%TmpFile%,1
FileDelete,%TmpFile%
Tooltip,
LastMenuItem = %A_ThisMenuItem%
if LastMenuItem=Fetch my &External IP Address
Msgbox,64,[Auto-WPC] External IP Address,External IP Address: %ExternalIP%
Return
;----------------------------------------------------------------------------------------
OpenWebPage:
URL=%WebLocation%index.htm
GoSub,GetExternalIP
if ExternalIP!=0.0.0.0
Run,%URL%
Return
;----------------------------------------------------------------------------------------
MailtoAuthor:
Run,mailto:arian.suresh@gmail.com?Subject=Re:Auto-WPC [%FileCreationTime%]
Return
;----------------------------------------------------------------------------------------
CheckForUpdate:
GoSub,GetExternalIP
if ExternalIP=0.0.0.0
Exit
DownloadFolder=%A_ScriptDir%\Download\
ifNotExist,%DownloadFolder%
FileCreateDir,%DownloadFolder%
FormatTime,TimeStamp,,[yy-MM-dd] @ [H.mm.ss]
DownloadFileName=%DownloadFolder%%TimeStamp% - %A_ScriptName%
URL=%WebLocation%\Auto-WPC.txt
URLDownloadToFile,%URL%,%DownloadFileName%
FileReadline,DL_Version,%DownloadFileName%,1
StringMid,DL_Version,DL_Version,18,14
if DL_Version > %FileCreationTime%
{
L1=The latest version of this script has been downloaded!
L2=Would like to replace this Script with the new one?
L3=Current %A_ScriptName% will be copied to BackUp\ folder.
MsgBox,36,Automatic Wallpaper Changer - Internet Update
,%L1%`n%L2%`n`n%L3%`n`nProceed?
ifMsgBox,Yes
{
inUpdationMode=1
GoSub,BackupScript
FileCopy,%DownloadFileName%,%A_ScriptFullPath%,1 ; Overwrites Current Script!
Readme=%A_ScriptDir%\Readme.txt
ReadmeURL=%Weblocation%readme/%DL_Version%.txt
URLDownloadToFile,%ReadmeURL%,%Readme%
ImageURL=%Weblocation%splash.gif
URLDownloadToFile,%ImageURL%,Auto-WPC.GIF
Reload
}
}
Return
;----------------------------------------------------------------------------------------
CheckMousePosition:
; When the Mouse is moved up to the TOP-LEFT corner, this routine Pop-up's the
; Tray Menu and minimizes all Visible Windows. Combined this with the Shift key
; Displays Tray Menu without Minimizing any Windows. Requires "PopupTrayMenu=1"
MouseGetPos, Xpos, Ypos
GetKeyState, ShiftStatus, Shift
Pos:=Xpos+Ypos
if Pos=0
{
if ShiftStatus=U
WinMinimizeAll
Sleep,361
MouseGetPos, Xpos, Ypos
Pos:=Xpos+Ypos
if Pos=0
{
MouseMove, 20, 20,5
Menu,Tray,Show,5,5
}
}
Return
;----------------------------------------------------------------------------------------
ToggleSound: ; and also Tooltip Display
MenuItem:=A_ThisMenuItem
if MenuItem=Turn &Sound ON
{
Play_A_Wave_Sound=1
Menu, Tray, Rename,Turn &Sound ON,Turn &Sound OFF
}
if MenuItem=Turn &Sound OFF
{
Play_A_Wave_Sound=0
Menu, Tray, Rename,Turn &Sound OFF,Turn &Sound ON
}
if MenuItem=Turn Tooltip &Display OFF
{
DisplayTooltip=0
Menu, Tray, Rename,Turn Tooltip &Display OFF,Turn Tooltip &Display ON
EnvAdd,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display Time
}
if MenuItem=Turn Tooltip &Display ON
{
DisplayTooltip=1
Menu, Tray, Rename,Turn Tooltip &Display ON,Turn Tooltip &Display OFF
EnvSub,SleepValue,%TooltipDisplayDuration% ; Adjusting Tooltip display Time
}
return
;----------------------------------------------------------------------------------------
BackupScript:
BackupFolder=%A_ScriptDir%\Backup\
ifNotExist, %BackUpFolder%
FileCreateDir,%BackupFolder%
FormatTime,TimeStamp,,[yy-MM-dd] @ [H.mm.ss]
BackupFileName=%BackUpFolder%%TimeStamp% - %A_ScriptName%
FileCopy,%A_ScriptName%,%BAckupFileName%
If ! inUpdationMode
MsgBox,64,This Script [%A_ScriptName%] has been Archived,%BackupFileName%,10
Return
;----------------------------------------------------------------------------------------
ViewReadMe:
Run,Readme.Txt
return
;----------------------------------------------------------------------------------------
Exitt:
if Errors
Exitapp
if ChangeWallpaperOnExit
Run, %IrfanView% "%WallpaperOnExit%" /wall=%WallpaperSetType% /killmesoftly
FileDelete,RandList.TXT
ExitApp
Return
;----------------------------------------------------------------------------------------
; § ; =========================================================== %
IrfanView:
IfExist %A_ScriptDir%\i_view32.exe ; test si existe en local
{
IrfanView = %A_ScriptDir%\i_view32.exe
Return
}
; test si existe sur le PC
RegRead, IrfanView, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView, UninstallString
if ErrorLevel=1
{
; MsgBox , 4160 , , IrfanView is not installed!
; IrfanView=
}
Else
{
SplitPath, IrfanView, , IrfanView
IrfanView = %IrfanView%\i_view32.exe
}
Return
; ============================================
; - Script written by Goyyah [ arian.suresh@gmail.com ] |
_________________ with ahk, all is different!...<img> |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Thu Aug 12, 2010 7:55 pm Post subject: |
|
|
This was the second script I posted..
 |
|
| Back to top |
|
 |
rtcvb32
Joined: 17 Feb 2008 Posts: 289
|
Posted: Sat Aug 14, 2010 8:02 am Post subject: |
|
|
| SKAN wrote: | This was the second script I posted..
 |
Seems it has a certain level of popularity.
I've continued working on the script the last few days; mostly updating some options for timing, and Word-Wrap that i see on my computer for some reason. Should i bother posting the updated version?
It's backwards compatible with the ini file, and the changes let you change from minutes, all the way to 1/100th of a second time periods. If you change what kind of time frame you wanted to use, the saved data in the ini-file automatically uses the old settings until you update them with the new ones. I just hope i haven't introduced new bugs. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|