Jump to content

Fade With WallPaper Changer


Recommended Posts

Hey Every1 ...............

I made a Wallpaper Changer............

Herez the Code

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=devilish.ico
#AutoIt3Wrapper_Outfile=....Change Wallpaper.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
If @Compiled Then RegWrite("HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRun", @ScriptName, "REG_SZ", @ScriptFullPath)
Global $search
#include-once

_Singleton(Binary("XAbhishekX"),0)
OnAutoItExitRegister("_exit")
Dim $iniread,$iniread0,$iniread1
Global Const $GUI_DROPACCEPTED = 8
Global Const $GUI_SHOW = 16
Global Const $GUI_HIDE = 32
Global Const $GUI_ENABLE = 64
Global Const $GUI_DISABLE = 128
Global Const $GUI_EVENT_CLOSE = -3
Global Const $GUI_CHECKED = 1
Global Const $tagSECURITY_ATTRIBUTES = "dword Length;ptr Descriptor;bool InheritHandle"
Global Const $GUI_UNCHECKED = 4
Global Const $BS_DEFPUSHBUTTON = 0x0001
Global Const $BS_PUSHLIKE = 0x1000
Global Const $GUI_EVENT_DROPPED = -13
Global Const $GUI_FOCUS = 256
Global $Images,$time,$Gfolder,$continue=True,$gUI,$default="",$ir,$no=1,$RANDOM=True,$it,$z
Global $imgformats[11]
$imgformats[0]="JPG"
$imgformats[1]="TIF"
$imgformats[2]="RLE"
$imgformats[3]="PNG"
$imgformats[4]="GIF"
$imgformats[5]="BMP"
$imgformats[7]="TIFF"
$imgformats[8]="JFIF"
$imgformats[9]="JPEG"
$imgformats[10]="JPE"
$imgformats[6]="DIB"
$directory=@AppDataDir&"Wallpaper"
DirCreate($directory)
$lNi=$directory&"Data.ini"
$Data="ïèª~¦A&â?NS-1-22994-65311`-123551||=123123"
HotKeySet("+!c","_toogle")
If _checkdirectory(0)=0 Then _guicreate(0)
Func _guicreate($pwm)
$gUI=GUICreate("Window",450,200,-1,-1,-1,0x00000018)
$label=GUICtrlCreateLabel("Type the Path of the Image or...",10,10,160,20)
If $pwm=0 Then
  $input=GUICtrlCreateInput("Drag Your Folder Containing Image Here",10,40,430,30)
  $type=GUICtrlCreateInput("45000",10,110,430,30)
EndIf
If $pwm=1 Then
  If $ir<>"" Then
   $input=GUICtrlCreateInput($ir,10,40,430,30)
  Else
   $input=GUICtrlCreateInput($iniread,10,40,430,30)
  EndIf
  If $it<>"" Then
   $type=GUICtrlCreateInput($it,10,110,430,30)
  Else
   $type=GUICtrlCreateInput($iniread0,10,110,430,30)
  EndIf
