Jump to content

Recommended Posts

I made this script after a by an user that want some kind of script for charity purpose ( i really hope o:) ), by the way very good idea this can be helpfull to publicize charity organization or local store ;).

With Wallpaper Changer you can dinamically change your windows wallpaper without any trouble.

You can also download your wallpaper from your own website and restribuite it to all the people that will use your software. PLEASE if you use this script on commercial software publicize autoit and why not a local charity organization.

Changelog

;=====================================================
v.1.2.0 (08/05/2013)
Added new style ;Thanks to GreenCan
Added image autoresize if the image has a higher resolution the the screen
Added new option to _ImageSaveToBMP
Fixed convert the image to bmp only when it is necessary

;=====================================================
v.1.1.0 (07/05/2013)
Fixed Inetclose causes crash under some circumstances
Fixed Some code cleanup
Added New Style ;Thanks GreenCan for the documentation
Added Support to 'gif', 'jpeg', 'jpg', 'png', 'tiff' format
Added php code completely rewritten

;=====================================================
v.1.0.1 (06/05/2013)
Fixed Some code cleanup

;=====================================================
v.1.0.0 (06/05/2013)
Initial Release

The .php file has been tested on Xamp with php 5.3.8, you need PHP 4 >= 4.3.0, PHP 5 to run the script.

You have to put the .php in the same directory where the wallpaper are stored on your server. After that you have to set in the autoit script the variable:

; #INDEX# =======================================================================================================================
; Title .........: Wallpaper Changer v.1.2.0
; AutoIt Version : v3.3.8.1
; Description ...: A little program to dinamically change your wallpapers
; Author(s) .....: Nessie
; ===============================================================================================================================
#include <GDIPlus.au3>

#region Settings
$iWait = 2000 ;Change the background every 50 seconds
$iLoop = -1 ;The number of changing wallpaper loop, set -1 to infinite loop
$sWallpapersPath = @ScriptDir & "\Wallpapers\" ;Remember to put the "\" at the end!
$bOnline = False ;Set to True if you want to download the wallpapers from your website, otherwise set this value to False
$sURL = "http://127.0.0.1/TEST/wallpaper.php" ;The url where the .php script is stored !!WARNING!! You have to put this .php in the same directory where the wallpapers are stored
$bRestoreWallpaper = True ;Set to True if you want to restore the original wallpaper at the script exit, otherwise set this value to False
$iWallStyle = 2 ;Default wallpaper style, for more info see _ChangeWallpaper header
$bAutoResize = True ;Autosize the wallpaper, if it have a higher resolution than screen. (Only for Vista and later!)
#endregion Settings

OnAutoItExitRegister("_Terminate")
HotKeySet(("^!e"), "_Terminate") ;CTRL+ALT+E to terminate the process.

If $bRestoreWallpaper Then
    Global $sTileWallPaper = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallPaper")
    Global $sWallpaperStyle = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle")
    Global $sOriginalWallpaper = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper")
EndIf

If Not FileExists($sWallpapersPath) Then
    MsgBox(16, "Error", "This path: " & $sWallpapersPath & " doesn't exist.")
    Exit
EndIf

If $bOnline Then

    $sSource = BinaryToString(InetRead($sURL, 1))
    If @error Then
        MsgBox(16, "Error", "Unable to download the source of the page.")
        Exit
    EndIf

    $aImageNames = StringRegExp($sSource, "<tr>(.*?)</tr>", 3)
    If @error Then
        MsgBox(16, "Error", "Unable to grab the images name.")
        Exit
    EndIf

    $aRegex = StringRegExp($sURL, "(.+/)", 3) ;Retrive the path where the images are stored, in this example http://127.0.0.1/b/Wallpaper/
    If @error Then
        MsgBox(16, "Error", "Unable to grab the images path.")
        Exit
    EndIf

    $sURL_ImagePath = $aRegex[0]

    For $i = 0 To UBound($aImageNames) - 1
        ;Convert all the image name to .bmp format, to check if the converted images is already store on the user pc
        $sImageName = StringRegExpReplace($aImageNames[$i], "(.*)\..*$", "$1.bmp") ;If image name already .bmp don't touch it, already change extension

        If FileExists($sWallpapersPath & $sImageName) Then ;The .bmp image equivalent already exist, we don't need to re-download the original file images
            ContinueLoop
        EndIf

        Local $hDownload = InetGet($sURL_ImagePath & $aImageNames[$i], $sWallpapersPath & $aImageNames[$i])
        If @error Then ContinueLoop
        InetClose($hDownload)
    Next

