Jump to content

Wallpaper Selector


alien13
 Share

Recommended Posts

Hey,

I decided to make a wallpaper selector for users who are making a shell that allows the user to have a wallpaper. This allows you to open a file(s) and preview files then save them as the background.. I'm not 100% sure if this will work as I haven't look at any shells that use wallpapers so, *Fingers crossed*.

Here is a screenshot and the attached script in action:

Posted Image

Hopefully a shell maker will find this useful!

alien13

~Feel free to help improve this script~

Wallpaper_Chooser.au3

Edited by alien13
Link to comment
Share on other sites

Hey,

I noticed when you 'save' the background image, because you delete and create the image it will overlap your controls

this should work tho,

; Forum Topic: http://www.autoitscript.com/forum/index.php?showtopic=55422
; Script by alien13   Updated by Robjong
#include <GUIConstants.au3>
#Include <GuiList.au3>
#include <File.au3>
#Include <IE.au3>

Global $start_dir = @DesktopDir
Dim $szDrive, $szDir, $szFName, $szExt

$WallpaperMain = GUICreate("Wallpaper Selector", 350, 406)
$Background = GUICtrlCreatePic("", 0, 0, 350, 406)
GuiCtrlSetState($Background, $GUI_DISABLE) ; disable the background image so it wont overlap the controls
$WallpaperList = GUICtrlCreateList("", 16, 208, 313, 149, $WS_VSCROLL)
$WallpaperPreview = GUICtrlCreatePic("", 44, 16, 257, 177, $WS_BORDER)
$About = GUICtrlCreateLabel("?", 339, 389, 15, 15)
$Browse = GUICtrlCreateButton("Browse", 24, 368, 70, 25, 0)
$Preview = GUICtrlCreateButton("Preview", 98, 368, 70, 25, 0)
$Save = GUICtrlCreateButton("Save", 172, 368, 70, 25, 0)
$Cancel = GUICtrlCreateButton("Cancel", 246, 368, 70, 25, 0)
GUISetState(@SW_SHOW, $WallpaperMain)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            quit()
        Case $Browse
            $SelectWP = FileOpenDialog("Please select an image(s) to add to the list.", $start_dir, "Images (*.jpg;*.bmp)", 1)
            If FileExists($SelectWP) Then
                $path = _PathSplit($SelectWP, $szDrive, $szDir, $szFName, $szExt)
                $start_dir = $szDrive & $szDir
                _GUICtrlListAddItem($WallpaperList, $SelectWP)
                GUICtrlSetImage($WallpaperPreview, $SelectWP) ; change image instead of creating a new one so it won't overlap the controls
            EndIf   
        Case $Preview
            $NewPic = _GUICtrlListGetText($WallpaperList, _GUICtrlListSelectedIndex($WallpaperList))
            If FileExists($NewPic) Then GUICtrlSetImage($WallpaperPreview, $NewPic); change image instead of creating a new one so it won't overlap the controls
        Case $Save
            $GetPic = _GUICtrlListGetText($WallpaperList, _GUICtrlListSelectedIndex($WallpaperList))
            If FileExists($GetPic) Then GUICtrlSetImage($Background, $GetPic) ; Tweak this to your needs
        Case $Cancel
            quit()
        Case $About
            MsgBox(32, "About", "Wallpaper Selector" & @CRLF & "Made by alien13 - http://www.alien13.com")
    EndSwitch
WEnd

Func quit()
    Exit
EndFunc

==========

Robjong

Link to comment
Share on other sites

alien13, you are registered for the OS Shell competition. Why do you share your scripts with other people?

Well,

I actually made and released this before the competition (at least before I knew about it) but I don't mind too much, as this is only a small thing, if they give credit to me for it, then it is ok.

^Hope that makes sense(Just woke up)

alien13

Link to comment
Share on other sites

Nice work so far.

I would recommend three changes.

First, let the user be able to delete items off the list.

Second, automatically preview the picture when the user clicks on it. Search the GUI support for Liss and you should find something.

Third, instead of having the program start empty, use the current wallpaper as a default option.

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Hey,

Glad you guys like it!

Here is my updated script (did it a few hours after first post) for you to have a look at.. thanks for the suggestions aswell!

Func _Wallpaper()
    $WPs = IniRead($Ini, "Settings", "Background", "")
    $WallpaperMain = GUICreate("A13 Shell - Wallpaper Selector", 367, 406)
    $WallpaperList = GUICtrlCreateList($WPs, 16, 208, 334, 159, $WS_VSCROLL)
    $WallpaperPreview = GUICtrlCreatePic($WPs, 70, 16, 260, 177, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    $Browse = GUICtrlCreateButton("Browse", 8, 368, 65, 25, 0)
    $Preview = GUICtrlCreateButton("Preview", 78, 368, 65, 25, 0)
    $Save = GUICtrlCreateButton("Save", 150, 368, 65, 25, 0)
    $Delete = GUICtrlCreateButton("Delete", 222, 368, 65, 25, 0)
    $Cancel = GUICtrlCreateButton("Cancel", 294, 368, 65, 25, 0)

    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($WallpaperMain)
                ExitLoop
            Case $Browse
                $SelectWP = FileOpenDialog("Please select an image(s) to add to the list.", @DesktopDir, "Images (*.jpg;*.bmp)", 1)
                _GUICtrlListAddItem($WallpaperList, $SelectWP)
                GUICtrlDelete($WallpaperPreview)
                $WallpaperPreview = GUICtrlCreatePic($SelectWP, 50, 16, 257, 177, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
            Case $Preview
                GUICtrlDelete($WallpaperPreview)
                $NewPic = _GUICtrlListGetText($WallpaperList, _GUICtrlListSelectedIndex($WallpaperList))
                $WallpaperPreview = GUICtrlCreatePic($NewPic, 50, 16, 257, 177, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
            Case $Save
                $GetPic = _GUICtrlListGetText($WallpaperList, _GUICtrlListSelectedIndex($WallpaperList))
                $SaveBkGrnd = IniWrite($Ini, "Settings", "Background", $GetPic)
                $SetBkGrnd = GUICtrlSetImage($BkGrnd, $GetPic)
            Case $Delete
                $GetPc = _GUICtrlListSelectedIndex($WallpaperList)
                _GUICtrlListDeleteItem($WallpaperList, $GetPc)
                GUICtrlDelete($WallpaperPreview)
            Case $Cancel
                GUIDelete($WallpaperMain)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_Wallpaper

Added the delete function ~thanks Piano_Man~ and I am looking into the preview on click~

alien13

Edited by alien13
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...