mexykanu Posted February 8, 2009 Share Posted February 8, 2009 (edited) Hi,This is my first published script so here goes.WallpaperCycle - changes your wallpaper once every X minutes with pictures in a specific folder.It is controllable only by the Tray icon (click or right-click) and reads its startup settings from a .ini file.Credits (some includes were found on this forum) : 1. _ReduceMemory by wOuter2. _ChangeDestopWallpaper by FlyingBozCurrent features:- You can choose any folder which contains at least one .JPG / .BMP / .PNG file.- You can set the time each wallpaper is displayed (a maximum of 99 minutes)- You can set how the wallpaper are displayed (centered, stretched or tiled)- The program has a "autostart" feature - it can start every time Windows starts.- Memory usage optimizationTotal time spent: about 20-24 hours.Compiled size: 401 KB (including .ini file)RAM used at startup: 900 KBMaximum used RAM: 2000 KBI'm open for suggestions/improvements/bugs so please don't hesitate to post.Thanks,mexykanu.edit: Removed source since it's not mandatorywallpaper_cycle.rar Edited February 9, 2009 by mexykanu Link to comment Share on other sites More sharing options...
UEZ Posted February 8, 2009 Share Posted February 8, 2009 Works fine on Vista x32! One suggestion: wallpaper change duration in seconds instead of minutes. Good job! Thanks, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
mexykanu Posted February 9, 2009 Author Share Posted February 9, 2009 Thanks for the feedback Link to comment Share on other sites More sharing options...
James Posted February 9, 2009 Share Posted February 9, 2009 If you're good with GDI, you should do what Apple macs do and fade the wallpaper. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
mexykanu Posted February 9, 2009 Author Share Posted February 9, 2009 I don't really understand what you mean Could you provide a video or something like a sample ? Link to comment Share on other sites More sharing options...
jerem488 Posted February 9, 2009 Share Posted February 9, 2009 Could you put the script file ? Also, good job thank you Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
mexykanu Posted February 9, 2009 Author Share Posted February 9, 2009 What do you need exactly ? I guess i could help you with a thing or two Link to comment Share on other sites More sharing options...
jerem488 Posted February 11, 2009 Share Posted February 11, 2009 What do you need exactly ? I guess i could help you with a thing or twoHow do you do to refresh the desktop ?I think you call a dll... But why ? Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
mexykanu Posted February 11, 2009 Author Share Posted February 11, 2009 The program doesn't refresh the Desktop. The flickering icons are somewhat of a bug which resulted from changing the wallpaper. If it helps i can give you the respective code. Cheers Link to comment Share on other sites More sharing options...
jerem488 Posted February 11, 2009 Share Posted February 11, 2009 Yes ! it would be nice! Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
mexykanu Posted February 11, 2009 Author Share Posted February 11, 2009 herechange_wallpaper.au3 Link to comment Share on other sites More sharing options...
JasonDW Posted November 3, 2009 Share Posted November 3, 2009 mexykanu, I have been using your script recently and have a few comments: - when the computer starts I get a dialog box requesting me to choose the init.ini file. Am I doing something wrong? It would be good if it would automatically choose the init.ini file. - the windows xp options are limited for sizing the pictures i.e. tile, centered, stretched. However, none of those is real useful when the pictures are bigger than your desktop ... stretched distorts the picture, centered doesn't help and neither does tiled. It would be good to have the option to have the program resize the image before setting it as the desktop. Below is an edit of a script originally written by n3nE that I edited for my digital photo frame. You would need to find out the resolution of screen first then pass that as the width and height. The centered / tiled / stretched is probably the biggest killer for me since all my photos are high res and my laptop screens are not. Other than that the script runs well, uses minimal resources and looks good in the taskbar...good work. expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name...........: _ImageResize ; Description ...: Resizes image to values as given and saves to $sOutImage ; Syntax.........: _ImageResize($sInImage, $sOutImage, $iW = -1, $iH = -1, $bPreserveAR = True, $bStretch = False, $bUseExtensions = False) ; Parameters ....: $sInImage - Full path and filename of the image to be resized ; $sOutImage - Full path and filename of the file to save to ; $iW - Width in pixels (optional - Will default to $sInImage width) ; $iH - Height in pixels (optional - Will default to $sInImage height) ; $bPreserveAR - Boolean, True to preserve aspect ratio, False to not (optional - Default True) ; $bStretch - Boolean, True increases small images to fit, False does not (optional - Default False) ; $bUseExtensions - Boolean, Indicates whether to use the extensions list or not (optional - Default False) ; Return values .: Success - Returns a 1 ; Failure - Returns a 0 ; @Error - 0 = No error. ; |1 = Input file does not exist ; |2 = Not a recognized image format ; |3 = No resize performed ; Author ........: Original from n3nE ; Edited by JasonLA ; Modified.......: 04/06/2009 ; Remarks .......: This function assumes that if a H and W are inputted then the user does not want an image bigger than either of ; those numbers. Aspect Ratio and Stretch are taken into account if required however the image will never be bigger ; in either dimension than what was requested. ; Related .......: ; Link ..........; ; Enhancements ..; add option to use a specify a ratio based resize eg. 0.5 would be half original size, 2.0 would be twice original etc. ; add more file extensions ; add ability to pass file extension array to function ; add check that $sOutImage can be written to ; =============================================================================================================================== Func _ImageResize($sInImage, $sOutImage, $iW = -1, $iH = -1, $bPreserveAR = True, $bStretch = False, $bUseExtensions = False) Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0 Local $sOF, $Ext, $vAspectR Local $tPath, $tDir Local $aImageExtensions Dim $aImageExtensions[4] = ["jpg", "tif", "jpeg", "bmp", "png"] _ArraySort($aImageExtensions) ;~ Process Defaults If $iW = Default Then $iW = -1 If $iH = Default Then $iH = -1 ;~ must use "==" below because False = Default resolves to TRUE..this causes errors in this code. If $bPreserveAR == Default Then $bPreserveAR = True If $bStretch == Default Then $bStretch = False If $bUseExtensions == Default Then $bUseExtensions = False ;~ check input image exists If Not FileExists($sInImage) Then Return SetError(1, 0, 0) ;~ extract image name and extension $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1)) $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1) ;~ check file extension If $bUseExtensions Then If _ArrayBinarySearch($aImageExtensions, StringLower($Ext)) = -1 Then Return SetError(2, 0, 0) EndIf ;~ start GDI plus to get aspect ratio _GDIPlus_Startup() $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage) ;~ find current aspect ratio (using width / height) $iActW = _GDIPlus_ImageGetWidth($hImage2) $iActH = _GDIPlus_ImageGetHeight($hImage2) $vAspectR = $iActW / $iActH ;~ populate values if defaults used. Use "<0" to capture incorrect size entries. If $iH < 0 And $iW < 0 Then $iH = $iActH $iW = $iActW ElseIf $iH < 0 Then $iH = $iW / $vAspectR ElseIf $iW < 0 Then $iW = $iH * $vAspectR EndIf ;~ process all options and combinations (36 in total) If $bPreserveAR = True And (($iActW >= $iW Or $iActH >= $iH) Or ($iActW <= $iW And $iActH <= $iH And $bStretch = True)) Then ;~ captures the following cases (17) ;~ $iActW > $iW, $iActH > $iH, $bPreserveAR = True, $bStretch = True ; reduce to largest image that will fit in H and W with Aspect Ratio (see remarks) ;~ $iActW > $iW, $iActH > $iH, $bPreserveAR = True, $bStretch = False ; reduce to largest image that will fit in H and W with Aspect Ratio (see remarks) ;~ $iActW = $iW, $iActH > $iH, $bPreserveAR = True, $bStretch = True ; reduce to largest image that will fit in H and W with Aspect Ratio (see remarks) ;~ $iActW = $iW, $iActH > $iH, $bPreserveAR = True, $bStretch = False ; reduce to largest image that will fit in H and W with Aspect Ratio (see remarks) ;~ $iActW > $iW, $iActH = $iH, $bPreserveAR = True, $bStretch = True ; reduce to largest image that will fit in H and W with Aspect Ratio (see remarks) ;~ $iActW > $iW, $iActH = $iH, $bPreserveAR = True, $bStretch = False ; reduce to largest image that will fit in H and W with Aspect Ratio (see remarks) ;~ $iActW > $iW, $iActH < $iH, $bPreserveAR = True, $bStretch = True ; reduce W to max, calc H with Aspect Ratio ;~ $iActW > $iW, $iActH < $iH, $bPreserveAR = True, $bStretch = False ; reduce W to max, calc H with Aspect Ratio ;~ $iActW < $iW, $iActH > $iH, $bPreserveAR = True, $bStretch = True ; reduce H to max, calc W with Aspect Ratio ;~ $iActW < $iW, $iActH > $iH, $bPreserveAR = True, $bStretch = False ; reduce H to max, calc W with Aspect Ratio ;~ $iActW = $iW, $iActH < $iH, $bPreserveAR = True, $bStretch = True ; no resize due to Aspect Ratio constraint, $iW = $iActW and $iH = $iActH ;~ $iActW = $iW, $iActH < $iH, $bPreserveAR = True, $bStretch = False ; no resize due to Aspect Ratio constraint, $iW = $iActW and $iH = $iActH ;~ $iActW < $iW, $iActH = $iH, $bPreserveAR = True, $bStretch = True ; no resize due to Aspect Ratio constraint, $iW = $iActW and $iH = $iActH ;~ $iActW < $iW, $iActH = $iH, $bPreserveAR = True, $bStretch = False ; no resize due to Aspect Ratio constraint, $iW = $iActW and $iH = $iActH ;~ $iActW = $iW, $iActH = $iH, $bPreserveAR = True, $bStretch = True ; don't need to capture this here but it does anyway, no resize required ;~ $iActW = $iW, $iActH = $iH, $bPreserveAR = True, $bStretch = False ; don't need to capture this here but it does anyway, no resize required ;~ $iActW < $iW, $iActH < $iH, $bPreserveAR = True, $bStretch = True ; increase to largest image that will fit in H and W with Aspect Ratio (see remarks) If $iH * $vAspectR <= $iW Then $iW = $iH * $vAspectR Else $iH = $iW / $vAspectR EndIf ElseIf $bPreserveAR = False And (($bStretch = True And ($iActW <= $iW Or $iActH <= $iH)) Or ($iActW >= $iW And $iActH >= $iH)) Then ;~ for all cases below since aspect ratio is false the image will be resized to requested amount and potentially deformed ;~ no action required $iW = $iW and $iH = $iH ;~ captures the following cases (13) ;~ $iActW < $iW, $iActH < $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW > $iW, $iActH > $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW > $iW, $iActH > $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW > $iW, $iActH < $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW < $iW, $iActH > $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW = $iW, $iActH < $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW < $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW = $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW = $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW = $iW, $iActH > $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW = $iW, $iActH > $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW > $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = True ;~ $iActW > $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = False ElseIf $bStretch = False And ($iActW <= $iW And $iActH <= $iH) Then ;~ all cases below no resize is available because stretch is false and the original has all dimensions smaller than or equal to the request. ;~ captures the following cases (4) ;~ $iActW < $iW, $iActH < $iH, $bPreserveAR = True, $bStretch = False ;~ $iActW < $iW, $iActH < $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW < $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW = $iW, $iActH < $iH, $bPreserveAR = False, $bStretch = False ;~ these cases are captured earlier but also make the above true ;~ $iActW = $iW, $iActH < $iH, $bPreserveAR = True, $bStretch = False ;~ $iActW < $iW, $iActH = $iH, $bPreserveAR = True, $bStretch = False ;~ $iActW = $iW, $iActH = $iH, $bPreserveAR = True, $bStretch = False $iH = $iActH $iW = $iActW ElseIf $bStretch = False And $bPreserveAR = False Then ;~ captures the following cases (2) ;~ $iActW < $iW, $iActH > $iH, $bPreserveAR = False, $bStretch = False ; resize to requested H and original W ;~ $iActW > $iW, $iActH < $iH, $bPreserveAR = False, $bStretch = False ; resize to requested W and original H ;~ these cases are captured earlier but also make the above true ;~ $iActW < $iW, $iActH < $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW < $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW = $iW, $iActH < $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW > $iW, $iActH > $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW = $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW = $iW, $iActH > $iH, $bPreserveAR = False, $bStretch = False ;~ $iActW > $iW, $iActH = $iH, $bPreserveAR = False, $bStretch = False If $iActW < $iW Then $iW = $iActW ElseIf $iActH < $iH Then $iH = $iActH EndIf EndIf If Not ($iW = $iActW And $iH = $iActH) Then ; resize picture $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDC) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH) $CLSID = _GDIPlus_EncodersGetCLSID($Ext) _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID) _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() Return SetError(0, 0, 1) EndIf _GDIPlus_Shutdown() Return SetError(3, 0, 0) EndFunc ;==>_ImageResize Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now