Jump to content

Displaying an image on the desktop


regi
 Share

Recommended Posts

Hi, long time fan and first time poster,

I've mostly used AutoIt to create little tools that increase my productivity and now I'm stepping it up a tad.

I was looking for assistance in creating a 'slideshow' program, that will grab random images from a user defined folder, and display them at intervals 'on' the desktop (ie 300px by 300px), much function of Vista's sidebar slideshow.

Can anyone give me some pointers as to how i can achieve this?

The GUI and image selection I can probably knock up myself, but the drawing of the image on the desktop is tricky for me!

Link to comment
Share on other sites

@regi

Welcome to autoit forum :)

-The best way to do it is to 'reproduce' desktop window(if you want to keep icons)

-you can make child window of your desktop

-if youre good in html scripting, you can put html window on your desktop instead of your wallpaper and then you can do what you want :lmao:

Cheers, FireFox.

Link to comment
Share on other sites

Maybe..

#include <File.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1)

$Location = FileSelectFolder("Choose a folder.", @HomeDrive)
If $Location = "" Then Exit

$GUI = GUICreate("My Pics", 300, 300)
GUISetOnEvent(-3, "Exiter")
$pic = GUICtrlCreatePic("", 0, 0, 300, 300)
GUISetState()

$Pic_List = _FileListToArray($Location)
If @error Then Exit

While 1
    $rand = Random(1, UBound($Pic_List) - 1, 1)
    GUICtrlSetImage($pic, $Location & "\" & $Pic_List[$rand])
    Sleep(5000)
WEnd

Func Exiter()
    Exit
EndFunc   ;==>Exiter

8)

NEWHeader1.png

Link to comment
Share on other sites

API set parent did not work ( note the include above for API )

This works....

#include <WindowsConstants.au3>
#include <File.au3>

$Location = FileSelectFolder("Choose a folder.", @HomeDrive)
If $Location = "" Then Exit

$GUI = GUICreate("My Pics", 300, 300, -1, -1, $WS_POPUP)
$dTop = WinGetHandle("[CLASS:Progman]")
DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $GUI, "hwnd", $dTop)
$pic = GUICtrlCreatePic("", 0, 0, 300, 300)
GUISetState()

$Pic_List = _FileListToArray($Location)
If @error Then Exit

While 1
    $rand = Random(1, UBound($Pic_List) - 1, 1)
    GUICtrlSetImage($pic, $Location & "\" & $Pic_List[$rand])
    Sleep(5000)
WEnd

EDIT; took out the crap..

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Had to use GDI and some nifty resize formula phew.

An annoying thing I've noticed, as I'm writing this in fact, is that when the picture changes on the desktop, it takes the focus away from the window that's on top, meaning I have to click this window again to regain focus. Any ideas on a possible solution/work around?

Link to comment
Share on other sites

Regaining focus to the currently "active" window is easy. First get the current window, do your stuff that makes it lose focus and then do WinActivate() on it, something like this:

$hWin = WinGetHandle("[ACTIVE]")
;Do your stuff here that steals focus
WinActivate($hWin)
Link to comment
Share on other sites

Easily solved, thanks AdmiralAlkex.

OK, last issue i think...

This is a simplified version of what I have thus far, aiming to achieve continual access to a right-click context menu while the image behind changed at set intervals.

The problem at the moment is that if $Speed is updated via the rightclick menu, then it stops the image rotation, is there an obvious solution to this that I'm missing?

Probably going about this totally the wrong way... :)

$Speed = 1000
$counta = 0
While 1
    if $counta = $Speed Then
; Set GUI containing image
        $counta = 0
    EndIf

; ContextMenu built here

    $msg = GUIGetMsg()
    Select
        Case $msg = $exititem
            exitG($GUI)
        Case $msg = $option
            showOpt()               
    EndSelect
    Sleep(1)
    $counta += 1    
WEnd
Edited by regi
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...