Achilles Posted August 5, 2007 Share Posted August 5, 2007 (edited) I made this recently for a friend of mine, and before I give it to him I would appreciate if a couple people could test it... Fairly simple, but it was fun to make.NOTE: Since PaulIA's includes do not cooperate with GuiListView.au3, I compiled all PaulIA's functions that I used into a file, that it attached here: AutoItLib.au3 Previous number of downloads: 92expandcollapse popup#region *** INCLUDES *** #include <GUIConstants.au3> #Include <Constants.au3> #Include <GuiListView.au3> #include <File.au3> #include <Array.au3> #include 'AutoItLib.au3' #NoTrayIcon #endregion #region *** SINGLETON *** _Singleton('Wallpaper Rotater.au3') #endregion #region *** OPTS *** Opt('GUIOnEventMode', 1) Opt('TrayOnEventMode',1) Opt('OnExitFunc', '_Exit') Opt('TrayMenuMode',1) #endregion #region *** GLOBAL CONSTS *** Global Const $WM_NOTIFY = 0x004E Global Const $NM_FIRST = 0 Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) #endregion #region *** GLOBAL VARIABLES *** Global $showed[1] ;Array of all shown pictures Global $globalIndex = 1 Global $lstDirectories, $picPreview, $txtTime, $optionGui ;GUI Objects Global $lastSelected, $time, $doubleClicked, $rad[1], $showing, $lastShowed ;Variables #endregion If Not FileExists(@ScriptDir & '\Rotater.ini') then $firstTime = True Else $firstTime = False EndIf $enabled = IniRead(@ScriptDir & '\Rotater.ini', 'Enabled', 'Current', 'UNKNOWN') If $enabled = 'UNKNOWN' or $enabled = 'True' then $enabled = True IniWrite(@ScriptDir & '\Rotater.ini', 'Enabled', 'Current', True) EndIf TrayCreateItem('Configure...') TrayItemSetState(-1, $TRAY_DEFAULT) TrayItemSetOnEvent(-1, '_CreateGUI') TrayCreateItem('') TrayCreateItem('Next') TrayItemSetOnEvent(-1, '_Next') TrayCreateItem('') TrayCreateItem('Enabled') TrayItemSetOnEvent(-1, '_Status') If $enabled then TrayItemSetState(-1, $TRAY_CHECKED) TrayCreateItem('') TrayCreateItem('Exit Wallpaper Rotater') TrayItemSetOnEvent(-1, '_ExitProgram') TraySetClick(8) TraySetState() If $firstTime then $showing = -1 _CreateGUI() Else $showed[0] = RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper') $showing = $showed[0] $temp = _GetPosition() IniWrite(@ScriptDir & '\Rotater.ini', 'Images', $showed[0], '1|' & $temp) $time = IniRead(@ScriptDir & '\Rotater.ini', 'Time', 'Current', 'NOT FOUND') If $time = 'NOT FOUND' then $time = 10 IniWrite(@ScriptDir & '\Rotater.ini', 'Time', 'Current', 10) Else If $time < 1 then $time = 1 IniWrite(@ScriptDir & '\Rotater.ini', 'Time', 'Current', 1) EndIf EndIf If $enabled then _StartRotater() EndIf #region *** LOOP *** While 1 Sleep(5000) WEnd #endregion Func _StartRotater() _ChangePic() AdLibEnable('_ChangePic', $time * 1000 * 60) EndFunc Func _Next() _ChangePic() EndFunc Func _ChangePic() $old = IniReadSection(@ScriptDir & '\Rotater.ini', 'Images') If IsArray($old) then $purifiedArray = _Purify($old) If $purifiedArray[0][0] = 1 then _ChangeDesktopBackground($purifiedArray[1][0], $purifiedArray[1][1]) $tipCreating = StringSplit($purifiedArray[1][0], '\') $tip = $tipCreating[$tipCreating[0]] $showing = $purifiedArray[1][0] TraySetToolTip('Current picture: ' & $tip) ElseIf $purifiedArray[0][0] = 2 then If $purifiedArray[1][0] = $showed[0] then _ChangeDesktopBackground($purifiedArray[2][0], $purifiedArray[2][1]) $showed[0] = $purifiedArray[2][0] $showing = $purifiedArray[2][0] $tipCreating = StringSplit($purifiedArray[2][0], '\') Else _ChangeDesktopBackground($purifiedArray[1][0], $purifiedArray[1][1]) $showed[0] = $purifiedArray[1][0] $showing = $purifiedArray[1][0] $tipCreating = StringSplit($purifiedArray[1][0], '\') EndIf TraySetToolTip('Current picture: ' & $tipCreating[$tipCreating[0]]) ElseIf $purifiedArray[0][0] > 2 then Redim $showed[$purifiedArray[0][0]] Do $rand = Random(1, $purifiedArray[0][0]+ 1) $new = $purifiedArray[$rand][0] $position = $purifiedArray[$rand][1] $pass = True For $a = 0 to $purifiedArray[0][0] - 1 If $new = $showed[$a] then $pass = False Next Until $pass = True _ChangeDesktopBackground($new, $position) $showing = $new If $globalIndex > $purifiedArray[0][0] - 2 then $globalIndex = 0 EndIf $showed[$globalIndex] = $new $globalIndex += 1 $tipCreating = StringSplit($new, '\') TraySetToolTip('Current picture: ' & $tipCreating[$tipCreating[0]]) EndIf EndIf EndFunc Func _Purify($array) Local $newArray[1][2] Local $index = 1 $newArray[0][0] = $array[0][0] For $a = 1 to $array[0][0] $stringTemp = StringSplit($array[$a][1], '|') If $stringTemp[1] = 1 then ReDim $newArray[$index + 1][2] $newArray[$index][0] = $array[$a][0] $newArray[$index][1] = $stringTemp[2] $index += 1 Else $newArray[0][0] -= 1 EndIf Next Return $newArray EndFunc Func _Status() $enabled = Not $enabled IniWrite(@ScriptDir & '\Rotater.ini', 'Enabled', 'Current', $enabled) If $enabled = True then If WinExists('Wallpaper Rotater Configuration') then Return _StartRotater() Else AdLibDisable() EndIf EndFunc Func _CreateGUI() If WinExists('Wallpaper Rotater Configuration') then Return AdLibDisable() Local Const $WIDTH_X_HEIGHT_CONVERSION = @DesktopWidth / @DesktopHeight Local Const $HEIGHT = 300 Local Const $SECOND_COLUMN_X = 415 GuiCreate('Wallpaper Rotater Configuration', 428 + $WIDTH_X_HEIGHT_CONVERSION * $HEIGHT, 406) GuiSetOnEvent($GUI_EVENT_CLOSE, '_Ok') GuiSetFont(11) GuiCtrlCreateLabel('Your current pictures:', 10, 0, 195, 25, $SS_CENTERIMAGE) $lstDirectories = GuiCtrlCreateListView('Name|Directory|Position', 10, 25, 395, $HEIGHT, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER), BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) _GUICtrlListViewSetColumnWidth($lstDirectories, 0, 150) _GUICtrlListViewSetColumnWidth($lstDirectories, 1, 245) _GUICtrlListViewSetColumnWidth($lstDirectories, 2, 100) GuiCtrlCreateButton('Select All', 10, $HEIGHT + 40, 95, 25) GuiCtrlSetOnEvent(-1, '_SelectAll') GuiCtrlCreateButton('Deselect All', 105, $HEIGHT + 40, 95, 25) GuiCtrlSetOnEvent(-1, '_DeselectAll') GuiCtrlCreateButton('Remove Selection', 205, $HEIGHT + 40, 95, 55, $BS_MULTILINE ) GuiCtrlSetOnEvent(-1, '_Remove') GuiCtrlCreateButton('Add File', 10, $HEIGHT + 70, 95, 25) GuiCtrlSetOnEvent(-1, '_AddFile') GuiCtrlCreateButton('Add Folder', 105, $HEIGHT + 70, 95, 25) GuiCtrlSetOnEvent(-1, '_AddFolder') GuiCtrlCreateLabel('Switch desktop wallpaper every', $SECOND_COLUMN_X - 90, $HEIGHT + 40, 200, 55, BitOr($SS_CENTERIMAGE , $SS_CENTER)) $txtTime = GuiCtrlCreateInput('', $SECOND_COLUMN_X + 208 - 90, $HEIGHT + 57, 42, 20) GuiCtrlCreateLabel('minutes.', $SECOND_COLUMN_X + 255 - 90, $HEIGHT + 40, 60, 55, BitOr($SS_CENTERIMAGE , $SS_CENTER)) $temp = IniReadSection(@ScriptDir & '\Rotater.ini', 'Images') If Not IsArray($temp) then $preview = RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper') $array = _ConvertDir($preview) $tempPosition = _GetPosition() GUICtrlCreateListViewItem($array[0] & '|' & $array[1] & '|' & _ConvertToText($tempPosition), $lstDirectories) GuiCtrlSetState(-1, $GUI_CHECKED) IniWrite(@ScriptDir & '\Rotater.ini', 'Images', $array[1] & '\' & $array[0], '1|' & $tempPosition) $picPreview = GuiCtrlCreatePic($preview, $SECOND_COLUMN_X, 25, $WIDTH_X_HEIGHT_CONVERSION * $HEIGHT, $HEIGHT, $SS_SUNKEN) $lastSelected = 1 $showed[0] = $preview Else For $a = 1 to $temp[0][0] $array = _ConvertDir($temp[$a][0]) $tempSplit = StringSplit($temp[$a][1], '|') GUICtrlCreateListViewItem($array[0] & '|' & $array[1] & '|' & _ConvertToText($tempSplit[2]), $lstDirectories) If $tempSplit[1] = 1 then GuiCtrlSetState(-1, $GUI_CHECKED) If $showing = $temp[$a][0] then $lastSelected = $a $picPreview = GuiCtrlCreatePic($temp[$a][0], $SECOND_COLUMN_X, 25, $WIDTH_X_HEIGHT_CONVERSION * $HEIGHT, $HEIGHT, $SS_SUNKEN) GuiCtrlSetImage($picPreview, $temp[$a][1] & '\' & $temp[$a][0]) _GUICtrlListViewSetItemSelState($lstDirectories, $a - 1, 1, 1) EndIf Next EndIf $time = IniRead(@ScriptDir & '\Rotater.ini', 'Time', 'Current', 'NOT FOUND') If $time = 'NOT FOUND' then $time = 20 GuiCtrlSetData($txtTime, $time) IniWrite(@ScriptDir & '\Rotater.ini', 'Time', 'Current', 20) Else If $time < 1 then $time = 1 IniWrite(@ScriptDir & '\Rotater.ini', 'Time', 'Current', 1) EndIf GuiCtrlSetData($txtTime, $time) EndIf GuiCtrlCreateButton('Ok', $SECOND_COLUMN_X + $WIDTH_X_HEIGHT_CONVERSION * $HEIGHT - 100, $HEIGHT + 40, 100, 55) GuiCtrlSetOnEvent(-1, '_Ok') GUIRegisterMsg($WM_NOTIFY, 'WM_Notify_Events') GuiSetState() EndFunc Func _GetPosition() $temp = RegRead('HKCU\Control Panel\Desktop', 'TileWallpaper') If $temp <> '1' then $temp = RegRead('HKCU\Control Panel\Desktop', 'WallpaperStyle') If $temp = '2' then $temp = '3' Else $temp = '2' EndIf EndIf Return $temp EndFunc Func _Ok() GuiSetState(@SW_HIDE) AdLibDisable() $time = GuiCtrlRead($txtTime) IniWrite(@ScriptDir & '\Rotater.ini', 'Time', 'Current', $time) _UpdateChecks() _ChangePic() GuiDelete() AdLibEnable('_ChangePic', $time * 1000 * 60) ;To convert to minutes... EndFunc Func _UpdateChecks() For $a = 0 to _GuiCtrlListViewGetItemCount($lstDirectories) - 1 $temp = _GuiCtrlListViewGetItemTextArray($lstDirectories, $a) If _GUICtrlListViewGetCheckedState ($lstDirectories, $a) = 0 then IniWrite(@ScriptDir & '\Rotater.ini', 'Images', $temp[2] & '\' & $temp[1], 0 & '|' & _ConvertToNum($temp[3])) Else IniWrite(@ScriptDir & '\Rotater.ini', 'Images', $temp[2] & '\' & $temp[1], 1 & '|' & _ConvertToNum($temp[3])) EndIf Next EndFunc Func _ConvertToNum($value) Switch $value Case 'Tile' Return 1 Case 'Center' Return 2 Case 'Stretch' Return 3 Case Else Return 3 EndSwitch EndFunc Func _ConvertToText($value) Switch $value Case 1 Return 'Tile' Case 2 Return 'Center' Case 3 Return 'Stretch' Case Else Return 'Stretch' EndSwitch EndFunc Func _IsOnList($value) For $a = 0 to _GUICtrlListViewGetItemCount($lstDirectories) - 1 $textArray = _GuiCtrlLIstViewGetItemTextArray($lstDirectories, $a) If $value = $textArray[2] & '\' & $textArray[1] then Return True EndIf Next Return False EndFunc Func _UpdatePreviewPic() If _GUICtrlListViewGetSelectedIndices($lstDirectories) <> - 1 then If _GUICtrlListViewGetSelectedIndices($lstDirectories) <> $lastSelected then $index = _GUICtrlListViewGetSelectedIndices ($lstDirectories) $text = _GUICtrlListViewGetItemTextArray($lstDirectories, $index) GuiCtrlSetImage($picPreview, $text[2] & '\' & $text[1]) $lastSelected = $index EndIf EndIf EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event If $wParam = $lstDirectories then $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Switch $event Case $NM_CLICK _UpdatePreviewPic() Case $NM_DBLCLK $doubleClicked = _GUICtrlListViewGetSelectedIndices($lstDirectories) _RadioOptionBox('Picture Position', 'Select the position you would like for this picture...', True, 'Tile', 'Center', 'Stretch') EndSwitch EndIf $tagNMHDR = 0 Return $GUI_RUNDEFMSG EndFunc Func _RadioOptionBox($title, $message, $guiOnEvent, $rad_0, $rad_1, $rad_2 = '', $rad_3 = '', $rad_4 = '', $rad_5 = '', $rad_6 = '', $rad_7 = '', $rad_8 = '', $rad_9 = '', $rad_10 = '') Local $width = 400 Local $i_UBound = @NumParams - 3 ReDim $rad[$i_UBound] If $title = '' then Return -2 If $message = '' then Return -2 If $rad_0 = '' then Return -2 If $rad_1 = '' then Return -2 $optionGui = GuiCreate($title, $width, 100 + (@NumParams - 3) * 25, -1, -1, $DS_SETFOREGROUND) GuiSetFont(13, 400, '', 'Timer New Roman') GuiCtrlCreateLabel($message, 5, 5, $width - 10, 25, $SS_CENTER) $temp = _GuiCtrlListViewGetItemTextArraY($lstDirectories, $doubleClicked) For $i_Index = 0 To $i_UBound - 1 $rad[$i_Index] = GuiCtrlCreateRadio(Eval("rad_" & String($i_Index)), 15, $i_Index * 25 + 30, 270, 25) If $i_Index + 1 = _ConvertToNum($temp[3]) then GuiCtrlSetState(-1, $GUI_CHECKED) Next $cancel = GuiCtrlCreateButton('Cancel', $width / 2 - 90, ($i_UBound) * 25 + 40, 80, 25) GuiCtrlSetOnEvent(-1, '_RadioCancel') $ok = GuiCtrlCreateButton('Ok', $width / 2 + 10, ($i_UBound) * 25 + 40, 80, 25) GuiCtrlSetOnEvent(-1, '_RadioOk') GuiSetState() EndFunc Func _RadioCancel() GuiDelete($optionGui) EndFunc Func _RadioOk() For $a = 0 to 2 If GuiCtrlRead($rad[$a]) = $GUI_CHECKED then $temp = _GuiCtrlListViewGetItemTextArraY($lstDirectories, $doubleClicked) If $temp[3] <> _ConvertToText($a + 1) then _GuiCtrlListViewSetItemText($lstDirectories, $doubleClicked, 2, _ConvertToText($a + 1)) $checkState = _GUICtrlListViewGetCheckedState($lstDirectories, $doubleClicked) IniWrite(@ScriptDir & '\Rotater.ini', 'Images', $temp[2] & '\' & $temp[1], $checkState & '|' & $a + 1) EndIf EndIf Next GuiDelete($optionGui) EndFunc Func _SelectAll() For $a = 0 to _GuictrlListViewGetItemCount($lstDirectories) - 1 _GUICtrlListViewSetCheckState ($lstDirectories, $a, 1) Next EndFunc Func _DeselectAll() For $a = 0 to _GuictrlListViewGetItemCount($lstDirectories) - 1 _GUICtrlListViewSetCheckState ($lstDirectories, $a, 0) Next EndFunc Func _Remove() Local $temp[1] $indices = _GUICtrlListViewGetSelectedIndices($lstDirectories, 1) If Not IsArray($indices) then Return For $a = 1 to $indices[0] Redim $temp[$a + 1] $split = StringSplit(_GuiCtrlListViewGetItemText($lstDirectories, $indices[$a]), '|') $toAdd = $split[2] & '\' & $split[1] $temp[$a] = $toAdd $temp[0] += 1 Next For $a = 1 to $temp[0] IniDelete(@ScriptDir & '\Rotater.ini', 'Images', $temp[$a]) Next _GuiCtrlListViewDeleteItemsSelected($lstDirectories) EndFunc Func _AddFile() If DirGetSize(@MyDocumentsDir & '\My Pictures') > 0 then $dir = @MyDocumentsDir & '\My Pictures' Else $dir = @MyDocumentsDir EndIf $temp = _MoveFileOpenDialog('Choose an image (Use Ctrl + to select multiple images', $dir, '(*.jpg;*.bmp;*.gif;*.png)', 7, '', @DesktopWidth / 2 - 563 / 2, @DesktopHeight / 2 - 414 / 2) If $temp <> '' then $splitTemp = StringSplit($temp, '|') If $splitTemp[0] = 1 then $array = _ConvertDir($temp) If _IsOnList($array[1] & '\' & $array[0]) then Return GUICtrlCreateListViewItem($array[0] & '|' & $array[1] & '|' & 'Stretch', $lstDirectories) GuiCtrlSetState(-1, $GUI_CHECKED) IniWrite(@ScriptDir & '\Rotater.ini', 'Images', $array[1] & '\' & $array[0], '1|3') Else For $a = 2 to $splitTemp[0] $array = _ConvertDir($splitTemp[1] & '\' & $splitTemp[$a]) If Not _IsOnList($array[1] & '\' & $array[0]) then GUICtrlCreateListViewItem($array[0] & '|' & $array[1] & '|' & 'Stretch', $lstDirectories) GuiCtrlSetState(-1, $GUI_CHECKED) IniWrite(@ScriptDir & '\Rotater.ini', 'Images', $array[1] & '\' & $array[0], '1|3') EndIf Next EndIf EndIf EndFunc Func _AddFolder() If DirGetSize(@MyDocumentsDir & '\My Pictures') > 0 then $dir = @MyDocumentsDir & '\My Pictures' Else $dir = @MyDocumentsDir EndIf $temp = FileSelectFolder('Choose a folder with wallpaper images', @HomeDrive, 2, $dir) If $temp <> '' then $folderArray = _FileListToArray($temp) $folderArray = _FilterArray($folderArray, 'jpg|bmp|gif') For $a = 1 to $folderArray[0] If Not _IsOnList($temp & '\' & $folderArray[$a]) then GUICtrlCreateListViewItem($folderArray[$a] & '|' & $temp & '|' & 'Stretch', $lstDirectories) GuiCtrlSetState(-1, $GUI_CHECKED) IniWrite(@ScriptDir & '\Rotater.ini', 'Images', $temp & '\' & $folderArray[$a], '1|3') EndIf Next EndIf EndFunc Func _ExitProgram() If WinExists('Wallpaper Rotater Configuration') then GuiDelete() _UpdateChecks() EndIf Exit EndFunc Func _FilterArray($array, $filter) Dim $tempArray[1] $filterSplit = StringSplit($filter, '|') For $a = 1 to $array[0] $itemSplit = StringSplit($array[$a], '.') $pass = False For $b = 1 to $filterSplit[0] If $itemSplit[$itemSplit[0]] = $filterSplit[$b] then $pass = True EndIf Next If $pass = True then _ArrayAdd($tempArray, $array[$a]) $tempArray[0] += 1 EndIf Next Return $tempArray EndFunc Func _ConvertDir($dir) Local $array[2] = ['', ''] $tempSplit = StringSplit($dir, '\') For $a = 1 to $tempSplit[0] - 1 $array[1] &= $tempSplit[$a] & '\' Next $array[1] = StringTrimRight($array[1], 1) $array[0] = $tempsplit[$tempSplit[0]] Return $array EndFunc Func _MoveFileOpenDialog($title, $initialDir, $filter, $options, $defaultPos, $posx, $posy) Local $temp $temp = EnvGet("temp") Local $filename = $temp & "\move_file_open_dialog.au3" Local $script = 'Global $title = "' & $title & '"' & @CRLF $script &= 'Global $pos_x = ' & $posx & @CRLF $script &= 'Global $pos_y = ' & $posy & @CRLF $script &= 'AdlibEnable("_Move",10)' & @CRLF $script &= 'while 1' & @CRLF $script &= ' sleep(1000)' & @CRLF $script &= 'wend' & @CRLF $script &= 'Func _Move()' & @CRLF $script &= ' if (WinActive($title)) Then' & @CRLF $script &= ' WinMove($title,"",$pos_x,$pos_y)' & @CRLF $script &= ' Exit' & @CRLF $script &= ' EndIf' & @CRLF $script &= 'EndFunc' & @CRLF FileWrite($filename,$script) Run(@AutoItExe & " /AutoIt3ExecuteScript " & $filename) Sleep(250) $temp = FileOpenDialog($title, $initialDir, $filter, $options, $defaultPos) FileDelete($filename) FileChangeDir(@ScriptDir) Return $temp EndFunc Func _ChangeDesktopBackground($sFile, $iPosition=3) Local $sCLSID, $tBuffer, $hImage, $sTemp ; Convert JPG image to BMP image _GDI_Startup() $hImage = _GDI_LoadFromFile($sFile) $sCLSID = _GDI_GetEncoderCLSID("BMP") $sTemp = _Str_ChangeFileExt($sFile, ".bmp") _GDI_SaveToFile($hImage, $sTemp, $sCLSID) _GDI_DisposeImage($hImage) _GDI_Shutdown() ; Set wallpaper position Switch $iPosition Case 1 ; Tile RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper' , 'reg_sz', '1') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0') Case 2 ; Center RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper' , 'reg_sz', '0') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0') Case 3 ; Stretch RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper' , 'reg_sz', '0') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2') EndSwitch ; Set wallpaper $tBuffer = DllStructCreate("char Text[" & StringLen($sTemp) + 1 & "]") DllStructSetData($tBuffer, "Text", $sTemp) _API_SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, DllStructGetPtr($tBuffer), BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE)) EndFunc Edited September 30, 2007 by Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
hutch Posted August 21, 2007 Share Posted August 21, 2007 excelent job , it work fine I will watch how you made this (how to force wallpaper change dynamically) Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted August 21, 2007 Share Posted August 21, 2007 Thats cool, i think i may have found a little bug, if you select multiple files to remove from the list it only removes 1 and it wont remove just 1 being selected. My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
Achilles Posted August 21, 2007 Author Share Posted August 21, 2007 Thats cool, i think i may have found a little bug, if you select multiple files to remove from the list it only removes 1 and it wont remove just 1 being selected.I can't get this error. I changed the code in my op to what I was using, so that might of fixed it.excelent job , it work fineI will watch how you made this (how to force wallpaper change dynamically) I'm not sure if it's a good idea to use adlibenable() for such long periods of time... anybody know if there is anything wrong with doing that?I was kind of thinking of having an option so that if the time is less the five minutes if uses adlibenable(), if it's longer it just checks the time every second or so... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
hutch Posted August 22, 2007 Share Posted August 22, 2007 (edited) why don't you use the scheduler if you use it , the script will not always run (it charge the cpu only when launching and not all the time and there is less chance that it bug and user don't need to launch it with windows) Edited August 22, 2007 by hutch Link to comment Share on other sites More sharing options...
MCP Posted September 30, 2007 Share Posted September 30, 2007 (edited) @Piano_ManI like this script and I am trying to provide an updated version with a small language support and a small refactoring so that all of us can benefit, but I am currently facing a few difficulties at trying to understand a few variables scopes (e.g. $enabled) or action (e.g. $index inside _ChangePic()) and I do not understand what _MoveFileOpenDialog() is exactly doing and why an external script has to be generated (thus blocking portability).Could please provide any info? Thanks a lot Piano_Man.Here follows what I am currently working on:Wallpaper Changer.au3[autoit]#region *** INCLUDES ***#include <GUIConstants.au3>#Include <Constants.au3>#Include <GuiListView.au3>#include <File.au3>#include <Array.au3>#include 'AutoItLib.au3'#include "Config.au3"#NoTrayIcon#endregion#region *** OPTS ***Opt('GUIOnEventMode', 1)Opt('TrayOnEventMode', 1)Opt('OnExitFunc', '_Exit')Opt('TrayMenuMode', 1)Opt('MustDeclareVars', 1)#endregion#region *** GLOBAL CONSTS ***Global Const $WM_NOTIFY = 0x004EGlobal Const $NM_FIRST = 0Global Const $NM_CLICK = ($NM_FIRST - 2)Global Const $NM_DBLCLK = ($NM_FIRST - 3)#endregion#region *** GLOBAL VARIABLES ***Global $gShown[1] ; Array of all shown picturesGlobal $gIndex = 1Global $gLstDirectories, $gPicPreview, $gtiTime, $gWallpaperOptionGUI ; GUI ObjectsGlobal $lastSelected, $gTime, $doubleClicked, $rad[1], $gShowing, $gEnabled ; Variables#endregionMain()Func Main() _Singleton($L_APP_TITLE) Local $firstTime = False If Not FileExists($INI_FILE) Then $firstTime = True EndIf $gEnabled = IniRead($INI_FILE, 'Enabled', 'Current', 'UNKNOWN') If $gEnabled == 'UNKNOWN' Or $gEnabled == 'True' Then $gEnabled = True IniWrite($INI_FILE, 'Enabled', 'Current', True) EndIf _CreateTrayMenu() If $firstTime Then $gShowing = -1 _CreateGUI() Else $gShown[0] = RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper') $gShowing = $gShown[0] Local $temp = _GetPosition() IniWrite($INI_FILE, 'Images', $gShown[0], '1|' & $temp) $gTime = IniRead($INI_FILE, 'Time', 'Current', 'NOT FOUND') If $gTime == 'NOT FOUND' Then $gTime = 10 IniWrite($INI_FILE, 'Time', 'Current', 10) Else If $gTime < 1 Then $gTime = 1 IniWrite($INI_FILE, 'Time', 'Current', 1) EndIf EndIf If $gEnabled Then _StartRotator() EndIf _DoSleep()EndFunc ;==>MainFunc _CreateTrayMenu() TrayCreateItem($L_APP_CONFIG) TrayItemSetState(-1, $TRAY_DEFAULT) TrayItemSetOnEvent(-1, '_CreateGUI') TrayCreateItem('') TrayCreateItem($L_APP_NEXT) TrayItemSetOnEvent(-1, '_Next') TrayCreateItem('') TrayCreateItem($L_APP_ENABLED) TrayItemSetOnEvent(-1, '_Status') If $gEnabled Then TrayItemSetState(-1, $TRAY_CHECKED) TrayCreateItem('') TrayCreateItem($L_APP_QUIT) TrayItemSetOnEvent(-1, '_ExitProgram') TraySetClick(8) TraySetState()EndFunc ;==>_CreateTrayMenuFunc _DoSleep() While 1 Sleep(5000) WEndEndFunc ;==>_DoSleepFunc _StartRotator() _ChangePic() AdlibEnable('_ChangePic', $gTime * 1000 * 60)EndFunc ;==>_StartRotatorFunc _Next() _ChangePic()EndFunc ;==>_NextFunc _ChangePic() Local $aOld = IniReadSection($INI_FILE, 'Images') If Not IsArray($aOld) Then Return Local $aPurified = _Purify($aOld) Local $tipCreating If $aPurified[0][0] == 1 Then _ChangeDesktopBackground($aPurified[1][0], $aPurified[1][1]) $tipCreating = StringSplit($aPurified[1][0], '\') $gShowing = $aPurified[1][0] TraySetToolTip($L_TIP_CURR & $tipCreating[$tipCreating[0]]) ElseIf $aPurified[0][0] == 2 Then If $aPurified[1][0] = $gShown[0] Then _ChangeDesktopBackground($aPurified[2][0], $aPurified[2][1]) $gShown[0] = $aPurified[2][0] $gShowing = $aPurified[2][0] $tipCreating = StringSplit($aPurified[2][0], '\') Else _ChangeDesktopBackground($aPurified[1][0], $aPurified[1][1]) $gShown[0] = $aPurified[1][0] $gShowing = $aPurified[1][0] $tipCreating = StringSplit($aPurified[1][0], '\') EndIf TraySetToolTip($L_TIP_CURR & $tipCreating[$tipCreating[0]]) ElseIf $aPurified[0][0] > 2 Then ReDim $gShown[$aPurified[0][0]] Local $rand, $new, $position, $pass Do $rand = Random(1, $aPurified[0][0] + 1) $new = $aPurified[$rand][0] $position = $aPurified[$rand][1] $pass = True For $a = 0 To $aPurified[0][0] - 1 If $new = $gShown[$a] Then $pass = False Next Until $pass = True _ChangeDesktopBackground($new, $position) $gShowing = $new If $gIndex > $aPurified[0][0] - 2 Then $gIndex = 0 EndIf $gShown[$gIndex] = $new $gIndex += 1 $tipCreating = StringSplit($new, '\') TraySetToolTip($L_TIP_CURR & $tipCreating[$tipCreating[0]]) EndIfEndFunc ;==>_ChangePicFunc _Purify($array) Local $aNew[1][2] Local $index = 1 $aNew[0][0] = $array[0][0] Local $aTemp For $a = 1 To $array[0][0] $aTemp = StringSplit($array[$a][1], '|') If $aTemp[1] == 1 Then ReDim $aNew[$index + 1][2] $aNew[$index][0] = $array[$a][0] $aNew[$index][1] = $aTemp[2] $index += 1 Else $aNew[0][0] -= 1 EndIf Next Return $aNewEndFunc ;==>_PurifyFunc _Status() $gEnabled = Not $gEnabled IniWrite($INI_FILE, 'Enabled', 'Current', $gEnabled) If $gEnabled Then If WinExists($L_APP_TITLE) Then Return _StartRotator() Else AdlibDisable() EndIfEndFunc ;==>_StatusFunc _CreateGUI() If WinExists($L_APP_TITLE) Then Return AdlibDisable() Local Const $WIDTH_X_HEIGHT_CONVERSION = @DesktopWidth / @DesktopHeight Local Const $HEIGHT = 300 Local Const $SECOND_COLUMN_X = 415 GUICreate($L_APP_TITLE, 428 + $WIDTH_X_HEIGHT_CONVERSION * $HEIGHT, 406) GUISetOnEvent($GUI_EVENT_CLOSE, '_Ok') GUICtrlCreateLabel($L_CFG_DESC, 10, 0, 195, 25, $SS_CENTERIMAGE) $gLstDirectories = GUICtrlCreateListView($L_CFG_COLUMNS, 10, 25, 395, $HEIGHT, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER), BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) _GUICtrlListViewSetColumnWidth($gLstDirectories, 0, 250) _GUICtrlListViewSetColumnWidth($gLstDirectories, 1, 700) _GUICtrlListViewSetColumnWidth($gLstDirectories, 2, 160) GUICtrlCreateButton($L_CFG_FILES, 10, $HEIGHT + 40, 95, 25) GUICtrlSetOnEvent(-1, '_AddFile') GUICtrlCreateButton($L_CFG_FOLDERS, 10, $HEIGHT + 70, 95, 25) GUICtrlSetOnEvent(-1, '_AddFolder') GUICtrlCreateButton($L_CFG_CHK_ALL, 110, $HEIGHT + 40, 95, 25) GUICtrlSetOnEvent(-1, '_CheckAll') GUICtrlCreateButton($L_CFG_UNCHK_ALL, 110, $HEIGHT + 70, 95, 25) GUICtrlSetOnEvent(-1, '_UncheckAll') GUICtrlCreateButton($L_CFG_SEL_ALL, 210, $HEIGHT + 40, 95, 25) GUICtrlSetOnEvent(-1, '_SelectAll') GUICtrlCreateButton($L_CFG_UNSEL_ALL, 210, $HEIGHT + 70, 95, 25) GUICtrlSetOnEvent(-1, '_UnselectAll') GUICtrlCreateButton($L_CFG_SEL_DEL, 310, $HEIGHT + 40, 95, 55, $BS_MULTILINE) GUICtrlSetOnEvent(-1, '_RemoveSelected') GUICtrlCreateLabel($L_CFG_WP_SEL, 420, $HEIGHT + 45, 200, 25) $gtiTime = GUICtrlCreateInput('', 420, $HEIGHT + 75, 42, 20) GUICtrlCreateLabel($L_CFG_WP_MIN, 470, $HEIGHT + 75, 60, 25) Local $aTemp = IniReadSection($INI_FILE, 'Images') If Not IsArray($aTemp) Then Local $preview = RegRead('HKEY_CURRENT_USER\Control Panel\Desktop', 'Wallpaper') Local $array = _ConvertDir($preview) Local $tempPosition = _GetPosition() GUICtrlCreateListViewItem($array[0] & '|' & $array[1] & '|' & _ConvertToText($tempPosition), $gLstDirectories) GUICtrlSetState(-1, $GUI_CHECKED) IniWrite($INI_FILE, 'Images', $array[1] & '\' & $array[0], '1|' & $tempPosition) $gPicPreview = GUICtrlCreatePic($preview, $SECOND_COLUMN_X, 25, $WIDTH_X_HEIGHT_CONVERSION * $HEIGHT, $HEIGHT, $SS_SUNKEN) $lastSelected = 1 $gShown[0] = $preview Else Local $array For $a = 1 To $aTemp[0][0] $array = _ConvertDir($aTemp[$a][0]) Local $tempSplit = StringSplit($aTemp[$a][1], '|') GUICtrlCreateListViewItem($array[0] & '|' & $array[1] & '|' & _ConvertToText($tempSplit[2]), $gLstDirectories) If $tempSplit[1] = 1 Then GUICtrlSetState(-1, $GUI_CHECKED) If $gShowing = $aTemp[$a][0] Then $lastSelected = $a $gPicPreview = GUICtrlCreatePic($aTemp[$a][0], $SECOND_COLUMN_X, 25, $WIDTH_X_HEIGHT_CONVERSION * $HEIGHT, $HEIGHT, $SS_SUNKEN) GUICtrlSetImage($gPicPreview, $aTemp[$a][1] & '\' & $aTemp[$a][0]) _GUICtrlListViewSetItemSelState($gLstDirectories, $a - 1, 1, 1) EndIf Next EndIf $gTime = IniRead($INI_FILE, 'Time', 'Current', 'NOT FOUND') If $gTime = 'NOT FOUND' Then $gTime = 20 GUICtrlSetData($gtiTime, $gTime) IniWrite($INI_FILE, 'Time', 'Current', 20) Else If $gTime < 1 Then $gTime = 1 IniWrite($INI_FILE, 'Time', 'Current', 1) EndIf GUICtrlSetData($gtiTime, $gTime) EndIf GUICtrlCreateButton($L_BTN_OK, 690, $HEIGHT + 40, 100, 55) GUICtrlSetOnEvent(-1, '_Ok') GUIRegisterMsg($WM_NOTIFY, 'WM_Notify_Events') GUISetState()EndFunc ;==>_CreateGUIFunc _GetPosition() Local $rc = RegRead('HKCU\Control Panel\Desktop', 'TileWallpaper') If $rc <> '1' Then $rc = RegRead('HKCU\Control Panel\Desktop', 'WallpaperStyle') If $rc = '2' Then $rc = '3' Else $rc = '2' EndIf EndIf Return $rcEndFunc ;==>_GetPositionFunc _Ok() GUISetState(@SW_HIDE) AdlibDisable() $gTime = GUICtrlRead($gtiTime) IniWrite($INI_FILE, 'Time', 'Current', $gTime) _UpdateChecks() _ChangePic() GUIDelete() AdlibEnable('_ChangePic', $gTime * 1000 * 60) ;To convert to minutes...EndFunc ;==>_OkFunc _UpdateChecks() Local $aTemp For $a = 0 To _GUICtrlListViewGetItemCount($gLstDirectories) - 1 $aTemp = _GUICtrlListViewGetItemTextArray($gLstDirectories, $a) If _GUICtrlListViewGetCheckedState($gLstDirectories, $a) == 0 Then IniWrite($INI_FILE, 'Images', $aTemp[2] & '\' & $aTemp[1], 0 & '|' & _ConvertToNum($aTemp[3])) Else IniWrite($INI_FILE, 'Images', $aTemp[2] & '\' & $aTemp[1], 1 & '|' & _ConvertToNum($aTemp[3])) EndIf NextEndFunc ;==>_UpdateChecksFunc _ConvertToNum($value) Switch $value Case 'Tile' Return 1 Case 'Center' Return 2 Case 'Stretch' Return 3 Case Else Return 3 EndSwitchEndFunc ;==>_ConvertToNumFunc _ConvertToText($value) Switch $value Case 1 Return 'Tile' Case 2 Return 'Center' Case 3 Return 'Stretch' Case Else Return 'Stretch' EndSwitchEndFunc ;==>_ConvertToTextFunc _IsOnList($value) Local $textArray For $a = 0 To _GUICtrlListViewGetItemCount($gLstDirectories) - 1 $textArray = _GUICtrlListViewGetItemTextArray($gLstDirectories, $a) If $value = $textArray[2] & '\' & $textArray[1] Then Return True EndIf Next Return FalseEndFunc ;==>_IsOnListFunc _UpdatePreviewPic() If _GUICtrlListViewGetSelectedIndices($gLstDirectories) <> -1 Then If _GUICtrlListViewGetSelectedIndices($gLstDirectories) <> $lastSelected Then Local $index = _GUICtrlListViewGetSelectedIndices($gLstDirectories) Local $text = _GUICtrlListViewGetItemTextArray($gLstDirectories, $index) GUICtrlSetImage($gPicPreview, $text[2] & '\' & $text[1]) $lastSelected = $index EndIf EndIfEndFunc ;==>_UpdatePreviewPicFunc WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event If $wParam = $gLstDirectories Then $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Switch $event Case $NM_CLICK _UpdatePreviewPic() Case $NM_DBLCLK $doubleClicked = _GUICtrlListViewGetSelectedIndices($gLstDirectories) _RadioOptionBox($L_POS_TITLE, $L_POS_CHOICE, True, 'Tile', 'Center', 'Stretch') EndSwitch EndIf $tagNMHDR = 0 Return $GUI_RUNDEFMSGEndFunc ;==>WM_Notify_EventsFunc _RadioOptionBox($title, $message, $guiOnEvent, $rad_0, $rad_1, $rad_2 = '', $rad_3 = '', $rad_4 = '', $rad_5 = '', $rad_6 = '', $rad_7 = '', $rad_8 = '', $rad_9 = '', $rad_10 = '') If $title == '' Or $message == '' Or $rad_0 == '' Or $rad_1 == '' Then Return Local $width = 400 Local $i_UBound = @NumParams - 3 ReDim $rad[$i_UBound] $gWallpaperOptionGUI = GUICreate($title, $width, 100 + (@NumParams - 3) * 25, -1, -1, $DS_SETFOREGROUND) GUICtrlCreateLabel($message, 10, 10, $width - 10, 25) ; , $SS_CENTER) Local $temp = _GUICtrlListViewGetItemTextArray($gLstDirectories, $doubleClicked) ; warning: pay attention to EVAL statement if changing variable names For $i_Index = 0 To $i_UBound - 1 $rad[$i_Index] = GUICtrlCreateRadio(Eval("rad_" & String($i_Index)), 45, $i_Index * 25 + 30, 270, 25) If $i_Index + 1 = _ConvertToNum($temp[3]) Then GUICtrlSetState(-1, $GUI_CHECKED) Next Local $cancel = GUICtrlCreateButton($L_BTN_CANCEL, $width / 2 - 90, ($i_UBound) * 25 + 40, 80, 25) GUICtrlSetOnEvent(-1, '_RadioCancel') Local $ok = GUICtrlCreateButton($L_BTN_OK, $width / 2 + 10, ($i_UBound) * 25 + 40, 80, 25) GUICtrlSetOnEvent(-1, '_RadioOk') GUISetState()EndFunc ;==>_RadioOptionBoxFunc _RadioCancel() GUIDelete($gWallpaperOptionGUI)EndFunc ;==>_RadioCancelFunc _RadioOk() Local $temp, $checkState For $a = 0 To 2 If GUICtrlRead($rad[$a]) == $GUI_CHECKED Then $temp = _GUICtrlListViewGetItemTextArray($gLstDirectories, $doubleClicked) If $temp[3] <> _ConvertToText($a + 1) Then _GUICtrlListViewSetItemText($gLstDirectories, $doubleClicked, 2, _ConvertToText($a + 1)) $checkState = _GUICtrlListViewGetCheckedState($gLstDirectories, $doubleClicked) IniWrite($INI_FILE, 'Images', $temp[2] & '\' & $temp[1], $checkState & '|' & $a + 1) EndIf EndIf Next GUIDelete($gWallpaperOptionGUI)EndFunc ;==>_RadioOkFunc _CheckAll() For $a = 0 To _GUICtrlListViewGetItemCount($gLstDirectories) - 1 _GUICtrlListViewSetCheckState($gLstDirectories, $a, 1) NextEndFunc ;==>_CheckAllFunc _UncheckAll() For $a = 0 To _GUICtrlListViewGetItemCount($gLstDirectories) - 1 _GUICtrlListViewSetCheckState($gLstDirectories, $a, 0) NextEndFunc ;==>_UncheckAllFunc _SelectAll() For $a = 0 To _GUICtrlListViewGetItemCount($gLstDirectories) - 1 _GUICtrlListViewSetItemSelState($gLstDirectories, $a, 1) NextEndFunc ;==>_SelectAllFunc _UnselectAll() For $a = 0 To _GUICtrlListViewGetItemCount($gLstDirectories) - 1 _GUICtrlListViewSetItemSelState($gLstDirectories, $a, 0) NextEndFunc ;==>_UnselectAllFunc _RemoveSelected() Local $indices = _GUICtrlListViewGetSelectedIndices($gLstDirectories, 1) If Not IsArray($indices) Then Return Local $temp[1] Local $split, $toAdd For $a = 1 To $indices[0] ReDim $temp[$a + 1] $split = StringSplit(_GUICtrlListViewGetItemText($gLstDirectories, $indices[$a]), '|') $toAdd = $split[2] & '\' & $split[1] $temp[$a] = $toAdd $temp[0] += 1 Next For $a = 1 To $temp[0] IniDelete($INI_FILE, 'Images', $temp[$a]) Next _GUICtrlListViewDeleteItemsSelected($gLstDirectories)EndFunc ;==>_RemoveSelectedFunc _AddFile() Local $dir If DirGetSize($MY_PICTURES) > 0 Then $dir = $MY_PICTURES Else $dir = @MyDocumentsDir EndIf Local $temp = FileOpenDialog($L_OPN_FILE, $dir, '(*.jpg;*.bmp;*.gif;*.png)', 7, '') If $temp <> '' Then Local $splitTemp = StringSplit($temp, '|') Local $array If $splitTemp[0] == 1 Then $array = _ConvertDir($temp) If _IsOnList($array[1] & '\' & $array[0]) Then Return GUICtrlCreateListViewItem($array[0] & '|' & $array[1] & '|' & 'Stretch', $gLstDirectories) GUICtrlSetState(-1, $GUI_CHECKED) IniWrite($INI_FILE, 'Images', $array[1] & '\' & $array[0], '1|3') Else For $a = 2 To $splitTemp[0] $array = _ConvertDir($splitTemp[1] & '\' & $splitTemp[$a]) If Not _IsOnList($array[1] & '\' & $array[0]) Then GUICtrlCreateListViewItem($array[0] & '|' & $array[1] & '|' & 'Stretch', $gLstDirectories) GUICtrlSetState(-1, $GUI_CHECKED) IniWrite($INI_FILE, 'Images', $array[1] & '\' & $array[0], '1|3') EndIf Next EndIf EndIfEndFunc ;==>_AddFileFunc _AddFolder() Local $dir If DirGetSize($MY_PICTURES) > 0 Then $dir = $MY_PICTURES Else $dir = @MyDocumentsDir EndIf Local $temp = FileSelectFolder($L_OPN_FOLDER, @HomeDrive, 2, $dir) If $temp <> '' Then Local $folderArray = _FileListToArray($temp) $folderArray = _FilterArray($folderArray, 'jpg|bmp|gif') For $a = 1 To $folderArray[0] If Not _IsOnList($temp & '\' & $folderArray[$a]) Then GUICtrlCreateListViewItem($folderArray[$a] & '|' & $temp & '|' & 'Stretch', $gLstDirectories) GUICtrlSetState(-1, $GUI_CHECKED) IniWrite($INI_FILE, 'Images', $temp & '\' & $folderArray[$a], '1|3') EndIf Next EndIfEndFunc ;==>_AddFolderFunc _ExitProgram() If WinExists($L_APP_TITLE) Then GUIDelete() _UpdateChecks() EndIf ExitEndFunc ;==>_ExitProgramFunc _FilterArray($array, $filter) Dim $tempArray[1] Local $filterSplit = StringSplit($filter, '|') Local $pass, $itemSplit For $a = 1 To $array[0] $itemSplit = StringSplit($array[$a], '.') $pass = False For $b = 1 To $filterSplit[0] If $itemSplit[$itemSplit[0]] == $filterSplit[$b] Then $pass = True EndIf Next If $pass Then _ArrayAdd($tempArray, $array[$a]) $tempArray[0] += 1 EndIf Next Return $tempArrayEndFunc ;==>_FilterArrayFunc _ConvertDir($dir) Local $array[2] = ['', ''] Local $tempSplit = StringSplit($dir, '\') For $a = 1 To $tempSplit[0] - 1 $array[1] &= $tempSplit[$a] & '\' Next $array[1] = StringTrimRight($array[1], 1) $array[0] = $tempSplit[$tempSplit[0]] Return $arrayEndFunc ;==>_ConvertDirFunc _ChangeDesktopBackground($sFile, $iPosition = 3) Local $sCLSID, $tBuffer, $hImage, $sTemp ; Convert JPG image to BMP image _GDI_Startup () $hImage = _GDI_LoadFromFile ($sFile) $sCLSID = _GDI_GetEncoderCLSID ("BMP") $sTemp = _Str_ChangeFileExt ($sFile, ".bmp") _GDI_SaveToFile ($hImage, $sTemp, $sCLSID) _GDI_DisposeImage ($hImage) _GDI_Shutdown () ; Set wallpaper position Switch $iPosition Case 1 ; Tile RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '1') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0') Case 2 ; Center RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0') Case 3 ; Stretch RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2') EndSwitch ; Set wallpaper $tBuffer = DllStructCreate("char Text[" & StringLen($sTemp) + 1 & "]") DllStructSetData($tBuffer, "Text", $sTemp) _API_SystemParametersInfo ($SPI_SETDESKWALLPAPER, 0, DllStructGetPtr($tBuffer), BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))EndFunc ;==>_ChangeDesktopBackground Edited October 3, 2007 by MCP Link to comment Share on other sites More sharing options...
MCP Posted September 30, 2007 Share Posted September 30, 2007 why don't you use the schedulerI agree with Piano_man's choice. Not using the scheduler allows every user - even one with no administrative rights - to run it and it is nice not to be too much intrusive so that a user can run it and one not, depending on taste. if you use it, the script will not always run (it charge the cpu only when launching and not all the time...This is true, but since it depends on the single user preference, I think it should be fine if the script is not too aggressively taking resources. Link to comment Share on other sites More sharing options...
MCP Posted September 30, 2007 Share Posted September 30, 2007 I think (ehm, I hope) that all of this is currently working like your version.Well, as I said: I hoped. Preview doesn't work anymore. Gotta check a few scopes.. Link to comment Share on other sites More sharing options...
Achilles Posted September 30, 2007 Author Share Posted September 30, 2007 I do not understand what _MoveFileOpenDialog() is exactly doing and why an external script has to be generated (thus blocking portability). This is used in order to position the FileOpenDialog(). The default FileOpenDialog() is placed at the top left of the users screen which I do not like because it makes the user move the mouse all the way to the top left of the screen. This is not at all necessary and could easily be taken out and replaced with just a normal FileOpenDialog().I like this script and I am trying to provide an updated version with a small language support and a small refactoring so that all of us can benefitSounds great! I am currently facing a few difficulties at trying to understand a few variables scopes (e.g. $enabled) or action (e.g. $index inside _ChangePic())$enabled, if I remember right, is the a global variable that determines if the Wallpaper Rotater is actually doing anything. I admit that disabling the rotater would make the program completely useless, but I thought that maybe somebody would want to use it. $index was originally supposed to be used for keeping pictures from repeating. I realized that this was not working anymore, thanks to your asking about it, and have fixed it (I think). View the original code for an update. I also changed the listview so that when you click on one of the items it automatically updates, which is stopped doing for some reason. Let me know if anything is not clear and I will try to explain it in more detail. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Achilles Posted September 30, 2007 Author Share Posted September 30, 2007 Well, as I said: I hoped. Preview doesn't work anymore. Gotta check a few scopes.. Yes, I realized that wasn't working, should be good now! Check the code again... I'm not really sure why it stopped working... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
MCP Posted September 30, 2007 Share Posted September 30, 2007 This is used in order to position the FileOpenDialog(). The default FileOpenDialog() is placed at the top left of the users screen which I do not like because it makes the user move the mouse all the way to the top left of the screen. This is not at all necessary and could easily be taken out and replaced with just a normal FileOpenDialog().Thank you.$enabled, if I remember right, is the a global variable that determines if the Wallpaper Rotater is actually doing anything. I admit that disabling the rotater would make the program completely useless, but I thought that maybe somebody would want to use it.Well I think it is nice to be able to stop it. I have appreciated it. Thx. Link to comment Share on other sites More sharing options...
MCP Posted October 3, 2007 Share Posted October 3, 2007 Preview doesn't work anymore. Gotta check a few scopes.. Now fixed. Link to comment Share on other sites More sharing options...
MCP Posted October 7, 2007 Share Posted October 7, 2007 I think I have found a possible error in _CreateGUI, where AdLibDisable() is executed: it should not be necessary and, on the contrary, it might create strange behaviors that need to be fixed by forcibly closing with a wallpaper update/rotation (in which a new AdLibDisable() is correctly executed). Link to comment Share on other sites More sharing options...
Achilles Posted October 13, 2007 Author Share Posted October 13, 2007 I think I have found a possible error in _CreateGUI, where AdLibDisable() is executed: it should not be necessary and, on the contrary, it might create strange behaviors that need to be fixed by forcibly closing with a wallpaper update/rotation (in which a new AdLibDisable() is correctly executed).I'm not sure what you mean. I realized, upon looking at my code again, that I have an extra AdLibDisable() in the _Ok function which is unnecessary, but I did not want the wallpaper changing while the options GUI is open. Now that I think about it I'm not sure why but I think it made some of the coding simpler knowing that the list wasn't going to be changing while the wallpaper could be changing.Let me know if I misunderstood, as I think I have, what you meant! My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
MCP Posted October 13, 2007 Share Posted October 13, 2007 I'm not sure what you mean. I realized, upon looking at my code again, that I have an extra AdLibDisable() in the _Ok function which is unnecessary ...Thanks for the _Ok function underlining, I was looking at it and guessing what I was missing... Let me know if I misunderstood, as I think I have, what you meant!No, I think you did not, it was me the one who was not clear... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now