EndIf

$search = FileFindFirstFile($sWallpapersPath & "*.*") ;We do that so we can grab all .bmp even if they are not in the website page, so the user can run custom wallpaper too
If $search = -1 Then
    MsgBox(0, "Error", "I can't find any images.")
    Exit
EndIf

$iCount = -1
$iDimension = 10
Local $aWallpapers[$iDimension]

While 1
    Local $file = FileFindNextFile($search)
    If @error Then ExitLoop

    $sFileExt = StringLower(StringRight($file, 4))

    If $sFileExt <> '.bmp' And _GetWinVersion() < 6.0 Then
        $file = _ImageSaveToBMP($sWallpapersPath & $file, $sWallpapersPath, Default, False, True)
        If @error Then ContinueLoop
    Else
        If _GetWinVersion() >= 6.0 And $sFileExt <> '.bmp' And $sFileExt <> '.jpg' Then
            $file = _ImageSaveToBMP($sWallpapersPath & $file, $sWallpapersPath, Default, False, True)
            If @error Then ContinueLoop
        EndIf
    EndIf

    $iCount += 1

    If $iCount > $iDimension - 1 Then
        $iDimension += 10
        ReDim $aWallpapers[$iDimension]
    EndIf

    $aWallpapers[$iCount] = $sWallpapersPath & $file
WEnd
FileClose($search)

ReDim $aWallpapers[$iCount + 1]

$i = 0

While 1 = 1
    If $iLoop > -1 Then
        If $i > $iLoop Then
            ExitLoop
        EndIf
        $i += 1
    EndIf

    For $x = 0 To UBound($aWallpapers) - 1
        _ChangeWallpaper($aWallpapers[$x], $iWallStyle, $bAutoResize)
        If @error Then
            MsgBox(16, "Error", "Unable to change the wallpaper.")
            Exit
        EndIf
        Sleep($iWait)
    Next
WEnd


; #FUNCTION# ====================================================================================================================
; Name...........: _ChangeWallpaper
; Description ...: Change Windows Wallpaper
; Syntax.........: _ChangeWallpaper($sImage, [$iStyle])
; Parameters ....: $sImage   - The path of the .bmp file
;                   $$iStyle  - The numeric value of desidered style
;                              0 Tiled
;                              1 Centered
;                              2 Stretched
;                              3 Fit (Windows 7 and later)
;                              4 Fill (Windows 7 and later)
;                               5 Screen Width
;                   $bResize   - Automatically resize th image if has a higher resolution than screen
; Return values .: On Success - Return the new file name.
;                  On Failure -
;                               @error = 1 The image doesn't exist
;                               @error = 2 The image is not a .bmp file
;                               @error = 3 Invalid style
;                               @error = 4 Style not supported by OS
;                               @error = 5 Unable to change the wallpaper
; Author ........: Nessie
; ===============================================================================================================================

