faustf Posted December 13, 2014 Posted December 13, 2014 hi guy i have a questions i wannt change my wallpaper by script i put in variable my path-image.jpg and delete the registry key RegDelete("HKEY_CURRENT_USERControl PanelDesktop", "Wallpaper") and after write registry key with new image RegWrite("HKEY_CURRENT_USERControl PanelDesktop","Wallpaper","REG_SZ",$path_save & $nome_immagine[5]) in registry change a path and all is ok but my desktop remaning with thesame foto if i restar pc i have with desktop only blue color someone have suggestions? ? thankz
computergroove Posted December 13, 2014 Posted December 13, 2014 (edited) _WinAPI_SystemParametersInfo is probably what you are looking for with SPI_GETDESKWALLPAPER Here's an example I wrote recently that changes a mouse cursor. #RequireAdmin #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WinAPIsysinfoConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}","Terminate") HotKeySet("{F3}","ToggleCursor") Global $NewCursor Global $OriginalCursor = RegRead("HKEY_CURRENT_USER\Control Panel\Cursors", "Arrow");Read the original cursor value Global $RegKeyCursor1= "HKEY_CURRENT_USER\Control Panel\Cursors";Location of the cursor info in the registry While 1 Sleep(100) WEnd Func ToggleCursor() $NewCursor = NOT $NewCursor RegWrite($RegKeyCursor1,"Arrow","REG_EXPAND_SZ","%SystemRoot%\cursors\aero_ew.cur");Change the cursor value in the registry _WinAPI_SystemParametersInfo($SPI_SETCURSORS, 0);Refresh the mouse settings used in the registry While $NewCursor;loop Sleep(100);loop WEnd;loop RegWrite($RegKeyCursor1,"Arrow","REG_EXPAND_SZ",$OriginalCursor);Restore the original mouse value in the registry _WinAPI_SystemParametersInfo($SPI_SETCURSORS, 0);Refresh the mouse settings used in the registry EndFunc Func Terminate() Exit 0 EndFunc Edited December 13, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
faustf Posted December 13, 2014 Author Posted December 13, 2014 i tryed to use RegDelete("HKEY_CURRENT_USERControl PanelDesktop", "Wallpaper") RegWrite("HKEY_CURRENT_USERControl PanelDesktop","Wallpaper","REG_SZ",$path_save & $nome_immagine[5]) _WinAPI_SystemParametersInfo($SPI_SETCURSORS, 0) but nothing happen
Chimaera Posted December 13, 2014 Posted December 13, 2014 (edited) Its not a simple thing Original authors i think were Smoke N and trancexx expandcollapse popup#include <GDIPlus.au3> #include <Misc.au3> _ChangeWallpaper($dest_dir & "\1920x1080.jpg", 2) Func _ChangeWallpaper($sFile, $iType) ; XP and below converts jpg to bmp Local $apos, $bpos, $sFileName, $hImage, $sCLSID ; Changes the wallpaper to $sFileName using $iType as: ; 1 Tiled ; 2 Centered ; 3 Stretched ; any other value (usually 0) unchanged ; ; Returns ; 0 if everything is allright. ; -1 if $sFile does not exist. @error is set to 1 ; -2 if $sFile is not bmp or jpg file. @error is set to 2 If Not FileExists($sFile) Then SetError(1) Return -1 EndIf $apos = StringInStr($sFile, "\", 0, -1) $bpos = StringInStr($sFile, ".", 0, -1) $sFileName = StringMid($sFile, $apos + 1, $bpos - $apos - 1) If Not StringRight($sFile, 3) = "jpg" Or Not StringRight($sFile, 3) = "bmp" Then SetError(2) Return -2 EndIf Select Case $iType = 1 RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '1') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0') Case $iType = 2 RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0') Case $iType = 3 RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2') Case Else EndSelect If $OS = "V-" Then If StringRight($sFile, 3) = "jpg" Then _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFile) $sCLSID = _GDIPlus_EncodersGetCLSID("BMP") _GDIPlus_ImageSaveToFileEx($hImage, $dest_dir & "\" & $sFileName & ".bmp", $sCLSID) _GDIPlus_Shutdown() $sFile = $dest_dir & "\" & $sFileName & ".bmp" EndIf Sleep(500) RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile) DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0) Else Sleep(500) RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile) DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0) EndIf ; Convert jpg to bmp ;~ If StringRight($sFile, 3) = "jpg" Then ;~ _GDIPlus_Startup() ;~ $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;~ $sCLSID = _GDIPlus_EncodersGetCLSID("BMP") ;~ _GDIPlus_ImageSaveToFileEx($hImage, @TempDir & "\" & $sFileName & ".bmp", $sCLSID) ;~ _GDIPlus_Shutdown() ;~ $sFile = @TempDir & "\" & $sFileName & ".bmp" ;~ EndIf ;~ Sleep(500) ;~ RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile) ;~ DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0) EndFunc ;==>_ChangeWallpaper It is modified but you should get the idea Edited December 13, 2014 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()
Spider001 Posted December 13, 2014 Posted December 13, 2014 (edited) '?do=embed' frameborder='0' data-embedContent>> Edited December 13, 2014 by Spider001
computergroove Posted December 13, 2014 Posted December 13, 2014 I thought it was more obvious to everyone with the example. Try the following: RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper","REG_SZ",$path_save & $nome_immagine[5]) _WinAPI_SystemParametersInfo($SPI_GETDESKWALLPAPER, 0) Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
faustf Posted December 13, 2014 Author Posted December 13, 2014 so i tryed just in this mode RegWrite("HKEY_CURRENT_USERControl PanelDesktop","Wallpaper","REG_SZ",$path_save & $nome_immagine[5]) _WinAPI_SystemParametersInfo($SPI_GETDESKWALLPAPER, 0) but dont go if i open Control PanelAppearance and PersonalizationPersonalization i see a unsaved theme with my backgraound , but nothing remaning old foto but i think , i do a questions , but is probably win7 for change desktop you must create a theme pocket and run it ?
faustf Posted December 13, 2014 Author Posted December 13, 2014 (edited) for me is not correct the notice RegWrite("HKEY_CURRENT_USERControl PanelDesktop","Wallpaper","REG_SZ",$path_save & $nome_immagine[5]) because the real sources of foto is C:WindowsWebWallpapernature , architect ............ and when you change a desktop background windows delete a file foto in folder @AppDataDir&"MicrosoftWindowsThemesTranscodedWallpaper.jpg and copy a new foto in the same folder with the same name therfore is not important change this key RegWrite("HKEY_CURRENT_USERControl PanelDesktop","Wallpaper","REG_SZ",$path_save & $nome_immagine[5]) because you can copy and rename a foto but dont go the same >_< Edited December 13, 2014 by faustf
computergroove Posted December 13, 2014 Posted December 13, 2014 (edited) Sorry I used the wrong SPI parameter RegWrite("HKEY_CURRENT_USERControl PanelDesktop","Wallpaper","REG_SZ",$path_save & $nome_immagine[5]) _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0) I tested the above with a direct path name and it works perfectly. Edited December 13, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
computergroove Posted December 14, 2014 Posted December 14, 2014 ;Script to toggle the background wallpaper. Tested working on Windows 7 Pro x64 ;F3 Toggles the background image. Script doesn't save original desktop wallpaper. #RequireAdmin #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WinAPIsysinfoConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}","Terminate") HotKeySet("{F3}","ToggleWallpaper") Global $Wallpaper Global $Background1 = @ScriptDir & "Picture1.jpg";<- You need to add a picture to this location or change the location Global $Background2 = @ScriptDir & "Picture2.jpg";Ditto While 1 Sleep(100) WEnd Func ToggleWallpaper() $Wallpaper = NOT $Wallpaper RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper","REG_SZ",$Background1) _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0) While $Wallpaper;loop Sleep(100);loop WEnd;loop RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper","REG_SZ",$Background2) _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0) EndFunc Func Terminate() Exit 0 EndFunc Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
faustf Posted December 14, 2014 Author Posted December 14, 2014 (edited) i tryed but not go i coped your script and use a 2 foto only for try if all go but nothing remaning always old background Edited December 14, 2014 by faustf
computergroove Posted December 14, 2014 Posted December 14, 2014 (edited) Open regedit and browse to HKEY_CURRENT_USERControl PanelDesktop and manually change the value for the item "Wallpaper" to a full file path that you know has a different jpg wallpaper and click OK (DO NOT USE AN ARRAY HERE YET) and then run the following in autoit: #RequireAdmin #include <WinAPI.au3> #include <WinAPIsysinfoConstants.au3> #include <WindowsConstants.au3> _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0) The background should change instantly. If the full path isnt right in the wallpaper path in the registry then the wallpaper wont change. You must have the correct path to the jpg file for your registry entry. What happens? Edited December 14, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
BrewManNH Posted December 14, 2014 Posted December 14, 2014 Try a ProcessClose on Explorer.exe and then restart it, see if that works. 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 GudeHow 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
computergroove Posted December 14, 2014 Posted December 14, 2014 What OS are you using? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
faustf Posted December 14, 2014 Author Posted December 14, 2014 (edited) i using windows 7 in virtualbox , but have tested program also in windows 8 real machine and dont go also with start and stop explorer not do nothing Edited December 14, 2014 by faustf
computergroove Posted December 14, 2014 Posted December 14, 2014 Oracle VirtualBox right? Ill try it in my windows 7 vb. Do you have the guest addons installed? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
computergroove Posted December 14, 2014 Posted December 14, 2014 (edited) ;Script to toggle the background wallpaper. Tested working on Windows 7 Pro x64 ;F3 Toggles the background image. Script doesn't save original desktop wallpaper. #RequireAdmin #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WinAPIsysinfoConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}","Terminate") HotKeySet("{F3}","ToggleWallpaper") Global $Wallpaper Global $Background1 = @ScriptDir & "Picture1.jpg";<- You need to add a picture to this location or change the location Global $Background2 = @ScriptDir & "Picture2.jpg";Ditto While 1 Sleep(100) WEnd Func ToggleWallpaper() $Wallpaper = NOT $Wallpaper RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper","REG_SZ",$Background1) _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0) While $Wallpaper;loop Sleep(100);loop WEnd;loop RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop","Wallpaper","REG_SZ",$Background2) _WinAPI_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0) EndFunc Func Terminate() Exit 0 EndFunc I made a mistake in my code. You need to add a "" in front of the picture1 and picture2 Global $Background1 = @ScriptDir & "\Picture1.jpg";<- You need to add a picture to this location or change the location Global $Background2 = @ScriptDir & "\Picture2.jpg";Ditto It works for me in vb. If you PM me I can teamviewer into your Virtual machine and take a look. or skype me username william walker Edited December 14, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
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