Jump to content

Change Windows 7 Logon screen wallpaper


Triblade
 Share

Recommended Posts

I found out today, due to my collegue, that in Windows 7 Microsoft build an easy way to change the logon screen (computer lock screen as well) wallpaper.

I build a GUI around that in AutoIt to make life easy :party:

Edit: Edited 256 * 1024 to 250 * 1024 so that the outcome will become the intended 256Kb. Reported by ERSL

#cs ----------------------------------------------------------------------------

 AutoIt Version:     3.3.0.0 (beta)
 Author:         Triblade
 Last change:    29-may-2009
 Changes:        Changed 256*1024 to 250*1024, cause pictures may still be too large at 256*1024. Thanks to ERSL.

 Script Function:
    Script to easely change Windows 7 logon wallpaper.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#RequireAdmin

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Dim $underscore

If @OSArch = "X64" Then
    $destination_path = @WindowsDir & "\Sysnative\oobe\info\backgrounds"
Else
    $destination_path = @WindowsDir & "\System32\oobe\info\backgrounds"
EndIf

$file = "backgroundDefault.jpg"
$destination_file = $destination_path & "\" & $file

$gui = GUICreate("Windows 7 logonscreen wallpaper changer", 450, 130)

GUICtrlCreateGroup("Picture && path", 10, 10, 430, 50)
    $picture_label = GUICtrlCreateLabel("No picture selected.", 20, 33, 300, 25, $SS_LEFTNOWORDWRAP)
    $select_picture = GUICtrlCreateButton("Select JPG", 330, 25, 100, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("Messages && commit button", 10, 70, 430, 50)
    $msg_label = GUICtrlCreateLabel("All systems are go.", 20, 93, 300, 25, $SS_LEFTNOWORDWRAP)
    $commit_button = GUICtrlCreateButton("Commit", 330, 85, 100, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlSetState($commit_button, $GUI_DISABLE)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $select_picture
            $picture = FileOpenDialog("Choose the new logon screen wallpaper", @DocumentsCommonDir, "Images (*.jpg)", 1)
            If @error = 1 Then
                $picture = ""
                GUICtrlSetData($picture_label, "No picture selected.")
            Else
                GUICtrlSetData($picture_label, $picture)
                check_picture()
            EndIf
        Case $commit_button
            $underscore = ""
            set_registry()
            check_picture_destination()
            copy_picture()
            GUICtrlSetData($msg_label, "Picture set as new logon screen wallpaper!")
    EndSwitch
;Sleep(100)
WEnd

Func copy_picture()
    FileCopy($picture, $destination_file, 8)
EndFunc

Func check_picture_destination()
    If FileExists($destination_path) = 0 Then
        DirCreate($destination_path)
    EndIf
    While FileExists($destination_file) = 1
        $underscore = $underscore & "_"
        If FileMove($destination_file, $destination_path & "\old" & $underscore & $file) = 1 Then ExitLoop
    WEnd
EndFunc

Func set_registry()
    If @OSArch = "X64" Then
        RegWrite("HKEY_LOCAL_MACHINE64\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", 1)
    Else
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", 1)
    EndIf
EndFunc

Func check_picture()
    $filesize = FileGetSize($picture)
    If @error Then
        GUICtrlSetData($msg_label, "There is a error checking the filesize.")
        GUICtrlSetState($commit_button, $GUI_DISABLE)
    Else
        If $filesize > (250 * 1024) Then
            GUICtrlSetData($msg_label, "Picture is to heavy. It has to be 256 Kb or smaller.")
            GUICtrlSetState($commit_button, $GUI_DISABLE)
        Else
            GUICtrlSetData($msg_label, "Picture accepted.")
            GUICtrlSetState($commit_button, $GUI_ENABLE)
        EndIf
    EndIf
EndFunc

Since I work in 64 bit, some 64-bit check where needed. And damn, that 32-bit redirection of the system32 folder is annoying :)

After some googeling I found that "Sysnative" works instead of "system32". This works only in 64-bit systems that want to specifically write in the "system32" folder instead of the redirected "syswow64".

Edited by Triblade

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

im using se7en (32) now...but se7en logon changer has been build and published but not in autoit.. Hurm, you doesnt meant it for 32 bit?

It should works in 32 but, I just can't test it. :)

Hi!

It's run OK.

Cool :party: Good to know!

Cool! I'll try that out^^

edit: before I change anything with my system... how can I restore the original image?

Just delete every picture there is in this directory: "C:\Windows\System32\oobe\info\backgrounds\"

Or just make sure there is no picture called: "backgroundDefault.jpg" in there. (Or make sure that picture is larger then 256Kb :idea:)

If one of those conditions are true then the default Windows 7 picture is used instead of the custom one.

Note: This methode of setting a custom picture makes it auto-fit. There are ways to make a picture for every resolutions, but I didn't encorporate that as I found auto-fit working for almost everyone.

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

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...