Func _ChangeWallpaper($sImage, $iStyle = 0, $bResize = True)
    If Not FileExists($sImage) Then Return SetError(1, 0, "")

    Local $sImageExt = StringLower(StringRight($sImage, 4))

    Local $fWinVer = _GetWinVersion()

    If $sImageExt <> '.bmp' And $fWinVer < 6.0 Then
        Return SetError(2, 0, "")
    Else
        If $fWinVer >= 6.0 And $sImageExt <> '.bmp' And $sImageExt <> '.jpg' Then
            Return SetError(2, 0, "")
        EndIf
    EndIf

    If $iStyle < 0 Or $iStyle > 5 Then Return SetError(3, 0, "")

    If $fWinVer < 6.0 Then ; More info http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832%28v=vs.85%29.aspx
        If $iStyle > 2 Then Return SetError(4, 0, "")
    EndIf

    Local $sWallpaperKey = "HKEY_CURRENT_USER\Control Panel\Desktop"

    Local $iTileWallPaper, $iWallpaperStyle

    If $bResize And $fWinVer >= 6.0 Then
        $aImageSize = _ImageGetSize($sImage)
        If @error Then Return SetError(5, 0, "")

        If $aImageSize[0] > @DesktopWidth Or $aImageSize[1] > @DesktopHeight Then
            $iStyle = 5 ;Force style n°5
        EndIf
    EndIf

    Switch $iStyle
        Case 0
            $iTileWallPaper = 1
            $iWallpaperStyle = 0
        Case 1
            $iTileWallPaper = 0
            $iWallpaperStyle = 0
        Case 2
            $iTileWallPaper = 0
            $iWallpaperStyle = 2
        Case 3
            $iTileWallPaper = 0
            $iWallpaperStyle = 6
        Case 4
            $iTileWallPaper = 0
            $iWallpaperStyle = 10
        Case 5
            $iTileWallPaper = 0
            $iWallpaperStyle = 4
    EndSwitch

    RegWrite($sWallpaperKey, "TileWallPaper", "REG_SZ", $iTileWallPaper)
    If @error Then Return SetError(5, 0, "")
    RegWrite($sWallpaperKey, "WallpaperStyle", "REG_SZ", $iWallpaperStyle)
    If @error Then Return SetError(5, 0, "")

    ;Thanks to guinness for his advice
    ; Idea from here: http://www.autoitscript.com/forum/topic/19370-autoit-wrappers/page__st__280#entry652536
    ; $SPI_SETDESKWALLPAPER, $SPIF_UPDATEINIFILE and $SPIF_SENDCHANGE can be found on APIConstants.au3 included on WinAPIEx by Yashied
    ;Return _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, DllStructGetPtr($tBuffer), BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
    Local $tBuffer = DllStructCreate('wchar Text[' & StringLen($sImage) + 1 & ']')
    DllStructSetData($tBuffer, 'Text', $sImage)
    Return _WinAPI_SystemParametersInfo(0x0014, 0, DllStructGetPtr($tBuffer), BitOR(0x0001, 0x0002))
    If @error Then Return SetError(5, 0, "")

    Return True
EndFunc   ;==>_ChangeWallpaper

