corgano Posted June 11, 2009 Share Posted June 11, 2009 i have this script: expandcollapse popup#include <WindowsConstants.au3> #include "GIFAnimation.au3" Opt("MustDeclareVars", 1) Global $hGui = GUICreate("GIF Animation", 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW) Global $sFile = FileOpenDialog("Choose gif", "", "(*.gif)", -1, "", $hGui) If @error Then Exit Global $aGIFArrayOfIconHandles Global $hGIFThread Global $iGIFTransparent Global $tFrameCurrent Global $hGIF = _GUICtrlCreateGIF($sFile, 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) GUICtrlSetTip($hGIF, "GIF") Global $hButton = GUICtrlCreateButton("Stop animation", 50, 450, 100, 25) Global $hButton1 = GUICtrlCreateButton("Delete GIF", 200, 450, 100, 25) Global $hButton2 = GUICtrlCreateButton("Open GIF", 350, 450, 100, 25) GUIRegisterMsg(15, "_Refresh"); WM_PAINT; don't forget this. It's needed only for non-transparent gifs though, but still. Global $iPlay = 1 GUISetState() While 1 Switch GUIGetMsg() Case - 3 Exit Case $hButton If $iPlay Then If _StopGIFAnimation($hGIFThread) Then $iPlay = 0 GUICtrlSetData($hButton, "Resume animation") EndIf Else If _ResumeGIFAnimation($hGIFThread) Then $iPlay = 1 GUICtrlSetData($hButton, "Stop animation") EndIf EndIf Case $hButton1 _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent) Case $hButton2 $sFile = FileOpenDialog("Choose gif", "", "(*.gif)", -1, "", $hGui) If Not @error Then _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent); if already there $hGIF = _GUICtrlCreateGIF($sFile, 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) GUICtrlSetTip($hGIF, "GIF") $iPlay = 1 GUICtrlSetData($hButton, "Stop animation") EndIf EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _RefreshGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc ;==>_Refresh What i need to do is add 2 buttons, one for back and one for foward. You click the foward button, it goes to the next gif in the dir of the selected image, and if you click the previous arrow, it goes to the previous file. I tried FileFindFirstFile and FileFindnextFile, but thoes go from the script dir, and what do I do for previous? i want the end program to be like the windows defult picture viewer, with next and previous image buttons. 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Inverted Posted June 11, 2009 Share Posted June 11, 2009 (edited) First step is to add the 2 buttons to your GUI, with some placeholder/empty functions. Edited June 11, 2009 by Inverted Link to comment Share on other sites More sharing options...
corgano Posted June 11, 2009 Author Share Posted June 11, 2009 First step is to add the 2 buttons to your GUI, with some placeholder/empty functions. I have no problem with buttons. It's the back and foward part. expandcollapse popup#include <WindowsConstants.au3> #include "GIFAnimation.au3" Opt("MustDeclareVars", 1) Global $hGui = GUICreate("GIF Animation", 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW) Global $sFile = FileOpenDialog("Choose gif", "", "(*.gif)", -1, "", $hGui) If @error Then Exit Global $aGIFArrayOfIconHandles Global $hGIFThread Global $iGIFTransparent Global $tFrameCurrent Global $hGIF = _GUICtrlCreateGIF($sFile, 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) GUICtrlSetTip($hGIF, "GIF") Global $hButton = GUICtrlCreateButton("back", 50, 450, 100, 25) Global $hButton1 = GUICtrlCreateButton("Delete GIF", 200, 450, 100, 25) Global $hButton2 = GUICtrlCreateButton("foward", 350, 450, 100, 25) GUIRegisterMsg(15, "_Refresh"); WM_PAINT; don't forget this. It's needed only for non-transparent gifs though, but still. Global $iPlay = 1 GUISetState() While 1 Switch GUIGetMsg() Case - 3 Exit Case $hButton back() Case $hButton1 _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent) Case $hButton2 foward() EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _RefreshGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc ;==>_Refresh Func back() EndFunc Func foward() EndFunc 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Inverted Posted June 11, 2009 Share Posted June 11, 2009 (edited) Well, I would suggest to use _FileListToArray with a *.gif filter after the user opens a gif. You can use _PathSplit to get the path. Then you have the files in an array and you can go through it at will. Have fun ! P.S.: You can use _ArrayDisplay to check what your gif file list array contains, just to be sure. Edited June 11, 2009 by Inverted Link to comment Share on other sites More sharing options...
corgano Posted June 11, 2009 Author Share Posted June 11, 2009 Well, I would suggest to use _FileListToArray with a *.gif filter after the user opens a gif. You can use _PathSplit to get the path. Then you have the files in an array and you can go through it at will.Have fun ! P.S.: You can use _ArrayDisplay to check what your gif file list array contains, just to be sure.I provided code so you could show me how it works. Even if you did it only for next I could do previous. 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Inverted Posted June 11, 2009 Share Posted June 11, 2009 (edited) Seems to be working fine ! Took me about 25 minutes. expandcollapse popup#include <WindowsConstants.au3> #include "GIFAnimation.au3" #Include <File.au3> #Include <Array.au3> Global $hGui = GUICreate("GIF Animation", 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW) Global $sFile = FileOpenDialog("Choose gif", "", "(*.gif)", -1, "", $hGui) Dim $szDrive, $szDir, $szFName, $szExt If @error Then Exit $gif_array = _FileListToArray (@WorkingDir,"*.gif",1) $split_path = _PathSplit($sFile, $szDrive, $szDir, $szFName, $szExt) ;_ArrayDisplay ($gif_array) $current_position = _ArraySearch ($gif_array,$split_path[3] & $split_path[4]) Global $aGIFArrayOfIconHandles Global $hGIFThread Global $iGIFTransparent Global $tFrameCurrent Global $hGIF = _GUICtrlCreateGIF($sFile, 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) GUICtrlSetTip($hGIF, "GIF") Global $hButton = GUICtrlCreateButton("back", 50, 450, 100, 25) Global $hButton1 = GUICtrlCreateButton("Delete GIF", 200, 450, 100, 25) Global $hButton2 = GUICtrlCreateButton("foward", 350, 450, 100, 25) GUIRegisterMsg(15, "_Refresh") Global $iPlay = 1 GUISetState() While 1 Switch GUIGetMsg() Case - 3 Exit Case $hButton back() Case $hButton1 _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent) Case $hButton2 forward() EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _RefreshGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc ;==>_Refresh Func back() _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent) If $current_position > 1 Then $current_position -= 1 Else $current_position = $gif_array[0] EndIf Global $hGIF = _GUICtrlCreateGIF($gif_array[$current_position], 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc Func forward() _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent) If $current_position < $gif_array[0] Then $current_position += 1 Else $current_position = 1 EndIf Global $hGIF = _GUICtrlCreateGIF($gif_array[$current_position], 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc Edited June 11, 2009 by Inverted Link to comment Share on other sites More sharing options...
trancexx Posted June 11, 2009 Share Posted June 11, 2009 May I interfere and eke Inverted's script? Took me 7 minutes expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GIFAnimation.au3" #include <File.au3> #include <Array.au3> Opt("MustDeclareVars", 1) Global $hGui = GUICreate("GIF Animation", 500, 500) Global $sFile = FileOpenDialog("Choose gif", "", "(*.gif)", -1, "", $hGui) If @error Then Exit Global $aGIFDimension = _GIFGetDimension($sFile) Global $aClientSize = WinGetClientSize($hGui) Global $iPosX = ($aClientSize[0] - $aGIFDimension[0]) / 2 Global $iPosY = ($aClientSize[1] - $aGIFDimension[1]) / 2 - 100 If $iPosY < 0 Then $iPosY = 0 Global $szDrive, $szDir, $szFName, $szExt Global $gif_array = _FileListToArray(@WorkingDir, "*.gif", 1) Global $split_path = _PathSplit($sFile, $szDrive, $szDir, $szFName, $szExt) ;_ArrayDisplay ($gif_array) Global $current_position = _ArraySearch($gif_array, $split_path[3] & $split_path[4]) Global $aGIFArrayOfIconHandles Global $hGIFThread Global $iGIFTransparent Global $tFrameCurrent Global $hGIF = _GUICtrlCreateGIF($sFile, $iPosX, $iPosY, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) Global $hButton = GUICtrlCreateButton("< Previous", 50, 450, 100, 25) Global $hButton1 = GUICtrlCreateButton("Stop animation", 200, 450, 100, 25) Global $hButton2 = GUICtrlCreateButton("Next >", 350, 450, 100, 25) If UBound($aGIFArrayOfIconHandles) = 1 Then GUICtrlSetState($hButton1, $GUI_DISABLE) EndIf GUIRegisterMsg(15, "_Refresh") Global $iPlay = 1 GUISetState() While 1 Switch GUIGetMsg() Case - 3 Exit Case $hButton GUISetCursor(15, 1) _Back() GUISetCursor(-1) $iPlay = 1 GUICtrlSetData($hButton1, "Stop animation") If UBound($aGIFArrayOfIconHandles) = 1 Then GUICtrlSetState($hButton1, $GUI_DISABLE) Else GUICtrlSetState($hButton1, $GUI_ENABLE) EndIf Case $hButton1 If $iPlay Then If _StopGIFAnimation($hGIFThread) Then $iPlay = 0 GUICtrlSetData($hButton1, "Resume animation") EndIf Else If _ResumeGIFAnimation($hGIFThread) Then $iPlay = 1 GUICtrlSetData($hButton1, "Stop animation") EndIf EndIf Case $hButton2 GUISetCursor(15, 1) _Forward() GUISetCursor(-1) $iPlay = 1 GUICtrlSetData($hButton1, "Stop animation") If UBound($aGIFArrayOfIconHandles) = 1 Then GUICtrlSetState($hButton1, $GUI_DISABLE) Else GUICtrlSetState($hButton1, $GUI_ENABLE) EndIf EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _RefreshGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc ;==>_Refresh Func _Back() _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent) If $current_position > 1 Then $current_position -= 1 Else $current_position = $gif_array[0] EndIf $aGIFDimension = _GIFGetDimension($gif_array[$current_position]) $aClientSize = WinGetClientSize($hGui) $iPosX = ($aClientSize[0] - $aGIFDimension[0]) / 2 $iPosY = ($aClientSize[1] - $aGIFDimension[1]) / 2 - 100 If $iPosY < 0 Then $iPosY = 0 If $iPosY + $aGIFDimension[1] > 400 Then $iPosY -= $aGIFDimension[1] - 400 ; not to cover buttons $hGIF = _GUICtrlCreateGIF($gif_array[$current_position], $iPosX, $iPosY, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc ;==>_Back Func _Forward() _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent) If $current_position < $gif_array[0] Then $current_position += 1 Else $current_position = 1 EndIf $aGIFDimension = _GIFGetDimension($gif_array[$current_position]) $aClientSize = WinGetClientSize($hGui) $iPosX = ($aClientSize[0] - $aGIFDimension[0]) / 2 $iPosY = ($aClientSize[1] - $aGIFDimension[1]) / 2 - 100 If $iPosY < 0 Then $iPosY = 0 If $iPosY + $aGIFDimension[1] > 400 Then $iPosY -= $aGIFDimension[1] - 400 ; not to cover buttons $hGIF = _GUICtrlCreateGIF($gif_array[$current_position], $iPosX, $iPosY, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc ;==>_Forward ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
corgano Posted June 11, 2009 Author Share Posted June 11, 2009 Thank you. That is what I needed 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e 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