EndIf
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$label1=GUICtrlCreateLabel("Type The Time Interval Of Change Of Wallpaper in Milliseconds(Decimal Value Supported) ",10,80,439,20)
$ok=GUICtrlCreateButton("&OKAY",310,150,60,40,$BS_DEFPUSHBUTTON)
$cancel=GUICtrlCreateButton("E&XIT",380,150,60,40)
$browse=GUICtrlCreateButton("B&ROWSE",240,150,60,40)
$ChangeR=GUICtrlCreateCheckbox("RA&NDOM",10,150,90,40,$BS_PUSHLIKE)
If $RANDOM=True Then GUICtrlSetState(-1,$GUI_CHECKED)
If $RANDOM=False Then GUICtrlSetState(-1,$GUI_UNCHECKED)
GUISetState(@SW_SHOW,$gUI)
While 1
  $sMsg=GUIGetMsg()
  Switch $sMsg
   Case $ok
    If GUICtrlRead($ChangeR)=$GUI_CHECKED Then $RANDOM=True
    If GUICtrlRead($ChangeR)=$GUI_UNCHECKED Then $RANDOM=False
    $ir=GUICtrlRead($input)
    $it=GUICtrlRead($type)
    If $ir="" Or $type="" Or $ir="Drag Your Folder Containing Image Here" Then
     MsgBox(64,"Information","Type The Path Of The Folder",0,$gUI)
     GUICtrlSetData($input,"")
     GUICtrlSetState($input,$GUI_FOCUS)
     ContinueLoop
    ElseIf $it<10000 Then
     MsgBox(64,"Information","The Timer Should Be Minimum 10 Seconds",0,$gUI)
     GUICtrlSetData($type,10000)
     ContinueLoop
    ElseIf Not FileExists($ir) Then
     MsgBox(16,"Error","The File '"&$ir&"' Doesn't Exist.",0,$gUI)
     ContinueLoop
    ElseIf StringInStr(FileGetAttrib($ir),"D",1)=0 Then
     MsgBox(16,"Error","The File '"&$ir&"' is not a Directory",0,$gUI)
     ContinueLoop
    EndIf
    GUISetState(@SW_DISABLE,$gUI)
    If _findfileandchangepaper(_checkslash($ir),$it,0)=True Then
     GUIDelete($gUI)
     _checkdirectory($ir,$it)
     _traytip()
     _findfileandchangepaper(_checkslash($ir),$it)
     ExitLoop
    EndIf
   Case $browse
    $Gfolder=FileSelectFolder("Folder With Images","",1,$default,$gUI)
    $default=$Gfolder
    _checkdirectory($default,"0",True)
    GUICtrlSetData($input,$Gfolder)
   Case $cancel
    Exit
   Case $GUI_EVENT_CLOSE
    Exit
  EndSwitch
WEnd
EndFunc
Func _traytip()
Local $x=TimerInit()
While TimerDiff($x)<=12000
  ToolTip("To Change The Settings Press Shift+Alt+C",Default,Default,"Information",1,5)
  Sleep(10)
WEnd
ToolTip("")
EndFunc
Func _findfileandchangepaper($folder,$time,$pwm=1)
Local $suicude=0
$search=FileFindFirstFile($folder&"*.*")
While 1
  $file=FileFindNextFile($search)
  If @error Then ExitLoop
  $suicude+=1
WEnd
For $i In $imgformats
  $search=FileFindFirstFile($folder&"*."&$i)
  If $search=-1 Then $suicude-=1
  If $suicude=0 Then
   $continue=True
   MsgBox(64,"Information","There Are No Image Files In The Directory Or The Image Files Are Currently Not Supported",0,$gUI)
   Return False
  EndIf
  While 1
   $file=FileFindNextFile($search)
   If @error Then ExitLoop
   $Images&=$file&"|"
  WEnd
Next
If $pwm=0 Then Return True
$continue=False
$z=$folder
AdlibRegister('_change',$time)
While 1
  Sleep(10)
WEnd
EndFunc
Func _change()
$split=StringSplit($Images,"|",1)
If $RANDOM Then ChangeDesktopWallpaper($z&$split[Random(1,$split[0],1)],2)
If Not $RANDOM Then
  ChangeDesktopWallpaper($z&$split[$no],2)
  $no+=1
EndIf
If $no=$split[0] Then $no=1
EndFunc
Func _checkslash($2check)
If StringRight($2check,1)="" Then Return $2check
If StringRight($2check,1)<>"" Then Return $2check&""
EndFunc
Func _checkdirectory($folderx,$time="45000",$edit=False)
If $folderx="0" Then
  $iniread2=IniRead($lNi,$Data,"Random","0")
  $iniread=IniRead($lNi,$Data,"Folder","0")
  $iniread0=IniRead($lNi,$Data,"Time","0")
  $iniread1=IniRead($lNi,$Data,"Default",'""')
  If $iniread="0" Or $iniread0="0" Or $iniread2="0" Then
   Return 0
  Else
   $default=$iniread1
   $RANDOM=$iniread2
   _findfileandchangepaper(_checkslash($iniread),$iniread0)
  EndIf
ElseIf $edit=True Then
  IniWrite($lNi,$Data,"Default",$folderx)