; #FUNCTION# ====================================================================================================================
; Name ..........: _ImageSaveToBMP
; Description ...: Convert an image to bmp format
; Syntax ........: _ImageSaveToBMP($sPath[, $sDestPath = @ScriptDir[, $sName = Default[, $bOverwrite = False[, $bDelOrig = False]]]])
; Parameters ....: $sPath               - A string value.
;                  $sDestPath           - The path where to save the converted image. Default is @ScriptDir.
;                  $sName               - The name of the converted image. Default is the original photo name.
;                  $bOverwrite          - Overwrite the converted file if already exist. Default is False.
;                  $bDelOrig            - Delete the original file after conversion. Default is False.
; Return values .: On Success - Return the new file names
;                  On Failure -
;                               @error = 1 The file to be converted doesn't not exist
;                               @error = 2 The image is already a bmp file
;                               @error = 3 Invalid file extension
;                               @error = 4 The destination path doesn't not exist
;                               @error = 5 Invalid file name
;                               @error = 6 The destination file already exist
;                               @error = 7 Unable to overwrite the destination file
;                               @error = 8 Unable to save the bmp file
; Author ........: Nessie
; Example .......: _ImageSaveToBMP(@DesktopDir & "\nessie.jpg")
; ===============================================================================================================================
Func _ImageSaveToBMP($sPath, $sDestPath = @ScriptDir, $sName = Default, $bOverwrite = False, $bDelOrig = False)
    Local $bCheckExt = False

    If Not FileExists($sPath) Then Return SetError(1, 0, "")

    Local $sImageExt = StringLower(StringTrimLeft($sPath, StringInStr($sPath, '.', 0, -1)))

    If $sImageExt = "bmp" Then SetError(2, 0, "")

    Local $aAllowedExt[5] = ['gif', 'jpeg', 'jpg', 'png', 'tiff']

    For $i = 0 To UBound($aAllowedExt) - 1
        If $sImageExt = $aAllowedExt[$i] Then
            $bCheckExt = True
            ExitLoop
        EndIf
    Next

    If $bCheckExt = False Then Return SetError(3, 0, "")

    If Not FileExists($sDestPath) Then Return SetError(4, 0, "")

    If $sName = Default Then
        $sName = StringTrimLeft($sPath, StringInStr($sPath, '\', 0, -1))
        $sName = StringTrimRight($sName, 4)
    Else
        If $sName = "" Then Return SetError(5, 0, "")
    EndIf

    If Not $bOverwrite Then
        If FileExists($sDestPath & "\" & $sName & ".bmp") Then
            Return SetError(6, 0, "")
        EndIf
    Else
        FileDelete($sDestPath & "\" & $sName & ".bmp")
        If @error Then
            Return SetError(7, 0, "")
        EndIf
    EndIf

    _GDIPlus_Startup()

    Local $hImage = _GDIPlus_ImageLoadFromFile($sPath)
    Local $sCLSID = _GDIPlus_EncodersGetCLSID("BMP")

    _GDIPlus_ImageSaveToFileEx($hImage, $sDestPath & "\" & $sName & ".bmp", $sCLSID)

    If @error Then
        _GDIPlus_Shutdown()
        Return SetError(8, 0, "")
    EndIf

    _GDIPlus_Shutdown()

    If $bDelOrig Then
        FileDelete($sPath)
        If @error Then Return SetError(8, 0, "")
    EndIf

    Return $sName & ".bmp"
EndFunc   ;==>_ImageSaveToBMP

; #FUNCTION# ====================================================================================================================
; Name ..........: _ImageGetSize
; Description ...: Retive the size of an image (Width & Height)
; Syntax ........: _ImageGetSize($sImage)
; Parameters ....: $sImage              - The path of the image.
; Return values .: Return an array with the image size
;                  On Success -
;                               $array[0] = Image Width
;                               $array[1] = Image Height
;                  On Failure -
;                               @error = 1 The file doesn't exist
;                               @error = 2 Unable to load the image
;                               @error = 3 Unable to get the image Width
;                               @error = 4 Unable to get the image Height
; Author ........: Nessie
; Example .......: _ImageGetSize("C:\Nessie.jpg")
; ===============================================================================================================================
Func _ImageGetSize($sImage)
    Local $aResult[2]

    If Not FileExists($sImage) Then Return SetError(1, 0, "")

    _GDIPlus_Startup()

    Local $hImage = _GDIPlus_ImageLoadFromFile($sImage)
    If @error Then Return SetError(2, 0, "")

    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    If @error Then Return SetError(3, 0, "")

    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    If @error Then Return SetError(4, 0, "")

    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

    $aResult[0] = $iWidth
    $aResult[1] = $iHeight

    Return $aResult
EndFunc   ;==>_ImageGetSize

Func _GetWinVersion()
    Local $sRet = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\', 'CurrentVersion')
    If @error Then Return SetError(0, 0, "")

    Return $sRet
EndFunc   ;==>_GetWinVersion

Func _Terminate()
    If $bRestoreWallpaper Then
        RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallPaper", $sTileWallPaper)
        RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", $sWallpaperStyle)
        DllCall("user32.dll", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sOriginalWallpaper, "int", BitOR(1, 2))
    EndIf

    Exit
EndFunc   ;==>_Terminate

And this is the source for the php script that you can upload on your own server to redistribuite your wallpaper.

<?php
/*
Wallpaper List
Author: Nessie
Description : A php script to implement with Wallpaper Changer.
Visit http://www.autoitscript.com/forum/topic/150597-wallpaper-changer/ for more info
*/
?>
<html>
<head>
<title>Wallpaper List powered by Nessie</title>
</head>
<body>
<?php
$root_dir = "./";
$search = scandir($root_dir);
$aAllowedExt = array("bmp","gif","jpeg","jpg","png","tiff");

foreach ($search as $images) {
     $filepath = $root_dir.'/'.$images;

     if(is_file($filepath)) {
          $ext = strtolower(substr($images, strrpos($images, '.')+1));

          if (in_array($ext,$aAllowedExt)) {
               echo "<tr>" . $images . "</tr><br>";
          }
     }
}
?>
</body>
</html>

Previous download: 20

Wallpaper Changer v.1.2.0.rar

Edited by Nessie

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

Very good! :D

Welcome to the club of Wallpaper Changing Program Makers. :dance:

We've had plenty of members join over the years (me included) .... probably only the second most popular script here, after Copy With Progress ... though yours is the first I've noticed in a while. :huh2:

I must get around to updating mine one day .... to the latest version of AutoIt, plus remove the necessity of Irfan View for Jpegs.

Mine is still the only one I know, that gives you the ability to set a specific image for a specific date (i.e. birthdays, Christmas, etc).

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

A couple of points for possible fixes?

  • Usage of Dim
  • Local keyword in a loop
  • If $fReturn Then is slightly optimised than If $fReturn = True Then

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Just released a new version with some code cleanup thanks to guinness advice. Please can tell to me on which OS have you tested this script? So i can remove the warning on the first post, as i haven't had yet a chance to try on systems other than Windows XP ;)

@TheSaint

Thanks for the compliment ;) I will certainly give a look at your script, funny is the ability to set a specific image for a specific date. Mine was specifically made for that user, mainly with the goal to download the wallpaper from a website and spread to all the user that use the script (i see a very good idea to advertice local store and charity organization).

Hi!

Edited by Nessie

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

Nessie

It works but i am a bit less enthusiastic than The Saint

I see 2 issues:

1. Why only bmp? bmp formats take much more diskspace than .jpg

Your _ChangeWallpaper() function looks like a revamp of FlyingBoz's _ChangeDesktopWallpaper() but is less good, exactly because your function does not handle other formats than .bmp.

2. If the bitmap is larger than the screen resolution, you compress the bitmap and it does not look good, the reason is that style 4 (screen width) is omitted. That was also the case in FlyingBoz's udf so I corrected it (yes, I wrote my own background changer :) )

Here is the modified udf

;===============================================================================
;
; Function Name: _ChangeDesktopWallpaper
; Description: Update WallPaper Settings
; Usage: _ChangeDesktopWallpaper(@WindowsDir & '\' & 'zapotec.bmp',1)
; Parameter(s): $bmp - Full Path to BitMap File (*.bmp)
; [$style] - 0 = Centered, 1 = Tiled, 2 = Stretched, 4 = Screen Width
; Requirement(s): None.
; Return Value(s): On Success - Returns 0
; On Failure - -1
; Author(s): FlyingBoz
; Revised by: Greencan, added Style 4
;Thanks: Larry - DllCall Example - Tested and Working under XPHome and W2K Pro
; Excalibur - Reawakening my interest in Getting This done.
;
;===============================================================================
Func _ChangeDestopWallpaper($bmp, $style = 0)
If Not FileExists($bmp) Then Return -1
;The $SPI* values could be defined elsewhere via #include - if you conflict,
; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic
Local $SPI_SETDESKWALLPAPER = 20
Local $SPIF_UPDATEINIFILE = 1
Local $SPIF_SENDCHANGE = 2
Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"
if $style = 1 then
RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1)
RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)
Else
RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style)
EndIf


DllCall("user32.dll", "int", "SystemParametersInfo", _
"int", $SPI_SETDESKWALLPAPER, _
"int", 0, _
"str", $bmp, _
"int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
Return 0
EndFunc ;==>_ChangeDestopWallpaper

To use screen width, verify if the width of the bitmap is larger than @DesktopWidth or height is larger than @DesktopHeight and if one of both conditions are met:

_ChangeDestopWallpaper($sWallpaper, 4) ; screen width

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

Nessie

It works but i am a bit less enthusiastic than The Saint

I see 2 issues:

1. Why only bmp? bmp formats take much more diskspace than .jpg

Your _ChangeWallpaper() function looks like a revamp of FlyingBoz's _ChangeDesktopWallpaper() but is less good, exactly because your function does not handle other formats than .bmp.

2. If the bitmap is larger than the screen resolution, you compress the bitmap and it does not look good, the reason is that style 4 (screen width) is omitted. That was also the case in FlyingBoz's udf so I corrected it (yes, I wrote my own background changer :) )

Here is the modified udf

;===============================================================================
;
; Function Name: _ChangeDesktopWallpaper
; Description: Update WallPaper Settings
; Usage: _ChangeDesktopWallpaper(@WindowsDir & '\' & 'zapotec.bmp',1)
; Parameter(s): $bmp - Full Path to BitMap File (*.bmp)
; [$style] - 0 = Centered, 1 = Tiled, 2 = Stretched, 4 = Screen Width
; Requirement(s): None.
; Return Value(s): On Success - Returns 0
; On Failure - -1
; Author(s): FlyingBoz
; Revised by: Greencan, added Style 4
;Thanks: Larry - DllCall Example - Tested and Working under XPHome and W2K Pro
; Excalibur - Reawakening my interest in Getting This done.
;
;===============================================================================
Func _ChangeDestopWallpaper($bmp, $style = 0)
If Not FileExists($bmp) Then Return -1
;The $SPI* values could be defined elsewhere via #include - if you conflict,
; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic
Local $SPI_SETDESKWALLPAPER = 20
Local $SPIF_UPDATEINIFILE = 1
Local $SPIF_SENDCHANGE = 2
Local $REG_DESKTOP= "HKEY_CURRENT_USER\Control Panel\Desktop"
if $style = 1 then
RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1)
RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)
Else
RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style)
EndIf


DllCall("user32.dll", "int", "SystemParametersInfo", _
"int", $SPI_SETDESKWALLPAPER, _
"int", 0, _
"str", $bmp, _
"int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
Return 0
EndFunc ;==>_ChangeDestopWallpaper

To use screen width, verify if the width of the bitmap is larger than @DesktopWidth or height is larger than @DesktopHeight and if one of both conditions are met:

_ChangeDestopWallpaper($sWallpaper, 4) ; screen width

Thanks for the report i will take a look to what you said, but as i said at the first, this is a 10 minute script for an ser, i hadn't tested it too much.

For the bitmap question, with the quick research on the web that i have done. i have seen that all other function that accept .jpg automatically convert the image to a .bmp file and the set as wallpaper.

But i will check better later, now i am on recording studio playing my guitar, but i will let you know something.

I didn't know about style n°4, i will take a look.

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

How do you handle a dual monitor (or even more than 2 monitors) system when the screens have different resolutions? Doesn't seem like any it would be as easy as using @DesktopWidth, because that only gets the primary display.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

BrewManH,

Yes, you are completely right, I handle dual monitors, I mean, one picture over multiple monitors and it works perfectly well, I could not put two different images on two monitors however, but I glue two bitmaps aside each other and that looks like 2 images.

Only tiled can span multiple monitors as far as I know.

_ChangeDestopWallpaper($sWallpaper, 1) ; Tiled (will span the image over the entire screen, dual monitors included)

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

How do you handle a dual monitor (or even more than 2 monitors) system when the screens have different resolutions? Doesn't seem like any it would be as easy as using @DesktopWidth, because that only gets the primary display.

That is a geeky idea:

http://blogs.msdn.com/b/oldnewthing/archive/2007/09/24/5083738.aspx

@GreenCan

I am searching for adding .jpg support but googling all i see is a jpg to bmp conversion and then set to wallpaper. Do you have a better way to do that?

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

BrewManH,

Yes, you are completely right, I handle dual monitors, I mean, one picture over multiple monitors and it works perfectly well, I could not put two different images on two monitors however, but I glue two bitmaps aside each other and that looks like 2 images.

Only tiled can span multiple monitors as far as I know.

Not exactly what I was referring to. You stated that you use style 4 (screen width) in your changer. I was merely asking the both of you how you handle it when your primary display is a different resolution than your secondary display. For example, my laptop has a 1440x900 resolution, but the LCD monitor has a 1280x1024 resolution, which width do you choose, the longer one or the shorter one?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@GreenCan

I have searched, and as i can see windows accept only .bmp images. When you change the wallpaper and use a .jpg image the OS itselft convert the image to a .bmp and save it to:

%Userprofile%\Local Settings\Application Data\Microsoft

It seems pretty useless to support .jpg in the function for space reasons :) The only thingthat can be usefull is to add the support for .jpg for the online wallpaper script and then convert to .bmp on the machine only for saving the server bandwidth.

I also can't find a document that talk about style n°4 but i will searching better. Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

I will test later as I'm using Windows 7 x64.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I understand but it's not different, in fact, I use two different monitors at the office, in a similar configuration as you describe. One 19 inch and one 24" widescreen (I don't remember the resolution)

I can't check here at home, but I believe that @DesktopHeight is the height of the primary monitor, if the second monitor's height resolution is different, you will lose some content either at the right side, or see some Black (whatever color) at the right side, but you have to live with it :), It's better than seeing twice the same background by the end.

