Jump to content

Strange issue regarding autoit script


 Share

Recommended Posts

I had an issue with an autoit script I wrote for the longest time, and only just now was able to resolve the problem, but the solution doesn't make any sense to me.  Let me back up.  I wrote an autoit script which you can think of as a media launcher: you select folders for it to monitor for media files and double click the item in the list box to launch the file.  I recently added a cool feature which utilized @ProgAndy's Autoitobject UDF to allow the script to display a preview of a media file when it was right clicked in the list box.  This new feature worked for a long time, but suddenly stopped working one day: the script would not show the preview of the file when it was right clicked, no matter what I did.  Fast forward to today, and I tried something I thought so stupid that there was no way that it could possibly resolve the problem: I copied the code from that script, created a new one in the same folder with a slightly different name, pasted the code into that script, saved it, compiled it, and tested it.  The result?  It worked!!  The preview functionality was working on the newly compiled script, but still not working on the old one, despite both having identical code.  See below:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

; *** Start added by AutoIt3Wrapper ***
#include <AutoItConstants.au3>
#include <StringConstants.au3>
; *** End added by AutoIt3Wrapper ***
; *** Start added by AutoIt3Wrapper ***
; *** End added by AutoIt3Wrapper ***
; *** Start added by AutoIt3Wrapper ***
#include <ListViewConstants.au3>
; *** End added by AutoIt3Wrapper ***
; *** Start added by AutoIt3Wrapper ***
#include <FileConstants.au3>
; *** End added by AutoIt3Wrapper ***
; *** Start added by AutoIt3Wrapper ***
#include <ListBoxConstants.au3>
#include <MsgBoxConstants.au3>
; *** End added by AutoIt3Wrapper ***
#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.15.0 (Beta)
    Author:         myName

    Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <File.au3>
#include <Array.au3>
#include <GuiListView.au3>
;#include <GUICtrlOnHover.au3>
;#include <GUICtrlOnHover.au3>
#include <AutoitObject.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
OnAutoItExitRegister("killmovies")
HotKeySet("`", "_Interrupt")
_AutoItObject_StartUp()
$fInterrupt = 0
Global $oGraphBuilder, $oMediaControl, $oMediaEventEx, $oVideoWindow, $oMediaPosition, $oBasicAudio, $oBasicVideo

Global $iPlaying = 1, $iVol, $iUnFit = 1
Global $hDLL = DllOpen("user32.dll")
#Region ### START Koda GUI section ### Form=c:\users\whiggs\onedrive\always script\form\openjv3.kxf
Global $Form1 = GUICreate("H Launcher", 500, 634, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
$MenuItem1 = GUICtrlCreateMenu("Add")
$MenuItem2 = GUICtrlCreateMenuItem("Folder", $MenuItem1)
$Label1 = GUICtrlCreateLabel("Pick your poison", 176, 16, 147, 29)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
$dumm = GUICtrlCreateDummy()
$Combo1 = GUICtrlCreateCombo("", 40, 56, 409, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE, $CBS_SORT, $WS_HSCROLL))
GUICtrlSetTip(-1, "Select the path you wish to view....")
;$list1 = GUICtrlCreateListView ( "", 24, 96, 449, 422, BitOR($LVS_LIST,$LVS_SHOWSELALWAYS))
;_GUICtrlListView_SetExtendedListViewStyle ( $list1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT) )
$List1 = GUICtrlCreateList("", 24, 96, 449, 422, BitOR($GUI_SS_DEFAULT_LIST, $LBS_HASSTRINGS))
;$list1 = GUICtrlCreateList("", 24, 96, 449, 422, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL,$LBS_HASSTRINGS,$LBS_EXTENDEDSEL))
$List1context = GUICtrlCreateContextMenu($List1)
;$MenuItem12 = GUICtrlCreateMenuItem("Preview", $List1context)
;_GUICtrl_OnHoverRegister(-1, "preview", "preview")
$Button1 = GUICtrlCreateButton("Open", 48, 536, 89, 33, $BS_NOTIFY)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor(-1, 0)
$Button2 = GUICtrlCreateButton("Delete", 360, 536, 81, 33, $BS_NOTIFY)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor(-1, 0)
$Checkbox1 = GUICtrlCreateCheckbox("Remove Zip files", 193, 576, 113, 25)
$Button5 = GUICtrlCreateButton("Move Selected", 48, 576, 89, 33, $BS_NOTIFY)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor(-1, 0)
$form2 = GUICreate("Form2", 534, 407, 800, 134, BitOR($WS_SYSMENU, $DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE), $Form1)
GUISetState(@SW_SHOW, $Form1)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "doubleClick")
GUIRegisterMsg($WM_SIZE, "_AdjustMediaViewPos")
GUIRegisterMsg($WM_GETMINMAXINFO, "_SetMinMax")
;FileInstall ( "C:\Temp\MediaInfo.dll\MediaInfo.dll", @ScriptDir & "\MediaInfo.dll" )
;FileInstall ( "C:\Users\whiggs\OneDrive\always script\movies.exe", @TempDir & "\movies.exe" )
FileInstall("C:\ProgramData\chocolatey\bin\MediaInfo.x64-avx.exe", @TempDir & "\MediaInfo.x64-avx.exe")
;Run ( @ComSpec & " /c movies.exe", @TempDir, @SW_HIDE )
;$_Dll = DllOpen ( "MediaInfo.dll" )
If Not FileExists(@ScriptDir & "\settings.ini") Then
    addPath()
Else
    $array2 = IniReadSection(@ScriptDir & "\settings.ini", "settings")
    Local $store2[$array2[0][0]]
    $here2 = 0
    For $i = 1 To $array2[0][0] Step 1
        GUICtrlSetData($Combo1, $array2[$i][1])
        ;   $here2 += 1
    Next
    ;GUICtrlSetData ( $Combo1, $store2 )
