regi Posted January 21, 2009 Share Posted January 21, 2009 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 More sharing options...
FireFox Posted January 21, 2009 Share Posted January 21, 2009 @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 Cheers, FireFox. Link to comment Share on other sites More sharing options...
Valuater Posted January 21, 2009 Share Posted January 21, 2009 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) Link to comment Share on other sites More sharing options...
FireFox Posted January 21, 2009 Share Posted January 21, 2009 @Valuater I dont think your window is implanted to desktop as he wants, isnt it ? Cheers, FireFox. Link to comment Share on other sites More sharing options...
Valuater Posted January 21, 2009 Share Posted January 21, 2009 (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 January 21, 2009 by Valuater Link to comment Share on other sites More sharing options...
FireFox Posted January 21, 2009 Share Posted January 21, 2009 @Valuater I saw the API include but no functions to match with, thats why I asked a question I cant test it but it should be nice way to do it Cheers, FireFox. Link to comment Share on other sites More sharing options...
regi Posted January 21, 2009 Author Share Posted January 21, 2009 (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 January 21, 2009 by regi Link to comment Share on other sites More sharing options...
regi Posted January 21, 2009 Author Share Posted January 21, 2009 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... Link to comment Share on other sites More sharing options...
iHonda Posted January 22, 2009 Share Posted January 22, 2009 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 Link to comment Share on other sites More sharing options...
regi Posted January 22, 2009 Author Share Posted January 22, 2009 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 More sharing options...
AdmiralAlkex Posted January 22, 2009 Share Posted January 22, 2009 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) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
regi Posted January 22, 2009 Author Share Posted January 22, 2009 (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 January 22, 2009 by regi Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now