The width that I choose is just the total desktop width A+B , nothing else, no complexities required if it's not necessary?

This is the snippet that I extracted where you see the logic.

By the way, just reading the code again shows that I lied when I wrote that only tiled could be used, I use tile only when the image perfectly matches the monitors resolution.

$aInfo = _ImageGetInfo($sWallpaper)
If @error Then Exit MsgBox (0, "Error", "Can't open file:" & @CR & $sWallpaper)
If _ImageGetParam($aInfo, "Width") = "" Then Exit MsgBox (0, "Error", "Not an image file:" & @CR & $sWallpaper)

If _ImageGetParam($aInfo, "Width") = $VirtualDesktopWidth Or IniRead(@ScriptDir & "\ForceWallpaper.ini","General","Tile","")="Yes" Then
     _ChangeDestopWallpaper($sWallpaper, 1) ; Tiled (will span the image over the entire monitor)
ElseIf _ImageGetParam($aInfo, "Width") > @DesktopWidth Or _ImageGetParam($aInfo, "Height") > @DesktopHeight Then
     _ChangeDestopWallpaper($sWallpaper, 4) ; screen width
Else
     _ChangeDestopWallpaper($sWallpaper, 0) ; no style
EndIf

If Not @Compiled Then ConsoleWrite("Current: " & $sCurrent & @CR & "New: " & $sWallpaper & @CR)

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