ElseIf $folderx<>"0" Then
  IniWrite($lNi,$Data,"Folder",$folderx)
  IniWrite($lNi,$Data,"Time",$time)
  IniWrite($lNi,$Data,"Random",$RANDOM)
EndIf
EndFunc
Func _toogle()
AdlibUnRegister('_change')
$Images=""
_guicreate(1)
EndFunc
Func _exit()
FileClose($search)
Exit
EndFunc
Func DebugLog($Message, $Line = @ScriptLineNumber)
   If Not @Compiled Then
      ConsoleWrite("(" & $Line & "): " & $Message & @CRLF)
   EndIf
EndFunc   ;==>DebugLog
Func _Singleton($sOccurenceName, $iFlag = 0)
Local Const $ERROR_ALREADY_EXISTS = 183
Local Const $SECURITY_DESCRIPTOR_REVISION = 1
Local $pSecurityAttributes = 0
If BitAND($iFlag, 2) Then
  ; The size of SECURITY_DESCRIPTOR is 20 bytes.  We just
  ; need a block of memory the right size, we aren't going to
  ; access any members directly so it's not important what
  ; the members are, just that the total size is correct.
  Local $tSecurityDescriptor = DllStructCreate("dword[5]")
  Local $pSecurityDescriptor = DllStructGetPtr($tSecurityDescriptor)
  ; Initialize the security descriptor.
  Local $aRet = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", _
    "ptr", $pSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION)
  If @error Then Return SetError(@error, @extended, 0)
  If $aRet[0] Then
   ; Add the NULL DACL specifying access to everybody.
   $aRet = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", _
     "ptr", $pSecurityDescriptor, "bool", 1, "ptr", 0, "bool", 0)
   If @error Then Return SetError(@error, @extended, 0)
   If $aRet[0] Then
    ; Create a SECURITY_ATTRIBUTES structure.
    Local $structSecurityAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES)
    ; Assign the members.
    DllStructSetData($structSecurityAttributes, 1, DllStructGetSize($structSecurityAttributes))
    DllStructSetData($structSecurityAttributes, 2, $pSecurityDescriptor)
    DllStructSetData($structSecurityAttributes, 3, 0)
    ; Everything went okay so update our pointer to point to our structure.
    $pSecurityAttributes = DllStructGetPtr($structSecurityAttributes)
   EndIf
  EndIf
EndIf
Local $handle = DllCall("kernel32.dll", "handle", "CreateMutexW", "ptr", $pSecurityAttributes, "bool", 1, "wstr", $sOccurenceName)
If @error Then Return SetError(@error, @extended, 0)
Local $lastError = DllCall("kernel32.dll", "dword", "GetLastError")
If @error Then Return SetError(@error, @extended, 0)
If $lastError[0] = $ERROR_ALREADY_EXISTS Then
  If BitAND($iFlag, 1) Then
   Return SetError($lastError[0], $lastError[0], 0)
  Else
   Exit -1
  EndIf
EndIf
Return $handle[0]
EndFunc   ;==>_Singleton

Func ChangeDesktopWallpaper($bmp,$style)
;===============================================================================
; Usage: _ChangeDesktopWallPaper(@WindowsDir & '' & 'zapotec.bmp')
; Parameter(s): $bmp - Full Path to BitMap File (*.bmp)
; Requirement(s): None.
; Return Value(s): On Success - Returns 0
; On Failure - -1
;===============================================================================

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_USERControl PanelDesktop"
;Don't tile -  just center
If $style=0 Or $style=2 Then
RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style)
Else
RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", $style)
RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)
EndIf

RegWrite($REG_DESKTOP, "Wallpaper", "REG_SZ", $bmp)

