 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SKAN
Joined: 26 Dec 2005 Posts: 5895
|
Posted: Mon Jan 09, 2006 11: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
 _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Jan 09, 2006 2: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: 5895
|
Posted: Mon Jan 09, 2006 2: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 _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
TheLeO
Joined: 11 Jun 2005 Posts: 165 Location: England ish
|
Posted: Wed Jan 11, 2006 9: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.  _________________ And i say: where there is a problem , there is a solution.(well some where that is.)
::
I Have Spoken
:: |
|
| Back to top |
|
 |
quatermass
Joined: 14 Dec 2005 Posts: 114
|
Posted: Wed Feb 15, 2006 12:25 pm 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: 14
|
Posted: Tue Aug 14, 2007 6: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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|