BAM5 Posted December 6, 2007 Posted December 6, 2007 (edited) Pretty basic, used it to test some stuff though, I now know I can check the msg using a for to loop, comes in handy when the user defines it How it works:1. Set up your desktop the way you like it.2. Click save on the tray menu.3. Give the configuration a name.4. Repeat for all desktop configurations.5. Go under the sub-menu "Desktops" and select the desktop configuration you want restored.Note: If your original file was a jpeg it will delay because it is converting it into a bitmap first then it will set the background.expandcollapse popup#Include <GDIPlus.au3> Opt ("TrayMenuMode", 1) $error = 0 Local $tray[50] $sFile = @ScriptDir & "\Data.ini" If Not FileExists ($sFile) Then FileWrite ($sFile, "") EndIf $desktops = TrayCreateMenu ("Desktops") $save = TrayCreateItem ("Save Current Background") $exit = TrayCreateItem ("Exit") writetray() While 1 $msg = TrayGetMsg () $infos = IniReadSectionNames ($sFile) If @error Then $error = 1 EndIf Select Case $msg = $save SaveCurWallpaperSettings ($sFile) If Not $error = 1 Then For $i = 1 To $infos[0] TrayItemDelete ($tray[$i]) Next EndIf writetray() Case $msg = $exit Exit 0 EndSelect If Not $error = 1 Then For $i = 1 To $infos[0] If $msg = $tray[$i] Then RestoreWallpaper ($sFile, $i) EndIf Next EndIf WEnd Func SaveCurWallpaperSettings($file, $num=-1) If $num = -1 Then $amount = IniReadSectionNames ($sFile) If Not @error Then $num = $amount[0] + 1 Else $num = 1 EndIf EndIf $CWallpaperFile = RegRead ("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper") $CWallpaperTile = RegRead ("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper") $CWallpaperStyle = RegRead ("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle") $name = InputBox ("Name?", "Enter the name for the save") If StringInStr ($CWallpaperFile, "\Local Settings\Application Data\Microsoft\Wallpaper1.bmp") Then $CWallpaperFile = RegRead ("HKEY_CURRENT_USER\Control Panel\Desktop", "ConvertedWallpaper") EndIf IniWriteSection ($file, $num, "1=" & $CWallpaperFile & @LF & "2=" & $CWallpaperTile & @LF & "3=" & $CWallpaperStyle & @LF & "4=" & $name) EndFunc Func RestoreWallpaper ($file, $num) $info = IniReadSection ($file, $num) If StringInStr ($info[1][1], ".bmp") Then RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $info[1][1]) RegWrite ("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", $info[2][1]) RegWrite ("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", $info[3][1]) DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $info[1][1], "int", 0) Else RegWrite ("HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "REG_SZ", $info[2][1]) RegWrite ("HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "REG_SZ", $info[3][1]) ChangeWallpaper ($info[1][1]) EndIf EndFunc Func writetray () $saves = IniReadSectionNames ($sFile) If Not @error = 1 Then For $i = 1 To $saves[0] $hehe = IniReadSection ($sFile, $i) $tray[$i] = TrayCreateItem ($hehe[4][1], $desktops) Next EndIf EndFunc Func ConvertImg($sImage, $sDestWithNewExt, $extension="BMP") _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile($sImage) $sCLSID = _GDIPlus_EncodersGetCLSID($extension) _GDIPlus_ImageSaveToFileEx($hImage, $sDestWithNewExt, $sCLSID) _GDIPlus_ShutDown() EndFunc Func ChangeWallpaper($sFile) $sCheck=StringSplit($sFile, ".") If $sCheck[2] = "bmp" Then RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile) DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0) Else ConvertImg ($sFile, $sCheck[1] & ".bmp", "bmp") RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sCheck[1] & ".bmp") DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sCheck[1] & ".bmp", "int", 0) EndIf EndFuncDownloaded current version of autoit and tested it and it works. I have windows xp sp2.Will be updating, many things I can improve but for now here is a rough working version Edited December 7, 2007 by bam5 [center]JSON Encoding UDF[/center]
GaryFrost Posted December 6, 2007 Posted December 6, 2007 That lib is no longer available to the public, might try again with something the public can use. Look in the autoit help for GDIPlus Management. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference. Â
BAM5 Posted December 6, 2007 Author Posted December 6, 2007 That lib is no longer available to the public, might try again with something the public can use.Look in the autoit help for GDIPlus Management.Wait, WHAT? That was some good stuff why isn't it available anymore? [center]JSON Encoding UDF[/center]
ChangMinYang Posted December 6, 2007 Posted December 6, 2007 Wait, WHAT? That was some good stuff why isn't it available anymore?A3LGDIPlus.au3 => GDIPlus.au3//Current AutoIt v3 included A3*Any used functions, _GDIP_* => _GDIPlus_*thx,
Achilles Posted December 6, 2007 Posted December 6, 2007 The change is actually very easy (generally). I had to change a few scripts and all you have to do is open the script and replace asll _GDIP_ with _GDIPlus_ and change the include name. Are you planning on changing your code so we can see how this works? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
BAM5 Posted December 6, 2007 Author Posted December 6, 2007 The change is actually very easy (generally). I had to change a few scripts and all you have to do is open the script and replace asll _GDIP_ with _GDIPlus_ and change the include name. Are you planning on changing your code so we can see how this works?O ok, I see now, for a second I thought it was gone completely as in its no longer compatible.Yes I will start converting it to the new script right away! [center]JSON Encoding UDF[/center]
Achilles Posted December 6, 2007 Posted December 6, 2007 First thing, you can click "Edit" to change a post. I suggest you do this and update your first post in this topic. Second, it works pretty well. There are a few bug though... When I saved my first desktop it made two tray icons for it for some reason. Third, it would actually change the desktop until I restarted the program. I'm not sure why that is... Good work on what you have so far! My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
BAM5 Posted December 7, 2007 Author Posted December 7, 2007 First thing, you can click "Edit" to change a post. I suggest you do this and update your first post in this topic.Second, it works pretty well. There are a few bug though... When I saved my first desktop it made two tray icons for it for some reason. Third, it would actually change the desktop until I restarted the program. I'm not sure why that is...Good work on what you have so far!Hmm.. Well I'm not sure I have explained how this works so.1. Set up your desktop the way you like it.2. Click save on the tray menu.3. Give the configuration a name.4. Repeat for all desktop configurations.5. Go under the sub-menu "Desktops" and select the desktop configuration you want restored.Note: If your original file was a jpeg it will delay because it is converting it into a bitmap first then it will set the background. [center]JSON Encoding UDF[/center]
Achilles Posted December 7, 2007 Posted December 7, 2007 Hmm.. Well I'm not sure I have explained how this works so.1. Set up your desktop the way you like it.2. Click save on the tray menu.3. Give the configuration a name.4. Repeat for all desktop configurations.5. Go under the sub-menu "Desktops" and select the desktop configuration you want restored.Note: If your original file was a jpeg it will delay because it is converting it into a bitmap first then it will set the background.Is this just for the background? Or does it move the icons/files/folders too? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
BAM5 Posted December 7, 2007 Author Posted December 7, 2007 (edited) Is this just for the background? Or does it move the icons/files/folders too?Just for the background but good idea. I know how to save and restore icons thanks to the icon restorator in the downloads section and I think I will add it to the script.The reason I said configuration is because it also saves aspects of the background such as if it is tiled centered or stretched which are all in the registry. Edited December 7, 2007 by bam5 [center]JSON Encoding UDF[/center]
Achilles Posted December 7, 2007 Posted December 7, 2007 Just for the background but good idea. I know how to save and restore icons thanks to the icon restorator in the downloads section and I think I will add it to the script.The reason I said configuration is because it also saves aspects of the background such as if it is tiled centered or stretched which are all in the registry.Look at Multiple Desktops in my signature. It could give you some ideas on improvements... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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