Jump to content
Sign in to follow this  
vrocco

Slideshow Script for Digital Photo Frame

Recommended Posts

vrocco

I want to make a digital picture frame out of an old laptop. I would like to write an autoit script to show the pictures full screen while hiding the mouse cursor and taskbar. I also would like it to look for a usb device to be attached and when it is, find the pictures files, copy them to a hard drive and include them in the slideshow.

Can someone point me in the right direction for getting started on this? Can it be done in autoit?

Thanks!

Vito

Share this post


Link to post
Share on other sites
Uriziel01

I think it will be semi hard to do in Autoit itself, i reccomend you to search for some .dll or including .au3 for this operations, this make all faster and "cleaner"...


Share this post


Link to post
Share on other sites
Uriziel01

To looking for new usb drive i think DriveGetDrive will be good. Just use DriveGetDrive and next keep searching for changes in it in loop. Next simple copy all files *.jpg, *.bmp, *.png to selected folder on yours hdd. To show this pictures you may use simple GUI without frame but i dont now how to hide taskbar. to list the files use _FileListToArray and when you want to show pic use GUICtrlSetImage and loop it.

Edited by Uriziel01

Share this post


Link to post
Share on other sites
Zedna

Example of "fullscreen" GUI:

#include <Color.au3>
#include <GUIConstants.au3>

$gui = GUICreate("Rainbow",@DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
$size = WinGetClientSize($gui)
$step = $size[0] / 6

_GUICtrlCreateGradient(0xFF0000, 0xFFFF00, 0*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0xFFFF00, 0x00FF00, 1*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x00FF00, 0x00FFFF, 2*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x00FFFF, 0x0000FF, 3*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x0000FF, 0xFF00FF, 4*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0xFF00FF, 0xFF0000, 5*$step, 0, $step, $size[1])
GUISetCursor(16,1)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
Wend

Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
    Local $color1R = _ColorGetRed($nStartColor)
    Local $color1G = _ColorGetGreen($nStartColor)
    Local $color1B = _ColorGetBlue($nStartColor)

    Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $step
    Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $step
    Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $step

    GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
    For $i = 0 To $nWidth
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $i, 0)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $i, $nHeight)
    Next
EndFunc
Edited by Zedna

Share this post


Link to post
Share on other sites
Uriziel01

Wow! How simple it is, thanks for this very much Zedna ! I dont now this metod in past =)


Share this post


Link to post
Share on other sites
Vindicator209

Hehehehe, heres a lazy solution:

Run(@HomeDrive&"\WINDOWS\system32\ssmypics.scr")

It runs the My Pictures ScreenSaver, so just put all your pictures into you My Pictures folder, an whala! although I don't think it was what you wanted =P

Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites
vrocco

Hehehehe, heres a lazy solution:

Run(@HomeDrive&"\WINDOWS\system32")

It runs the My Pictures ScreenSaver, so just put all your pictures into you My Pictures folder, an whala! although I don't think it was what you wanted =P

That's actually an interesting idea. I hadn't thought of it. Can I run and autoit script in the background to detect when a usb drive is plugged in adn copy pics from it to the My Pictures folder?

Or will the screen saver stop when something else executes?

Anyone know?

Share this post


Link to post
Share on other sites
vrocco

OK tried this a few ways and i am stuck again. Hopefully someone can help me.

Used a script ptrex wrote to detect usb drive plugged in and then copied pictures automatically to the hard drive. Also was able to ListToArray the files in the folder and display them one after another.

The problem is, when I run the picture changing on a continous loop, then it can't look for the usb drive. I am sure it is just a matter of code placement, but I am an extreme noob. Can someone give me some help?

Here is the script thus far:

#include <Color.au3>
#include <GUIConstants.au3>
#include <File.au3>
#include <Array.au3>

$picarray = _FileListToArray("C:\Photos")

$gui = GUICreate("Slideshow",@DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
$pic = GUICtrlCreatePic("C:\Photos\"& $picarray[1], 0, 0, @DesktopWidth, @DesktopHeight)
GUISetCursor(16,1)
GUISetState()

$strComputer = "."
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")

    $colEvents = $objWMIService.ExecNotificationQuery _
        ("Select * From __InstanceOperationEvent Within 5 Where " _
            & "TargetInstance isa 'Win32_LogicalDisk'")

    While 1
     $objEvent = $colEvents.NextEvent
        If $objEvent.TargetInstance.DriveType = 2 Then 
            If $objEvent.Path_.Class()="__InstanceCreationEvent" Then
                DirCopy($objEvent.TargetInstance.DeviceId & "\Photos", "C:\Photos", 1)
            EndIf
        EndIf
    WEnd


Slideshow()




Func Slideshow ()
Do
    $picarray = _FileListToArray("C:\Photos")
    Sleep(5000)
    For $n = 1 To $picarray[0]
        GUICtrlSetImage($pic, "C:\Photos\" & $picarray[$n])
        Sleep (5000)
    Next
Until @error
EndFunc

Share this post


Link to post
Share on other sites
herewasplato

You could make the USB detection a function and use adlibenable or maybe put it all in one loop - I've not studied the USB detection code to see if one loop would be a good idea.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
vrocco

I did try putting in the Do...Until Loop and then my pictures wouldn't change.

Anyone else can help with this?

Share this post


Link to post
Share on other sites
Vindicator209

Whoops my bad, the actual command for the mypics screensaver is:

Run(@HomeDrive&"\WINDOWS\system32\ssmypics.scr")

( I forgot the end of it )

and as for new drives,, I found this in one of my scripts but I can't remember who was the one who wrote it...

$DBT_DEVICEARRIVAL = "0x00008000"
$WM_DEVICECHANGE = 0x0219
GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")
Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
    If $WParam == $DBT_DEVICEARRIVAL Then
;Script Here
EndIf
EndFunc

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites
vrocco

I tired this route too, but couldn't get autoit to run the Mypics SS because it has an .scr extension (not .exe, .com, etc.)

Also, while the screensaver is running, my script to detect usb doesn't work. (Script works fine otherwise.)

Like I said, I am sure it is all there, but the placement of it is wrong.

Thanks!

Share this post


Link to post
Share on other sites
vrocco

Success!!!

Two scripts was my answer!! I put the USB detection in one script and compiled it. Then had the slideshow script run that .exe when it started. Seems to do what I want it to. However, is there a way to terminate the usb.exe program when the slideshow program exits?

Thanks to those who helped out!

Vito

Share this post


Link to post
Share on other sites
Zedna

Success!!!

Two scripts was my answer!! I put the USB detection in one script and compiled it. Then had the slideshow script run that .exe when it started. Seems to do what I want it to. However, is there a way to terminate the usb.exe program when the slideshow program exits?

Thanks to those who helped out!

Vito

ProcessClose()

Share this post


Link to post
Share on other sites
Paulie

Success!!!

Two scripts was my answer!! I put the USB detection in one script and compiled it. Then had the slideshow script run that .exe when it started. Seems to do what I want it to. However, is there a way to terminate the usb.exe program when the slideshow program exits?

Thanks to those who helped out!

Vito

ProcessClose("MyScript.exe")

Share this post


Link to post
Share on other sites
herewasplato

Opt("OnExitFunc", "_Terminate")

;your main script here


Func _Terminate()
    Do
        ProcessClose("USB.EXE")
        Sleep(3000)
    Until ProcessExists("USB.EXE") = 0
EndFunc   ;==>_Terminate


[size="1"][font="Arial"].[u].[/u][/font][/size]

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  

×