bird42 Posted November 13, 2013 Share Posted November 13, 2013 I wrote this because windows 8 picture viewer does not support animated gifs. It's a really basic script as i code as an hobbist. Any useful comments welcome expandcollapse popup;simple image viewer by Zentral #include <GuiconstantsEx.au3> #include <_GUIResourcePic.au3> #include <WindowsConstants.au3> #include <FileListToArray.au3> #include <Misc.au3> If UBound(ProcessList(@ScriptName)) > 2 Then MsgBox(4096, "Error", @ScriptName&" is already running.", 5) Exit EndIf $gui=GUICreate("Simple Image Viewer",800,650, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SIZEBOX), $WS_EX_ACCEPTFILES) $picture=_GUICtrlPic_Create('', 5, 5) Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) Opt("GUIOnEventMode", 1) Opt("MouseCoordMode", 2) GUISetOnEvent($GUI_EVENT_CLOSE, '_exit') GUISetOnEvent($GUI_EVENT_MINIMIZE, '_mintray') GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_movepic') $open = TrayCreateItem("Open Folder") TrayItemSetOnEvent(-1,"_folder") TrayCreateItem("") $open = TrayCreateItem("Set Recusion") TrayItemSetOnEvent(-1,"_setrec") TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayItemSetOnEvent(-1,"_about") $restoreitem = TrayCreateItem("Restore") TrayItemSetOnEvent(-1,"RestoreTray") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TrayItemSetOnEvent(-1,"_exit") TraySetToolTip("Simple Image Viewer") GUISetState(@SW_SHOW) Global $picture, $files = '', $recursion = 0, $currentpos = 1 While 1 sleep(50) ;~ left arrow If _IsPressed('25') Then _previous() While _IsPressed("25") Sleep(10) WEnd EndIf ;~ up arrow If _IsPressed('26') Then _first() While _IsPressed("26") Sleep(10) WEnd EndIf ;~ right arrow If _IsPressed('27') Then _next() While _IsPressed("27") Sleep(10) WEnd EndIf ;~ down arrow If _IsPressed('28') Then _last() While _IsPressed("28") Sleep(10) WEnd EndIf WEnd Func _movepic() $cInfo = GUIGetCursorInfo($gui) ; Is it over a control $iControl = $cInfo[4] Switch $iControl ; If it is a control we want to move Case $picture ; Work out offset of mouse on control $aPos = ControlGetPos($gui, "", $iControl) $iSubtractX = $cInfo[0] - $aPos[0] $iSubtractY = $cInfo[1] - $aPos[1] ; And then move the control until the mouse button is released Do $cInfo = GUIGetCursorInfo($gui) ControlMove($gui, "", $iControl, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY) Until Not $cInfo[2] EndSwitch EndFunc Func _folder() _GUICtrlPic_Delete($picture) $files=_RecFileListToArray(InputBox('','Path:'),'*.jpg;*.png;*.gif;*.bmp',1,$recursion,0,2) $currentpos = 1 $picture=_GUICtrlPic_Create($files[$currentpos], 5, 5) EndFunc Func _next() If $files = '' Then _folder() $currentpos+=1 If $currentpos > $files[0] then $currentpos=1 _GUICtrlPic_Delete($picture) $picture=_GUICtrlPic_Create($files[$currentpos], 5, 5) EndFunc Func _previous() If $files = '' Then _folder() $currentpos-=1 If $currentpos < 1 then $currentpos=$files[0] _GUICtrlPic_Delete($picture) $picture=_GUICtrlPic_Create($files[$currentpos], 5, 5) EndFunc Func _last() If $files = '' Then _folder() $currentpos=$files[0] _GUICtrlPic_Delete($picture) $picture=_GUICtrlPic_Create($files[$currentpos], 5, 5) EndFunc Func _first() If $files = '' Then _folder() $currentpos=1 _GUICtrlPic_Delete($picture) $picture=_GUICtrlPic_Create($files[$currentpos], 5, 5) EndFunc Func _setrec() $recusion=InputBox('','Set recursion:'&@CRLF&@CRLF&'1 - Search in all subfolders (unlimited recursion)'&@CRLF&'0 - Do not search in subfolders (Default)'&@CRLF&'Negative integer - Search in subfolders to specified depth','0','',400) EndFunc Func _MinTray() GuiSetState(@SW_HIDE) TraySetState(1) EndFunc Func RestoreTray() GuiSetState(@SW_SHOW) GuiSetState(@SW_RESTORE) TraySetState(2) EndFunc Func _about() MsgBox(0,"Author: Zentral","Function: simple image viewer."&@CRLF&'Navigate with arrows') EndFunc Func _exit() Exit 1 EndFunc Thanks to João Carlos (jscript) and Melba23 for includes. Link to comment Share on other sites More sharing options...
AZJIO Posted November 13, 2013 Share Posted November 13, 2013 (edited) _GUIResourcePic.au3 ??? Edited November 13, 2013 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
bird42 Posted November 14, 2013 Author Share Posted November 14, 2013 ; #INDEX# ======================================================================================================================= ; Title .........: _GUIResourcePic ; Version .......: 1.8.2012.2600b ; AutoIt Version.: 3.3.8.1 ; Language.......: English ; Description ...: Load image (.bmp, .jpg, .png, .gif {animated} and other formats.) resources from .exe, .dll, .ocx, .cpl... ; Author ........: João Carlos (jscript) ; Remarks .......: Based on http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=1776 and Prog@ndy work concept! ; ======================================================================================================================== I found it on the forum... can't remeber where at the moment. You linked a very useful example!! Thank you very much AZJIO. 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