EndIf

;GUIRegisterMsg ( $WM_MOUSEHOVER, "preview" )
While 1
    If _IsPressed("01", $hDLL) Or _IsPressed("02", $hDLL) Then
        If BitAND(WinGetState($form2), $WIN_STATE_VISIBLE) Then
            $oMediaPosition.put_CurrentPosition("long", "double", 0)
            $oMediaControl.Stop()
            $iPlaying = 0
            GUISwitch($Form1)
            GUISetState(@SW_HIDE, $form2)
            ;GUIDelete ( $form2 )
        EndIf
    EndIf


    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
        Case $Form1
            #cs
            If _IsPressed("02", $hDLL) Then
                        $pos = MouseGetPos()
                        MouseClick("left", $pos[0], $pos[1])
            EndIf
            #ce
            Switch $nMsg[0]
                Case $GUI_EVENT_SECONDARYDOWN
                    $pos = MouseGetPos()
                    MouseClick("left", $pos[0], $pos[1])
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $MenuItem2
                    addPath()

                Case $Combo1
                    _GUICtrlListBox_ResetContent($List1)
                    ;_GUICtrlListView_DeleteAllItems ($list1)
                    $use = GUICtrlRead($Combo1)
                    If Not FileExists($use) Then
                        #Region --- CodeWizard generated code Start ---

                        ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute
                        MsgBox($MB_OK + 262144, "invalid path", "the path you selected does not exist or is inaccessible on local device/using current user.")
                        #EndRegion --- CodeWizard generated code Start ---
                    Else


                        GUICtrlSetState($Button1, 128)
                        ;GUICtrlSetStyle($List1, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
                        $thelist = _FileListToArrayRec($use, "*", $FLTAR_FILESFOLDERS, Default, $FLTAR_SORT, Default)
                        If GUICtrlRead($Checkbox1) = 1 Then
                            For $i = 1 To $thelist[0] Step 1
                                If IsFile($use & "\" & $thelist[$i]) = 0 Then
                                    GUICtrlSetData($List1, $thelist[$i])
                                    ;Assign ( "Listitem" & $i, GUICtrlCreateListViewItem ( $thelist[$i], $list1 ), 2 )
                                    ;_GUICtrlListView_AddItem ( $list1, $thelist[$i] )
                                Else
                                    If StringRight($thelist[$i], 3) <> "mp4" And StringRight($thelist[$i], 3) <> "flv" Then
                                        ContinueLoop
                                    Else
                                        GUICtrlSetData($List1, $thelist[$i])
                                        ;Assign ( "Listitem" & $i, GUICtrlCreateListViewItem ( $thelist[$i], $list1 ), 2 )
                                        ;_GUICtrlListView_AddItem ( $list1, $thelist[$i] )
                                    EndIf
                                EndIf
                            Next
                        Else
                            For $i = 1 To $thelist[0] Step 1
                                If IsFile($use & "\" & $thelist[$i]) = 0 Then
                                    GUICtrlSetData($List1, $thelist[$i])
                                    ;_GUICtrlListView_AddItem ( $list1, $thelist[$i] )
                                Else
                                    If StringRight($thelist[$i], 3) <> "mp4" And StringRight($thelist[$i], 3) <> "flv" And StringRight($thelist[$i], 3) <> "zip" Then
                                        ContinueLoop
                                    Else
                                        GUICtrlSetData($List1, $thelist[$i])
                                        ;_GUICtrlListView_AddItem ( $list1, $thelist[$i] )
                                    EndIf
                                EndIf
                            Next
                        EndIf
                    EndIf

                Case $List1


                    $listselect = _GUICtrlListBox_GetSelItemsText($List1)
                    If _IsPressed("02", $hDLL) Then
                        GUIDelete($form2)
                        If IsFile(GUICtrlRead($Combo1) & "\" & GUICtrlRead($List1)) = 0 Then
                            $first = _FileListToArrayRec(GUICtrlRead($Combo1) & "\" & GUICtrlRead($List1), "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
                            $sMediaFile = $first[1]
                        Else
                            $sMediaFile = GUICtrlRead($Combo1) & "\" & GUICtrlRead($List1)
                        EndIf
                        $proc = Run('MediaInfo.x64-avx.exe "' & $sMediaFile & '"', @TempDir, @SW_HIDE, $STDOUT_CHILD)
                        ProcessWaitClose($proc)
                        $text = StdoutRead($proc)

                        $split = StringSplit($text, @CRLF)
                        $width = Null
                        $height = Null
                        For $h = 1 To $split[0] Step 1
                            If StringLeft(StringStripWS($split[$h], $STR_STRIPALL), 5) = "Width" Then
                                $wisplit = StringSplit(StringStripWS(StringTrimRight($split[$h], 6), $STR_STRIPALL), ":")
                                $width = $wisplit[2]
                            EndIf
                            If StringLeft(StringStripWS($split[$h], $STR_STRIPALL), 6) = "Height" Then
                                $hesplit = StringSplit(StringStripWS(StringTrimRight($split[$h], 6), $STR_STRIPALL), ":")
                                $height = $hesplit[2]
                            EndIf
                        Next

                        ;DllClose ( $_Dll )
                        ;$_Dll = DllOpen ( "MediaInfo.dll" )
                        ;$_Handle = DllCall ( $_Dll, "ptr", "MediaInfo_New" )
                        ;DllCall ( $_Dll, "int", "MediaInfo_Open", "ptr", $_Handle[0], "wstr", $sMediaFile )
                        ;DllCall ( $_Dll, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Complete", "wstr", "" )
                        ;$_Inform = DllCall ( $_Dll, "wstr", "MediaInfo_Inform", "ptr", $_Handle[0], "int", 0 )
                        ;DllClose ( $_Dll )
                        ;_ArrayDisplay ( $_Inform )
                        $form2 = GUICreate("Form2", $width, $height, 800, 0, BitOR($WS_SYSMENU, $DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE), $Form1)
                        GUISetState(@SW_SHOW, $form2)
                        _ReleaseBuilder($oGraphBuilder, $oMediaControl, $oMediaEventEx, $oVideoWindow, $oMediaPosition, $oBasicAudio, $oBasicVideo)
                        _InitBuilder($oGraphBuilder, $oMediaControl, $oMediaEventEx, $oVideoWindow, $oMediaPosition, $oBasicAudio, $oBasicVideo)
                        $oMediaControl.RenderFile($sMediaFile)
                        $oVideoWindow.put_Caption("long", "wstr", StringRegExpReplace($sMediaFile, ".*\\|\.xm", ""))
                        $oVideoWindow.put_Owner("long", "hwnd", Number($form2))
                        $oVideoWindow.put_WindowStyle("long", "long", 0x42000000) ; WS_CHILD | WS_CLIPCHILDREN
                        _SetSize($oVideoWindow, $oBasicVideo, $form2)
                        $oBasicAudio.put_Volume("long", "long", -Exp((100 - 0) / 10.86))
                        $oMediaControl.Run()
                    EndIf

                    If $listselect[0] > 0 Then
                        GUICtrlSetState($Button1, 64)
                        GUICtrlSetState($Button2, 64)
                        GUICtrlSetState($Button5, 64)
                    Else
                        GUICtrlSetState($Button1, 128)
                        GUICtrlSetState($Button2, 128)
                        GUICtrlSetState($Button5, 128)
                    EndIf

                Case $Button1
                    $listsel = _GUICtrlListBox_GetSelItemsText($List1)
                    For $f = 1 To $listsel[0] Step 1
                        If StringRight($listsel[$f], 4) == ".mp4" Or StringRight($listsel[$f], 4) == ".flv" Then
                            ShellExecute($listsel[$f], "", GUICtrlRead($Combo1), "open")
                        Else
                            $again2 = _FileListToArrayRec(GUICtrlRead($Combo1) & "\" & $listsel[$f], "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, Default)
                            $th2 = ""
                            For $r = 1 To $again2[0] Step 1
                                $spl2 = StringSplit($again2[$r], "\")
                                $pic2 = False
                                If StringRight($again2[$r], 4) == ".jpg" Or StringRight($again2[$r], 4) == ".png" Then
                                    $pic2 = True
                                Else
                                    $pic2 = False
                                EndIf

                                If StringCompare($spl2[$spl2[0] - 1], $th2) <> 0 And $pic2 = True Then
                                    $th2 = $spl2[$spl2[0] - 1]
                                    $tooo2 = ""
                                    For $v = 1 To $spl2[0] - 1 Step 1
                                        $tooo2 = $tooo2 & "\" & $spl2[$v]
                                    Next

                                    ShellExecute("i_view64.exe", GUICtrlRead($Combo1) & "\" & $listsel[$f] & "\" & $again2[$r], "C:\Program Files\IrfanView")
                                Else
                                    ContinueLoop
                                EndIf
                            Next
                        EndIf
                    Next

                Case $Button2
                    If _GUICtrlListBox_GetSelCount($List1) = 0 Then
                        $allsec = IniReadSection(@ScriptDir & "\settings.ini", "settings")
                        For $e = 1 To $allsec[0][0] Step 1
                            If GUICtrlRead($Combo1) = $allsec[$e][1] Then
                                IniDelete(@ScriptDir & "\settings.ini", "settings", $allsec[$e][0])
                                ExitLoop
                            Else
                                ContinueLoop
                            EndIf
                        Next
                    Else
                        If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
                        $iMsgBoxAnswer = MsgBox($MB_YESNO + $MB_DEFBUTTON2 + $MB_ICONEXCLAMATION, "Confirm", "You are about to delete this file/folder.  Are you sure?")
                        Select
                            Case $iMsgBoxAnswer = $IDYES
                                $listsel2 = _GUICtrlListBox_GetSelItemsText($List1)
                                For $f = 1 To $listsel2[0] Step 1
                                    If IsFile = 0 Then
                                        Do
                                            DirRemove(GUICtrlRead($Combo1) & "\" & $listsel2[$f], 1)
                                        Until Not FileExists(GUICtrlRead($Combo1) & "\" & $listsel2[$f])
                                    Else
                                        Do
                                            FileDelete(GUICtrlRead($Combo1) & "\" & $listsel2[$f])
                                        Until Not FileExists(GUICtrlRead($Combo1) & "\" & $listsel2[$f])
                                    EndIf
                                Next
                                _GUICtrlListBox_ResetContent($List1)
                                $use = GUICtrlRead($Combo1)
                                If Not FileExists($use) Then
                                    #Region --- CodeWizard generated code Start ---

                                    ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute
                                    MsgBox($MB_OK + 262144, "invalid path", "the path you selected does not exist or is inaccessible on local device/using current user.")
                                    #EndRegion --- CodeWizard generated code Start ---
                                Else


                                    GUICtrlSetState($Button1, 128)
                                    GUICtrlSetStyle($List1, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
                                    $thelist = _FileListToArrayRec($use, "*", $FLTAR_FILESFOLDERS, Default, $FLTAR_SORT, Default)
                                    If GUICtrlRead($Checkbox1) = 1 Then
                                        For $i = 1 To $thelist[0] Step 1
                                            If IsFile($use & "\" & $thelist[$i]) = 0 Then
                                                GUICtrlSetData($List1, $thelist[$i])
                                            Else
                                                If StringRight($thelist[$i], 3) <> "mp4" And StringRight($thelist[$i], 3) <> "flv" Then
                                                    ContinueLoop
                                                Else
                                                    GUICtrlSetData($List1, $thelist[$i])
                                                EndIf
                                            EndIf
                                        Next
                                    Else
                                        For $i = 1 To $thelist[0] Step 1
                                            If IsFile($use & "\" & $thelist[$i]) = 0 Then
                                                GUICtrlSetData($List1, $thelist[$i])
                                            Else
                                                If StringRight($thelist[$i], 3) <> "mp4" And StringRight($thelist[$i], 3) <> "flv" And StringRight($thelist[$i], 3) <> "zip" Then
                                                    ContinueLoop
                                                Else
                                                    GUICtrlSetData($List1, $thelist[$i])
                                                EndIf
                                            EndIf
                                        Next
                                    EndIf
                                EndIf

                            Case $iMsgBoxAnswer = $IDNO

                        EndSelect
                    EndIf


                Case $Checkbox1
                    _GUICtrlListBox_ResetContent($List1)
                    $use = GUICtrlRead($Combo1)
                    If Not FileExists($use) Then
                        #Region --- CodeWizard generated code Start ---

                        ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute
                        MsgBox($MB_OK + 262144, "invalid path", "the path you selected does not exist or is inaccessible on local device/using current user.")
                        #EndRegion --- CodeWizard generated code Start ---
                    Else


                        GUICtrlSetState($Button1, 128)
                        GUICtrlSetStyle($List1, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
                        $thelist = _FileListToArrayRec($use, "*", $FLTAR_FILESFOLDERS, Default, $FLTAR_SORT, Default)
                        If GUICtrlRead($Checkbox1) = 1 Then
                            For $i = 1 To $thelist[0] Step 1
                                If IsFile($use & "\" & $thelist[$i]) = 0 Then
                                    GUICtrlSetData($List1, $thelist[$i])
                                Else
                                    If StringRight($thelist[$i], 3) <> "mp4" And StringRight($thelist[$i], 3) <> "flv" Then
                                        ContinueLoop
                                    Else
                                        GUICtrlSetData($List1, $thelist[$i])
                                    EndIf
                                EndIf
                            Next
                        Else
                            For $i = 1 To $thelist[0] Step 1
                                If IsFile($use & "\" & $thelist[$i]) = 0 Then
                                    GUICtrlSetData($List1, $thelist[$i])
                                Else
                                    If StringRight($thelist[$i], 3) <> "mp4" And StringRight($thelist[$i], 3) <> "flv" And StringRight($thelist[$i], 3) <> "zip" Then
                                        ContinueLoop
                                    Else
                                        GUICtrlSetData($List1, $thelist[$i])
                                    EndIf
                                EndIf
                            Next
                        EndIf
                    EndIf
                    #cs
                                    Case $MenuItem12
                                        GUIDelete($form2)
                                        If IsFile(GUICtrlRead($Combo1) & "\" & GUICtrlRead($List1)) = 0 Then
                                            $first = _FileListToArrayRec(GUICtrlRead($Combo1) & "\" & GUICtrlRead($List1), "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
                                            $sMediaFile = $first[1]
                                        Else
                                            $sMediaFile = GUICtrlRead($Combo1) & "\" & GUICtrlRead($List1)
                                        EndIf
                                        If StringRight($sMediaFile, 3) = "mp4" Then
                                            $form2 = GUICreate("Form2", 534, 407, 800, 134, BitOR($WS_SYSMENU, $DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE), $Form1)
                                            GUISetState(@SW_SHOW, $form2)
                                        Else
                                            $form2 = GUICreate("Form2", 615, 938, 211, 27, BitOR($WS_SYSMENU, $DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE), $Form1)
                                            GUISetState(@SW_SHOW, $form2)
                                        EndIf

                                        _ReleaseBuilder($oGraphBuilder, $oMediaControl, $oMediaEventEx, $oVideoWindow, $oMediaPosition, $oBasicAudio, $oBasicVideo)
                                        _InitBuilder($oGraphBuilder, $oMediaControl, $oMediaEventEx, $oVideoWindow, $oMediaPosition, $oBasicAudio, $oBasicVideo)
                                        $oMediaControl.RenderFile($sMediaFile)
                                        $oVideoWindow.put_Caption("long", "wstr", StringRegExpReplace($sMediaFile, ".*\\|\.xm", ""))
                                        $oVideoWindow.put_Owner("long", "hwnd", Number($form2))
                                        $oVideoWindow.put_WindowStyle("long", "long", 0x42000000)     ; WS_CHILD | WS_CLIPCHILDREN
                                        _SetSize($oVideoWindow, $oBasicVideo, $form2)
                                        $oBasicAudio.put_Volume("long", "long", -Exp((100 - 0) / 10.86))
                                        $oMediaControl.Run()
                    #ce
                Case $Button5
                    $movefold = FileSelectFolder("Select destination folder", "", 7, "", $Form1)
                    If $movefold <> "" Then
                        $listsel3 = _GUICtrlListBox_GetSelItemsText($List1)
                        For $f = 1 To $listsel3[0] Step 1
                            If FileExists($movefold & "\" & $listsel3[$f]) Then
                                If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
                                $iMsgBoxAnswer = MsgBox($MB_YESNO + $MB_ICONEXCLAMATION, "File Exists", "The file/folder " & $listsel3[$f] & " you want to copy already exists. Do you want to overwrite the destination file?")
                                Select
                                    Case $iMsgBoxAnswer = $IDYES
                                        If IsFile = 0 Then
                                            $res = DirMove(GUICtrlRead($Combo1) & "\" & $listsel3[$f], $movefold & "\" & $listsel3[$f], 1)
                                        Else
                                            $res = FileMove(GUICtrlRead($Combo1) & "\" & $listsel3[$f], $movefold & "\" & $listsel3[$f], 1)
                                        EndIf
                                    Case $iMsgBoxAnswer = $IDNO

                                EndSelect
                            Else
                                If IsFile = 0 Then
                                    $res = DirMove(GUICtrlRead($Combo1) & "\" & $listsel3[$f], $movefold & "\" & $listsel3[$f])
                                Else
                                    $res = FileMove(GUICtrlRead($Combo1) & "\" & $listsel3[$f], $movefold & "\" & $listsel3[$f])
                                EndIf
                            EndIf
                        Next
                        _GUICtrlListBox_ResetContent($List1)
                        $use = GUICtrlRead($Combo1)
                        If Not FileExists($use) Then
                            #Region --- CodeWizard generated code Start ---

                            ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute
                            MsgBox($MB_OK + 262144, "invalid path", "the path you selected does not exist or is inaccessible on local device/using current user.")
                            #EndRegion --- CodeWizard generated code Start ---
                        Else


                            GUICtrlSetState($Button1, 128)
                            GUICtrlSetStyle($List1, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER))
                            $thelist = _FileListToArrayRec($use, "*", $FLTAR_FILESFOLDERS, Default, $FLTAR_SORT, Default)
                            If GUICtrlRead($Checkbox1) = 1 Then
                                For $i = 1 To $thelist[0] Step 1
                                    If IsFile($use & "\" & $thelist[$i]) = 0 Then
                                        GUICtrlSetData($List1, $thelist[$i])
                                    Else
                                        If StringRight($thelist[$i], 3) <> "mp4" And StringRight($thelist[$i], 3) <> "flv" Then
                                            ContinueLoop
                                        Else
                                            GUICtrlSetData($List1, $thelist[$i])
                                        EndIf
                                    EndIf
                                Next
                            Else
                                For $i = 1 To $thelist[0] Step 1
                                    If IsFile($use & "\" & $thelist[$i]) = 0 Then
                                        GUICtrlSetData($List1, $thelist[$i])
                                    Else
                                        If StringRight($thelist[$i], 3) <> "mp4" And StringRight($thelist[$i], 3) <> "flv" And StringRight($thelist[$i], 3) <> "zip" Then
                                            ContinueLoop
                                        Else
                                            GUICtrlSetData($List1, $thelist[$i])
                                        EndIf
                                    EndIf
                                Next
                            EndIf
                        EndIf
                    EndIf

            EndSwitch
        Case $form2
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                    $oMediaPosition.put_CurrentPosition("long", "double", 0)
                    $oMediaControl.Stop()
                    $iPlaying = 0
                    GUISwitch($Form1)
                    GUISetState(@SW_HIDE, $form2)
            EndSwitch

    EndSwitch

WEnd

Func addPath()
    If Not FileExists(@ScriptDir & "\settings.ini") Then
        #Region --- CodeWizard generated code Start ---


        ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info
        MsgBox($MB_OK + $MB_ICONASTERISK, "Select paths", "You need to select some paths so program knows where to look")
        #EndRegion --- CodeWizard generated code Start ---
        $hold = 0
    Else
        $hold = IniReadSection(@ScriptDir & "\settings.ini", "settings")
    EndIf

    Do
        $init = FileSelectFolder("Select path to add", "")
        If $init <> "" Then
            If IsArray($hold) Then
                $hold[0][0] += 1
                IniWrite(@ScriptDir & "\settings.ini", "settings", "path " & $hold[0][0], $init)
            Else
                $hold += 1
                IniWrite(@ScriptDir & "\settings.ini", "settings", "path " & $hold, $init)
            EndIf

        EndIf
        #Region --- CodeWizard generated code Start ---

        ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=None
        If Not IsDeclared("continue") Then Local $continue
        $continue = MsgBox($MB_YESNO, "More?", "Are there any more you would like to enter?")
    Until $continue = $IDNO
    $array = IniReadSection(@ScriptDir & "\settings.ini", "settings")
    Local $store[$array[0][0]]
    $here = 0
    For $i = 1 To $array[0][0] Step 1
        GUICtrlSetData($Combo1, $array[$i][1])
        ;$here += 1
    Next
    ;GUICtrlSetData ( $Combo1, $store )
EndFunc   ;==>addPath

#EndRegion --- CodeWizard generated code Start ---
Func doubleClick($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam
    Select
        Case $nID = $List1
            Switch $nNotifyCode
                Case $LBN_DBLCLK
                    $one = GUICtrlRead($List1)
                    If StringRight($one, 4) == ".mp4" Or StringRight($one, 4) == ".flv" Then
                        ShellExecute($one, "", GUICtrlRead($Combo1), "open")
                    Else
                        $again = _FileListToArrayRec(GUICtrlRead($Combo1) & "\" & $one, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, Default)
                        $th = ""
                        For $o = 1 To $again[0] Step 1
                            $spl = StringSplit($again[$o], "\")
                            $pic = False
                            If StringRight($again[$o], 4) == ".jpg" Or StringRight($again[$o], 4) == ".png" Then
                                $pic = True
                            Else
                                $pic = False
                            EndIf

                            If StringCompare($spl[$spl[0] - 1], $th) <> 0 And $pic = True Then
                                $th = $spl[$spl[0] - 1]
                                $tooo = ""
                                For $p = 1 To $spl[0] - 1 Step 1
                                    $tooo = $tooo & "\" & $spl[$p]
                                Next

                                ShellExecute($spl[$spl[0]], "", GUICtrlRead($Combo1) & "\" & $one & $tooo, "open")
                            Else
                                ContinueLoop
                            EndIf
                        Next
                    EndIf
            EndSwitch
    EndSelect
EndFunc   ;==>doubleClick
Func killmovies()
    DllClose($hDLL)
EndFunc   ;==>killmovies
Func IsFile($sFilePath)
    Return Number(FileExists($sFilePath) And StringInStr(FileGetAttrib($sFilePath), "D", 2, 1) = 0)
EndFunc   ;==>IsFile
Func GetFileName($pach)
    $corefile = ""
    $holdstring2 = ""
    $tocompare = StringSplit($pach, "\")
    If @error Then
        SetError(0)
        $corefile = $pach
        $holdstring2 = "\"
    Else
        $corefile = $tocompare[$tocompare[0]]
    EndIf
    Return $corefile
EndFunc   ;==>GetFileName


Func FilePath($thepath)
    $holdstring = ""
    $filepathstring = StringSplit($thepath, "\")
    If @error Then
        $holdstring = @error
    Else
        If $filepathstring[0] = 2 Then
            $holdstring = $filepathstring[1]
        ElseIf $filepathstring[0] = 3 Then
            $holdstring = $filepathstring[1] & "\" & $filepathstring[2]
        Else
            For $hh = 1 To $filepathstring[0] - 1 Step 1
                $holdstring = $holdstring & $filepathstring[$hh] & "\"
            Next
            $holdstring = StringTrimRight($holdstring, 1)
        EndIf
    EndIf
    Return $holdstring
EndFunc   ;==>FilePath

Func GetExtension($fileyyy)
    $holdext = ""
    $charnum = StringSplit($fileyyy, "")
    $dots = _ArrayFindAll($charnum, ".")
    For $m = $dots[UBound($dots) - 1] To $charnum[0] Step 1
        $holdext = $holdext & $charnum[$m]
    Next
    Return $holdext
EndFunc   ;==>GetExtension
Func preview($listread)
    ;If $listread = $List1 Then

    ;   If StringRight($listread, 4) = ".mp4" Or StringRight($listread, 4) = ".flv" Then
EndFunc   ;==>preview
Func _Interrupt()

    $fInterrupt = 1
EndFunc   ;==>_Interrupt
Func _SetSize($oVideoWindow, $oBasicVideo, $form2)
    Local $aClientSize = WinGetClientSize($form2)
    Local $aCall = $oBasicVideo.GetVideoSize("long", "long*", 0, "long*", 0)
    Local $iX, $iY
    Local $iWidth = $aClientSize[0], $iHeight = $aClientSize[1] - 80
    If IsArray($aCall) And $iUnFit Then
        If $iWidth > $aCall[1] Or $iHeight > $aCall[2] Then
            $iX = ($iWidth - $aCall[1]) / 2
            $iY = ($iHeight - $aCall[2]) / 2
            $iWidth = $aCall[1]
            $iHeight = $aCall[2]
            If $iY + $iHeight + 80 > $aClientSize[1] Then $iY = $aClientSize[1] - 80 - $aCall[2]
        EndIf
    EndIf
    $oVideoWindow.SetWindowPosition("long", "long", $iX, "long", $iY, "long", $iWidth, "long", $iHeight)
    Return 1
EndFunc   ;==>_SetSize

Func _InitBuilder(ByRef $oGraphBuilder, ByRef $oMediaControl, ByRef $oMediaEventEx, ByRef $oVideoWindow, ByRef $oMediaPosition, ByRef $oBasicAudio, ByRef $oBasicVideo)

    Local $tCLSID_FilterGraph = _AutoItObject_CLSIDFromString("{e436ebb3-524f-11ce-9f53-0020af0ba770}")
    Local $tIID_IGraphBuilder = _AutoItObject_CLSIDFromString("{56a868a9-0ad4-11ce-b03a-0020af0ba770}")

    Local $tIID_IMediaPosition = _AutoItObject_CLSIDFromString("{56a868b2-0ad4-11ce-b03a-0020af0ba770}")
    Local $tIID_IMediaControl = _AutoItObject_CLSIDFromString("{56A868B1-0AD4-11CE-B03A-0020AF0BA770}")
    Local $tIID_IMediaEventEx = _AutoItObject_CLSIDFromString("{56A868C0-0AD4-11CE-B03A-0020AF0BA770}")
    Local $tIID_IVideoWindow = _AutoItObject_CLSIDFromString("{56A868B4-0AD4-11CE-B03A-0020AF0BA770}")
    Local $tIID_IBasicAudio = _AutoItObject_CLSIDFromString("{56a868b3-0ad4-11ce-b03a-0020af0ba770}")
    Local $tIID_IBasicVideo = _AutoItObject_CLSIDFromString("{56a868b5-0ad4-11ce-b03a-0020af0ba770}")

    Local $pGraphBuilder
    _AutoItObject_CoCreateInstance(DllStructGetPtr($tCLSID_FilterGraph), 0, 1, DllStructGetPtr($tIID_IGraphBuilder), $pGraphBuilder)
    If Not $pGraphBuilder Then Return SetError(1, 0, 0)

    Local $tagInterface = "QueryInterface;" & _
            "AddRef;" & _
            "Release;" & _ ; IUnknown
            "AddFilter;" & _
            "RemoveFilter;" & _
            "EnumFilters;" & _
            "FindFilterByName;" & _
            "ConnectDirect;" & _
            "Reconnect;" & _
            "Disconnect;" & _
            "SetDefaultSyncSource;" & _ ; IFilterGraph
            "Connect;" & _
            "Render;" & _
            "RenderFile;" & _
            "AddSourceFilter;" & _
            "SetLogFile;" & _
            "Abort;" & _
            "ShouldOperationContinue;" ; IGraphBuilder

    ; Wrapp IGraphBuilder interface
    $oGraphBuilder = _AutoItObject_WrapperCreate($pGraphBuilder, $tagInterface)
    If @error Then Return SetError(2, 0, 0)

    ; IMediaControl IDispatch
    Local $aCall = $oGraphBuilder.QueryInterface("int", "ptr", Number(DllStructGetPtr($tIID_IMediaControl)), "idispatch*", 0) ; or directly "idispatch*"
    If IsArray($aCall) Then
        $oMediaControl = $aCall[2]
    Else
        Return SetError(3, 0, 0)
    EndIf

    ; IMediaEventEx IDispatch
    $aCall = $oGraphBuilder.QueryInterface("int", "ptr", Number(DllStructGetPtr($tIID_IMediaEventEx)), "idispatch*", 0) ; or directly "idispatch*"
    If IsArray($aCall) Then
        $oMediaEventEx = $aCall[2]
    Else
        Return SetError(4, 0, 0)
    EndIf

    ; Get pointer to IVideoWindow interface
    $aCall = $oGraphBuilder.QueryInterface("int", "ptr", Number(DllStructGetPtr($tIID_IVideoWindow)), "ptr*", 0)
    If IsArray($aCall) Then
        $pVideoWindow = $aCall[2]
    Else
        Return SetError(5, 0, 0)
    EndIf

    ; IVideoWindow is dual interface. Defining vTable methods:
    Local $tagIVideoWindow = "QueryInterface;" & _
            "AddRef;" & _
            "Release;" & _ ; IUnknown
            "GetTypeInfoCount;" & _
            "GetTypeInfo;" & _
            "GetIDsOfNames;" & _
            "Invoke;" & _ ; IDispatch
            "put_Caption;" & _
            "get_Caption;" & _
            "put_WindowStyle;" & _
            "get_WindowStyle;" & _
            "put_WindowStyleEx;" & _
            "put_WindowStyleEx;" & _
            "put_AutoShow;" & _
            "get_AutoShow;" & _
            "put_WindowState;" & _
            "get_WindowState;" & _
            "put_BackgroundPalette;" & _
            "get_BackgroundPalette;" & _
            "put_Visible;" & _
            "get_Visible;" & _
            "put_Left;" & _
            "get_Left;" & _
            "put_Width;" & _
            "get_Width;" & _
            "put_Top;" & _
            "get_Top;" & _
            "put_Height;" & _
            "get_Height;" & _
            "put_Owner;" & _
            "get_Owner;" & _
            "put_MessageDrain;" & _
            "get_MessageDrain;" & _
            "get_BorderColor;" & _
            "put_BorderColor;" & _
            "get_FullScreenMode;" & _
            "put_FullScreenMode;" & _
            "SetWindowForeground;" & _
            "NotifyOwnerMessage;" & _
            "SetWindowPosition;" & _
            "GetWindowPosition;" & _
            "GetMinIdealImageSize;" & _
            "GetMaxIdealImageSize;" & _
            "GetRestorePosition;" & _
            "HideCursor;" & _
            "IsCursorHidden;" ; IVideoWindow

    ; Wrapp it:
    $oVideoWindow = _AutoItObject_WrapperCreate($pVideoWindow, $tagIVideoWindow)
    If @error Then Return SetError(6, 0, 0)

    ; Get pointer to IMediaPosition interface
    $aCall = $oGraphBuilder.QueryInterface("int", "ptr", Number(DllStructGetPtr($tIID_IMediaPosition)), "ptr*", 0)
    If IsArray($aCall) Then
        $pMediaPosition = $aCall[2]
    Else
        Return SetError(7, 0, 0)
    EndIf

    ; IMediaPosition is dual interface. Defining vTable methods:
    Local $tagIMediaPosition = "QueryInterface;" & _
            "AddRef;" & _
            "Release;" & _ ; IUnknown
            "GetTypeInfoCount;" & _
            "GetTypeInfo;" & _
            "GetIDsOfNames;" & _
            "Invoke;" & _ ; IDispatch
            "get_Duration;" & _
            "put_CurrentPosition;" & _
            "get_CurrentPosition;" & _
            "get_StopTime;" & _
            "put_StopTime;" & _
            "get_PrerollTime;" & _
            "put_PrerollTime;" & _
            "put_Rate;" & _
            "get_Rate;" & _
            "CanSeekForward;" & _
            "CanSeekBackward;" ; IMediaPosition

    ; Wrapp it:
    $oMediaPosition = _AutoItObject_WrapperCreate($pMediaPosition, $tagIMediaPosition)
    If @error Then Return SetError(8, 0, 0)

    ; Get pointer to IBasicAudio interface
    $aCall = $oGraphBuilder.QueryInterface("int", "ptr", Number(DllStructGetPtr($tIID_IBasicAudio)), "ptr*", 0)
    If IsArray($aCall) Then
        $pBasicAudio = $aCall[2]
    Else
        Return SetError(9, 0, 0)
    EndIf

    ; IBasicAudio is dual interface. Defining vTable methods:
    Local $tagIBasicAudio = "QueryInterface;" & _
            "AddRef;" & _
            "Release;" & _ ; IUnknown
            "GetTypeInfoCount;" & _
            "GetTypeInfo;" & _
            "GetIDsOfNames;" & _
            "Invoke;" & _ ; IDispatch
            "put_Volume;" & _
            "get_Volume;" & _
            "put_Balance;" & _
            "get_Balance;" ; IBasicAudio

    ; Wrapp it:
    $oBasicAudio = _AutoItObject_WrapperCreate($pBasicAudio, $tagIBasicAudio)
    If @error Then Return SetError(10, 0, 0)

    ; Get pointer to IBasicVideo interface
    $aCall = $oGraphBuilder.QueryInterface("int", "ptr", Number(DllStructGetPtr($tIID_IBasicVideo)), "ptr*", 0)
    If IsArray($aCall) Then
        $pIBasicVideo = $aCall[2]
    Else
        Return SetError(11, 0, 0)
    EndIf

    ; IBasicVideo is dual interface. Defining vTable methods:
    Local $tagIBasicVideo = "QueryInterface;" & _
            "AddRef;" & _
            "Release;" & _ ; IUnknown
            "GetTypeInfoCount;" & _
            "GetTypeInfo;" & _
            "GetIDsOfNames;" & _
            "Invoke;" & _ ; IDispatch
            "get_AvgTimePerFrame;" & _
            "get_BitRate;" & _
            "get_BitErrorRate;" & _
            "get_VideoWidth;" & _
            "get_VideoHeight;" & _
            "put_SourceLeft;" & _
            "get_SourceLeft;" & _
            "put_SourceWidth;" & _
            "get_SourceWidth;" & _
            "put_SourceTop;" & _
            "get_SourceTop;" & _
            "put_SourceHeight;" & _
            "get_SourceHeight;" & _
            "put_DestinationLeft;" & _
            "get_DestinationLeft;" & _
            "put_DestinationWidth;" & _
            "get_DestinationWidth;" & _
            "put_DestinationTop;" & _
            "get_DestinationTop;" & _
            "put_DestinationHeight;" & _
            "get_DestinationHeight;" & _
            "SetSourcePosition;" & _
            "GetSourcePosition;" & _
            "SetDefaultSourcePosition;" & _
            "SetDestinationPosition;" & _
            "GetDestinationPosition;" & _
            "SetDefaultDestinationPosition;" & _
            "GetVideoSize;" & _
            "GetVideoPaletteEntries;" & _
            "GetCurrentImage;" & _
            "IsUsingDefaultSource;" & _
            "IsUsingDefaultDestination;" ; IBasicVideo

    ; Wrapp it:
    $oBasicVideo = _AutoItObject_WrapperCreate($pIBasicVideo, $tagIBasicVideo)
    If @error Then Return SetError(12, 0, 0)

    Return 1 ; All ok!

EndFunc   ;==>_InitBuilder

Func _ReleaseBuilder(ByRef $oGraphBuilder, ByRef $oMediaControl, ByRef $oMediaEventEx, ByRef $oVideoWindow, ByRef $oMediaPosition, ByRef $oBasicAudio, ByRef $oBasicVideo)
    If IsObj($oMediaControl) Then $oMediaControl.Stop()
    If IsObj($oVideoWindow) Then $oVideoWindow.put_Visible("long", "long", 0)
    If IsObj($oVideoWindow) Then $oVideoWindow.put_Owner("long", "hwnd", 0)
    $oGraphBuilder = 0
    $oMediaControl = 0
    $oMediaEventEx = 0
    $oVideoWindow = 0
    $oMediaPosition = 0
    $oBasicAudio = 0
    $oBasicVideo = 0
EndFunc   ;==>_ReleaseBuilder


Func _AdjustMediaViewPos($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg
    If $hWnd = $Form1 Then
        Local $aClientSize[2] = [BitAND($lParam, 65535), BitShift($lParam, 16)]
        Local $iX, $iY
        Local $iWidth = $aClientSize[0], $iHeight = $aClientSize[1] - 80
        If IsObj($oBasicVideo) Then
            Local $aCall = $oBasicVideo.GetVideoSize("long", "long*", 0, "long*", 0)
            If IsArray($aCall) Then
                If $iUnFit Then
                    If $iWidth > $aCall[1] Or $iHeight > $aCall[2] Then
                        $iX = ($iWidth - $aCall[1]) / 2
                        $iY = ($iHeight - $aCall[2]) / 2
                        $iWidth = $aCall[1]
                        $iHeight = $aCall[2]
                        If $iY + $iHeight + 80 > $aClientSize[1] Then $iY = $aClientSize[1] - 80 - $aCall[2]
                    EndIf
                EndIf
            EndIf
        EndIf
        If IsObj($oVideoWindow) Then $oVideoWindow.SetWindowPosition("long", "long", $iX, "long", $iY, "long", $iWidth, "long", $iHeight)
    EndIf
EndFunc   ;==>_AdjustMediaViewPos

Func _SetMinMax($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    If $hWnd = $Form1 Then
        Local $tMINMAXINFO = DllStructCreate("int;int;" & _
                "int MaxSizeX; int MaxSizeY;" & _
                "int MaxPositionX;int MaxPositionY;" & _
                "int MinTrackSizeX; int MinTrackSizeY;" & _
                "int MaxTrackSizeX; int MaxTrackSizeY", _
                $lParam)
        DllStructSetData($tMINMAXINFO, "MinTrackSizeX", 520)
        DllStructSetData($tMINMAXINFO, "MinTrackSizeY", 80)
    EndIf
EndFunc   ;==>_SetMinMax

Any idea why/how this is happening?

Edited by MattHiggs
Link to comment
Share on other sites

Maybe an encoding issue? If the content are absolutely identical, then something external to the file, which I can't even speculate as to what that would/could be.

If you calculate a file hash for both files, are they identical?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...