Sign in to follow this  
Followers 0
regi

Displaying an image on the desktop

12 posts in this topic

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!

Share this post


Link to post
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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@Valuater

I dont think your window is implanted to desktop as he wants, isnt it ?

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

@Valuater

I saw the API include but no functions to match with, thats why I asked a question :lmao:

I cant test it but it should be nice way to do it :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks for the extremely speedy replies!

I kinda had what you wrote Valuater, but I couldn't get this piece of code to work :/

You're updated code seems to though, nice!

Edited by regi

Share this post


Link to post
Share on other sites

A follow-up...

How would I go about ensuring each picture was displayed with the correct aspect ratio?

At the moment, they're all displayed at 300x300, distorting the images...

Share this post


Link to post
Share on other sites

if im correct just leave out the dimensions and it should re size im not sure never tried it


A great place to start Autoit 1-2-3

Share this post


Link to post
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?

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0