DllCall("user32.dll", "int", "SystemParametersInfo","int", $SPI_SETDESKWALLPAPER, "int", 1, "str", $bmp, "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))

Return 0
EndFunc;==>_ChangeDestopWallpaper

I wanted a Functionality for the Current Background To Fade Out and a Black Screen Is Shown then The New BackGround Fades In.....................

Unluckily Im not having a Wide Knowledge of GDI and I have also tried Out _WinAPI_SetSysColors()........................

But No Luck............

I dont have a Wide Range Of Knowledge but on Experimenting I found That it Works With All the Image Formats.............

And the Func of ChangeDesktopWallpaper is not Written by me..........

I am Using Windows7 Ultimate 32 Bit .....Build 7600

Please Help Me If Possible................

Regards

Phoenix XL

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • 1 month later...

Simplifying

The following is the code of Wallpaper changer

Func ChangeDesktopWallpaper($bmp,$style)
;===============================================================================
; Usage: _ChangeDesktopWallPaper(@WindowsDir & '' & 'zapotec.bmp')
; Parameter(s): $bmp - Full Path to BitMap File (*.bmp)
; Requirement(s): None.
; Return Value(s): On Success - Returns 0
; On Failure - -1
;===============================================================================

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_USERControl PanelDesktop"
;Don't tile - just center
If $style=0 Or $style=2 Then
RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0)
RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style)
Else
RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", $style)
RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0)
EndIf

RegWrite($REG_DESKTOP, "Wallpaper", "REG_SZ", $bmp)

DllCall("user32.dll", "int", "SystemParametersInfo","int", $SPI_SETDESKWALLPAPER, "int", 1, "str", $bmp, "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE))

Return 0
EndFunc;==>_ChangeDestopWallpaper

Is it possible before the wallpaper is changed a fade in and fade out effect is applied

thnx for your time :)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

What i have tried yet

#include-once
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>



;$hGUI=GUICreate('',@DesktopWidth,@DesktopHeight,0,0,$WS_POPUP,$WS_EX_TOOLWINDOW)
;_WinAPI_SetWindowLong($hGUI, $GWL_HWNDPARENT, _GetDesktopWindow())
;GUISetState(@SW_SHOWMINNOACTIVE,$hGUI)
;Sleep(3000)
;GUISetState(@SW_SHOW,$hGUI)
;While GUIGetMsg()<>-3
;WEnd




_Fade2()

Func _Fade2($sPwm=0)
Local $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

; Draw a string
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle('[CLASS:Progman; TITLE:Program Manager]','','[CLASS:SHELLDLL_DefView; INSTANCE:1]'))
;ControlHide('[CLASS:Progman; TITLE:Program Manager]','','[CLASS:SHELLDLL_DefView; INSTANCE:1]')
;ConsoleWrite(0x0000000&@CRLF)
$hBrush=_GDIPlus_BrushCreateSolid(0)
Local $x=0
;For $i=0 To 255
While $x<>50
;ConsoleWrite($i&@CRLF)
_GDIPlus_BrushSetSolidColor($hBrush,0x50000000)
_GDIPlus_GraphicsFillRect($hGraphic,0,0,@DesktopWidth,@DesktopHeight,$hBrush)
;Sleep(300)
$x+=1
WEnd
$x=0
While $x<>50
_GDIPlus_BrushSetSolidColor($hBrush,0x50FFFFFF)
_GDIPlus_GraphicsFillRect($hGraphic,0,0,@DesktopWidth,@DesktopHeight,$hBrush)
;Sleep(300)
$x+=1
WEnd
;Next
; Clean up resources
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()

EndFunc ;==>_Main

please help me

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Not sure if this will work but here's an idea:

There's a wallpaper slideshow feature in windows 7 right?

http://www.withinwindows.com/2008/11/03/windows-7-to-let-users-create-a-desktop-slideshow-from-files-rss-feeds/

  • Make/Get a pitch black image.

  • For the fade in effect, get the current wallpaper to fade in to the black image, via desktop slideshow. Current image to black image.

  • For the fade out effect, set slideshow from black image to new wallpaper image.

  • Finally Disable slideshow.
I think the minimum interval of change is 10 seconds, but if it isnt smooth, you can try the different slideshow transition durations to see which AnimationDuration is smooth for the fade: http://www.winhelponline.com/blog/windows7-desktop-slideshow-animation-duration/

Also note that if the user has disabled Visual effect: Animate controls and elements inside windows in System Properties > Advanced tab > Performance Options, the fade wont work!

Dont have win7 so culdnt try myself :unsure:

Link to comment
Share on other sites

thnx i will look into it :)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...