gertsolo Posted October 17, 2007 Posted October 17, 2007 (edited) Hey all,I would like to make a small picture viewer based on this solution by Big_Daddy :http://www.autoitscript.com/forum/index.ph...=0&p=366854What I want to do is select a directory and put all the images files of that dir in an array.I would then like to show those images in the viewer, one by one, by pressing previous and next.I would also like to have to option (with a button) to copy the image that is currently viewed to another location.The problem is that I am very new to this and not to familiar with arrays.Is this possible and doable?code so far:expandcollapse popup#include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> Opt("GUIOnEventMode", True) HotKeySet("=", "_Zoom") HotKeySet("-", "_Zoom") $oPreview = ObjCreate("Preview.Preview.1") $MyDir = "D:\My_Documents\My Pictures" $Location = FileSelectFolder("Please select a folder", $MyDir) $FileList = _FileListToArray($Location) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf GUICreate("Picture viewer") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $GUI_OBJ = GUICtrlCreateObj($oPreview, 10, 10, 380, 380) GUISetState() ;$sFile = FileOpenDialog("Open Image", $Location, "Image files (*.bmp;*.jpg;*.jpeg)", 1) $oPreview.ShowFile ($FileList[1], 1) While 1 Sleep(100) WEnd Func _Zoom() Switch @HotKeyPressed Case "-" $oPreview.Zoom (-1) Case "=" $oPreview.Zoom (1) EndSwitch EndFunc ;==>_Zoom Func _Exit() Exit EndFunc ;==>_Exit Edited October 17, 2007 by gertsolo The more you learn, the less you know.
weaponx Posted October 17, 2007 Posted October 17, 2007 (edited) This seems simple enough. I tried looking up the Preview object on MSDN but couldn't find anything.There is a slideshow example using this object here:http://www.autoitscript.com/forum/index.ph...=image++previewIf someone has a link to the member functions of this object, that would be great, I have no clue how to get the next / previous buttons working. Edited October 17, 2007 by weaponx
smashly Posted October 17, 2007 Posted October 17, 2007 Hi, mild update to code you provided, uses keyboard arrow keys..expandcollapse popup#include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> Opt("GUIOnEventMode", 1) HotKeySet("{UP}", "Control") HotKeySet("{DOWN}", "Control") HotKeySet("{LEFT}", "Control") HotKeySet("{RIGHT}", "Control") $oPreview = ObjCreate("Preview.Preview.1") $Location = FileSelectFolder("Please select a folder", "") $FileList = _FileListToArray($Location) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf $n = 1 GUICreate("Picture viewer") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $GUI_OBJ = GUICtrlCreateObj($oPreview, 10, 10, 380, 380) $oPreview.ShowFile ($Location & "\" & $FileList[$n], 1) GUISetState() While 1 Sleep(100) WEnd Func Control() Switch @HotKeyPressed Case "{DOWN}" $oPreview.Zoom (-1) Case "{UP}" $oPreview.Zoom (1) Case "{LEFT}" If $n > 1 Then $n -= 1 Else $n = $FileList[0] EndIf $oPreview.ShowFile ($Location & "\" & $FileList[$n], 1) Case "{RIGHT}" If $n < $FileList[0] Then $n += 1 Else $n = 1 EndIf $oPreview.ShowFile ($Location & "\" & $FileList[$n], 1) EndSwitch EndFunc Func _Exit() Exit EndFunc Cheers
weaponx Posted October 17, 2007 Posted October 17, 2007 Smashly - I guess that works too, but you should use a different FileListArray function like FileListToArrayEx or else the script will freak out if there is a non-image file in that folder.
gertsolo Posted October 17, 2007 Author Posted October 17, 2007 Smashly - I guess that works too, but you should use a different FileListArray function like FileListToArrayEx or else the script will freak out if there is a non-image file in that folder.Well, it doesn't exactly freak out, the viewer just gives the 'No preview available' error. I can live with that ;-) The more you learn, the less you know.
gertsolo Posted October 17, 2007 Author Posted October 17, 2007 Just out of curiosity, how do I use the next and previous buttons in the viewer? Can I add buttons on that dialog, or fake it by putting buttons over it? The more you learn, the less you know.
weaponx Posted October 17, 2007 Posted October 17, 2007 Well I followed a link in this post (posted by lod3n):http://www.autoitscript.com/forum/index.php?showtopic=40398And downloaded Oakland ActiveX/COM Inspectorhttp://www.oaklandsoftware.com/product_com.../product_3.htmlWhich exposed these methods for the Preview object:ActualSizeAttachInterfacesBestFitCtlShowRaiseOnOnActualSizePressRaiseOnOnBestFitPressRaiseOnOnCloseRaiseOnonerrorRaiseOnOnPreviewReadyShowFileSlideShowZoomThere is an events list, but there are no events for the builtin navigation buttons. I'm guessing you have to pass a folder path or comma seperated string to activate these buttons.
gertsolo Posted October 17, 2007 Author Posted October 17, 2007 BTW, when running the exe on vista I get an error:Variable must be of type 'Object' Am I overlooking something? The more you learn, the less you know.
weaponx Posted October 17, 2007 Posted October 17, 2007 Maybe they ditched that object in Vista. The dependent dll is Windows\System32\shimgvw.dll Do you have that file?
gertsolo Posted October 17, 2007 Author Posted October 17, 2007 (edited) Maybe they ditched that object in Vista. The dependent dll is Windows\System32\shimgvw.dll Do you have that file? Yup, it's there. When compiling this expandcollapse popup#include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> Opt("GUIOnEventMode", 1) HotKeySet("{UP}", "Control") HotKeySet("{DOWN}", "Control") HotKeySet("{LEFT}", "Control") HotKeySet("{RIGHT}", "Control") HotKeySet("{ENTER}", "Control") $oPreview = ObjCreate("Preview.Preview.1") $HomeDir = "Z:\Kodak Pictures" $CopyDir = "Z:\Kodak Pictures\_Karin_print" $Location = FileSelectFolder("Kies een map om te bekijken", $HomeDir) $FileList = _FileListToArray($Location) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf $n = 1 GUICreate("Picture viewer") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $GUI_OBJ = GUICtrlCreateObj($oPreview, 10, 10, 380, 380) $oPreview.ShowFile ($Location & "\" & $FileList[$n], 1) GUISetState() While 1 Sleep(100) WEnd Func Control() Switch @HotKeyPressed Case "{DOWN}" $oPreview.Zoom (-1) Case "{UP}" $oPreview.Zoom (1) Case "{LEFT}" If $n > 1 Then $n -= 1 Else $n = $FileList[0] EndIf $oPreview.ShowFile ($Location & "\" & $FileList[$n], 1) Case "{RIGHT}" If $n < $FileList[0] Then $n += 1 Else $n = 1 EndIf $oPreview.ShowFile ($Location & "\" & $FileList[$n], 1) Case "{ENTER}" ConsoleWrite($FileList[$n]& @CR) FileCopy($Homedir & "\" &$FileList[$n],$CopyDir & "\" &$FileList[$n]) EndSwitch EndFunc Func _Exit() Exit EndFunc I Get: >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "\\fastdude\Backup_station\Picture_viewer.au3" \\fastdude\Backup_station\Picture_viewer.au3 (29) : ==> Variable must be of type "Object".: $oPreview.ShowFile ($Location & "\" & $FileList[$n], 1) $oPreview^ ERROR Edited October 17, 2007 by gertsolo The more you learn, the less you know.
weaponx Posted October 17, 2007 Posted October 17, 2007 Okay. Well I haven't used Vista but something tells me it doesn't still use the Windows Picture and File Viewer. There was a security vulnerability in that object and maybe instead of fixing it they chucked it.http://www.bleepingcomputer.com/forums/topic39047.htmlMaybe the dll jsut isn't being registered by default, you can try registering it.1. Click Start > Run 2. regsrvr32 shimgvw.dllThen try your script.
gertsolo Posted October 17, 2007 Author Posted October 17, 2007 (edited) Okay. Well I haven't used Vista but something tells me it doesn't still use the Windows Picture and File Viewer. There was a security vulnerability in that object and maybe instead of fixing it they chucked it.http://www.bleepingcomputer.com/forums/topic39047.htmlMaybe the dll jsut isn't being registered by default, you can try registering it.1. Click Start > Run 2. regsrvr32 shimgvw.dllThen try your script.Dllname was loaded, but the DLLRegisterServer entry point was not foundThen copied it to the AutoIt working dir, but no result...Doh! Edited October 17, 2007 by gertsolo The more you learn, the less you know.
weaponx Posted October 17, 2007 Posted October 17, 2007 According to the M$ knowledgebase, that error means it's not a dll file.http://support.microsoft.com/kb/249873Well thats about as smart as keyboard error, press f1 to continue.
gertsolo Posted October 18, 2007 Author Posted October 18, 2007 According to the M$ knowledgebase, that error means it's not a dll file.http://support.microsoft.com/kb/249873Well thats about as smart as keyboard error, press f1 to continue.You're right there, buddy.So now what? The more you learn, the less you know.
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