GreenCan,

To note Dll and constants are all available in WinAPI and WindowsConstants. No need to declare what is already available in AutoIt.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

It seems pretty useless to support .jpg in the function for space reasons :) The only thingthat can be usefull is to add the support for .jpg for the online wallpaper script and then convert to .bmp on the machine only for saving the server bandwidth.

Of course, the obvious benefit with Jpegs, is storage and wide availability of so many readily available images, even from our own cameras. Of course, the only file that needs to be a bmp is the current one in use as wallpaper, so you really only need to convert on the fly ... when changing. Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

@GreenCan

I have searched, and as i can see windows accept only .bmp images. When you change the wallpaper and use a .jpg image the OS itselft convert the image to a .bmp and save it to:

%Userprofile%\Local Settings\Application Data\Microsoft

It seems pretty useless to support .jpg in the function for space reasons :) The only thingthat can be usefull is to add the support for .jpg for the online wallpaper script and then convert to .bmp on the machine only for saving the server bandwidth.

Yes, you are right but it still is relevant to allow jpg. I have 70 dual monitor workstations at the office, users choose their own images, If they first have to convert their files to bmp (believe me that is already a challenge for the average user) I would be dead by now.

Why don't we use the W7 perfect background changer (I hear you asking this :) )

Well the group I work for outsourced it's infrastructure and desktop management to one of the ugly big ones, and guess what? They disabled the background image. This caused so much annoyance amongst the employees of my company that I decided to quickly implement a background changer myself. The funny thing is that some events cause the background to get back to it's initial state, by a forced GPO I guess (for example when closing the lid of a laptop). I catch the event and before the user notices any change the image is back on screen.

