| Lahace |
| | ecco un programmino che permette di cambiare il wallpaper del desktop in un tempo determinato ^^ il pulsante avvia all'avvio di windows non funziona! source: CODICE #include "wallpaper.au3" #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3>
Opt("TrayMenuMode",1) $Form1 = GUICreate("Wallpaper Changer", 409, 112, 192, 124) GUISetBkColor(0xFFFFFF) GUICtrlCreateLabel("Numero di wallpaper:", 8, 8, 103, 17) $Input1 = GUICtrlCreateInput("", 112, 5, 65, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER)) $Group1 = GUICtrlCreateGroup(" Impostazioni ", 8, 32, 393, 73) $Button1 = GUICtrlCreateButton("Start", 304, 56, 91, 17, $WS_GROUP) $Button2 = GUICtrlCreateButton("Stop", 304, 80, 89, 17, $WS_GROUP) $Button3 = GUICtrlCreateButton("Carica Impostazioni", 16, 80, 107, 17, $WS_GROUP) $Checkbox1 = GUICtrlCreateCheckbox("Avvia con windows", 16, 56, 121, 17) $Group2 = GUICtrlCreateGroup("", 208, 32, 9, 73) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label1 = GUICtrlCreateLabel("Attesa", 232, 8, 34, 17) $Input2 = GUICtrlCreateInput("", 272, 5, 65, 21) GUICtrlCreateLabel("millisecondi", 344, 8, 57, 17) $tray1 = TrayCreateItem("Mostra la finestra") $tray2 = TrayCreateItem("Nascondi la finestra") TrayCreateItem("") $tray4 = TrayCreateItem("Stop") $tray3 = TrayCreateItem("Chiudi") TrayCreateItem("") GUICtrlCreateGroup("", -99, -99, 1, 1) $o = 1 $state = False $inn = 0 $inum = IniReadSection(@ScriptDir & "\opt.ini" , "wallpaper") If IsArray($inum) Then For $r = 1 to $inum[0][0] If FileExists(IniRead(@ScriptDir & "\opt.ini" , "wallpaper" , "wp" & $r , "")) Then ; Else $inn += 1 EndIf Next If $inn >= 1 Then IniWrite(@ScriptDir & "\opt.ini" , "wi" , "con" , "no") Else IniWrite(@ScriptDir & "\opt.ini" , "wi" , "con" , "si") EndIf Else IniWrite(@ScriptDir & "\opt.ini" , "wi" , "con" , "no") EndIf If IniRead(@ScriptDir & "\opt.ini" , "startup" , "check" , "no") = "si" Then GUICtrlSetState($Checkbox1 , 1) $tot1 = IniReadSection(@ScriptDir & "\opt.ini" , "wallpaper") $tot = $tot1[0][0] $sec = IniRead(@ScriptDir & "\opt.ini" , "time" , "time" , "60000") _Wallpaper() Else GUISetState(@SW_SHOW) GUICtrlSetState($Checkbox1 , 4) GUICtrlSetState($Button1 , 64) GUICtrlSetState($Button2 , 128) EndIf If IniRead(@ScriptDir & "\opt.ini" , "wi" , "con" , "no") = "no" Then GUICtrlSetState($button3 , 128) EndIf While 1 Switch GUIGetMsg() Case -3 Exit Case $Button1 _regwallpaper() _Wallpaper() Case $Button3 If IniRead(@ScriptDir & "\opt.ini" , "wi" , "con" , "no") = "si" Then $tot = IniReadSection(@ScriptDir & "\opt.ini" , "wallpaper") $sec = IniRead(@ScriptDir & "\opt.ini" , "time" , "time" , "60000") _Wallpaper() Else MsgBox(0 , "Errore!" , "wallpaper non impostati correttamente") EndIf EndSwitch Switch TrayGetMsg() Case 0 ContinueLoop Case $tray1 GUISetState(@SW_SHOW) Case $tray2 GUISetState(@SW_HIDE) Case $tray3 Exit EndSwitch WEnd
Func _regwallpaper() $inum = IniReadSection(@ScriptDir & "\opt.ini" , "wallpaper") If IsArray($inum) Then For $l = 1 To $inum[0][0] IniDelete(@ScriptDir & "\opt.ini" , "wallpaper" , "wp" & $l) Next EndIf IniDelete(@ScriptDir & "\opt.ini" , "time" , "time") $tot = GUICtrlRead($Input1) $sec = GUICtrlRead($Input2) IniWrite(@ScriptDir & "\opt.ini" , "time" , "time" , GUICtrlRead($Input2)) If GUICtrlRead($Checkbox1) = 1 Then IniWrite(@ScriptDir & "\opt.ini" , "startup" , "check" , "si") Else IniWrite(@ScriptDir & "\opt.ini" , "startup" , "check" , "no") EndIf For $i = 1 To $tot $ib = FileOpenDialog("Seleziona wallpaper" , "" , "Wallpaper (*.bmp;*.jpg;*.jpeg)") If Not FileExists($ib) Then MsgBox(0 , "Errore!" , "File inesistente") $i -= 1 Else IniWrite(@ScriptDir & "\opt.ini" , "wallpaper" , "wp" & $i , $ib) If @error Then MsgBox(0 , "Errore!" , "Si è presentato un errore" & @CRLF & "ID errore: " & @error) EndIf Next EndFunc Func _Wallpaper() $tot = IniReadSection(@ScriptDir & "\opt.ini" , "wallpaper") $sec = IniRead(@ScriptDir & "\opt.ini" , "time" , "time" , "60000") GUICtrlSetState($Button1 , 128) GUICtrlSetState($Button2 , 64) Do If $state = False Then $time = TimerInit() $state = True EndIf $timed = TimerDiff($time) If $timed >= $sec Then $wp = IniRead(@ScriptDir & "\opt.ini" , "wallpaper" , "wp" & $o , "") If $wp = "" Or FileExists ($wp) = 0 Then ; Else _ChangeDesktopWallpaper($wp , 2) EndIf $state = False Else $state = True EndIf $o += 1 If $o > $tot[0][0] Then $o = 1 EndIf Until GUIGetMsg() = $Button2 Or TrayGetMsg() = $tray4 $state = False $o = 1 GUICtrlSetState($Button1 , 64) GUICtrlSetState($Button2 , 128) EndFunc include(wallpaper.au3): CODICE Func _ChangeDesktopWallpaper($bmp, $style = 0) ;=============================================================================== ; ; 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 ; Requirement(s): None. ; Return Value(s): On Success - Returns 0 ; On Failure - -1 ; Author(s): FlyingBoz ;Thanks: Larry - DllCall Example - Tested and Working under XPHome and W2K Pro ; Excalibur - Reawakening my interest in Getting This done. ; ;=============================================================================== 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
| | |
| |
|