I use W7 64bit

Edited by GreenCan

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

Yes, you are right but it still is relevant to allow jpg. I have 70 dual monitor workstations at the office, users choose their own images, If they first have to convert their files to bmp (believe me that is already a challenge for the average user) I would be dead by now.

Why don't we use the W7 perfect background changer (I hear you asking this :) )

Well the group I work for outsourced it's infrastructure and desktop management to one of the ugly big ones, and guess what? They disabled the background image. This caused so much annoyance amongst the employees of my company that I decided to quickly implement a background changer myself. The funny thing is that some events cause the background to get back to it's initial state, by a forced GPO I guess (for example when closing the lid of a laptop). I catch the event and before the user notices any change the image is back on screen.

I use W7 64bit

I will implement an onfly jpg to bmp converter and i will add .jpg support to .php script. Now only one question, do you have more infos about styles n°4?. From the internet i only see this the 3 style that i currently support.

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

GreenCan,

To note Dll and constants are all available in WinAPI and WindowsConstants. No need to declare what is already available in AutoIt.

Do you mean using the usage of _ImageGetParam and others functions of Lazycat?

Yes you are completely right but when I wrote this I had only a few hours to deliver, I didn't want to spent more time and out of laziness I choose the shortest track, the one that Lazycat gave me :)

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

I will implement an onfly jpg to bmp converter and i will add .jpg support to .php script. Now only one question, do you have more infos about styles n°4?. From the internet i only see this the 3 style that i currently support.

Hi!

I cannot find the enumeration on msdn, I think I checked the registry setting for the 5 styles that can be set.In fact there are 5 styles but they appear to be valid only as from Windows 7: Tile, Center, Stretch, Fit and Fill

http://code.msdn.microsoft.com/windowsdesktop/CppSetDesktopWallpaper-eb969505

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

I'm not!

#include <APIConstants.au3> ; Found in WinAPIEx by Yashied.
#include <WinAPI.au3>

; #FUNCTION# ====================================================================================================================
; Name ..........: _ChangeDestopWallpaper
; Description ...: Update the desktop wallpaper.
; Syntax ........: _ChangeDestopWallpaper($sImageFile[, $iStyle = 0])
; Parameters ....: $sImageFile          - Full path to the bitmap file.
;                  $iStyle               - [optional] 0 = Centered, 1 = Tiled, 2 = Stretched, 4 = Screen Width. Default is 0.
; Return values .: Success - True
;                  Failure - Sets @error to non-zero and returns False
; Author ........: FlyingBoz
; Modified ......: Larry - DllCall Example - Tested and Working under XPHome and W2K Pro.
;                  Greencan - Added Style 4.
;                  guinness - Tidied up the code and adding error checking.
; Example .......: No
; ===============================================================================================================================
Func _ChangeDestopWallpaper($sImageFile, $iStyle = Default)
    If FileExists($sImageFile) = 0 Then Return SetError(1, 0, False)

    $iStyle = Int($iStyle)
    If $iStyle < 0 Or $iStyle > 4 Then $iStyle = 0
    Local Const $sREG_DESKTOP = 'HKEY_CURRENT_USER\Control Panel\Desktop'
    If $iStyle = 1 Then
        RegWrite($sREG_DESKTOP, 'TileWallPaper', 'REG_SZ', 1)
        RegWrite($sREG_DESKTOP, 'WallpaperStyle', 'REG_SZ', 0)
    Else
        RegWrite($sREG_DESKTOP, 'TileWallPaper', 'REG_SZ', 0)
        RegWrite($sREG_DESKTOP, 'WallpaperStyle', 'REG_SZ', $iStyle)
    EndIf
    ; Idea from here: http://www.autoitscript.com/forum/topic/19370-autoit-wrappers/page__st__280#entry652536
    Local $tBuffer = DllStructCreate('wchar Text[' & StringLen($sImageFile) + 1 & ']')
    DllStructSetData($tBuffer, 'Text', $sImageFile)
    Return _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, DllStructGetPtr($tBuffer), BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))
EndFunc   ;==>_ChangeDestopWallpaper
Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...