; File name: BigPause-10-m3u.au3 #include #include #include Opt("WinTitleMatchMode", 2) HotKeySet("^!{END}", "MyExit") $vlcPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\vlc.exe", "") If $vlcPath = "" Then Exit MsgBox(0, "", "VLC is not installed!") Global $fileTypes = "mp4 wmv avi mkv flv webM" Global $aList, $guiMsg, $lPaused If Not FileExists(@ScriptDir & "\VLC-Playlist.m3u") Then ; All file names must be in English characters. Initially the playlist will be in alphabetical order. ; MyExit() rearranges the playlist so that current file comes on the top $aList = _FileListToArrayRec(@ScriptDir, StringReplace("*." & $fileTypes, " ", ";*."), 1, 0, 0, 2) If Not IsArray($aList) Then MsgBox(0, "", "This program should reside in the driectory where video files are located.") Exit EndIf Global $oShellApp = ObjCreate("shell.application"), $sDir, $sFile, $playList, $iIndex $playList &= '#EXTM3U' & @CR For $i = 1 To $aList[0] $sTitle = FileGetProperty(21) ; media title in Windows 10 $sDuration = FileGetProperty(27) ; media duration in Windows 10 $playList &= '#EXTINF:' & $sDuration & ',' & $sTitle & @CR $playList &= 'file:///' & URLEncode($aList[$i]) & @CR Next $fh = FileOpen(@ScriptDir & "\VLC-Playlist.m3u", 2) FileWrite($fh, $playList) FileClose($fh) EndIf ; from Koda buttons creation ;~ #include ;~ #include ;~ #include ;~ #Region ### START Koda GUI section ### Form=C:\Users\Carl\Documents\AutoIt\CarlPlay\BigButton-01.kxf ;~ Global $Form1 = GUICreate("Form1", 1025, 801, -1, -1) ;~ Global $Pause = GUICtrlCreateButton("Pause", 8, 48, 1009, 649) ;~ GUICtrlSetFont(-1, 250, 400, 0, "Arial Rounded MT Bold") ;~ Global $Next = GUICtrlCreateButton("Next", 552, 720, 465, 73) ;~ GUICtrlSetFont(-1, 60, 400, 0, "Arial Rounded MT Bold") ;~ Global $Previous = GUICtrlCreateButton("Previous", 8, 720, 457, 73) ;~ GUICtrlSetFont(-1, 60, 400, 0, "Arial Rounded MT Bold") ;~ Global $Exit = GUICtrlCreateButton("Exit", 488, 8, 33, 17) ;~ GUICtrlSetFont(-1, 10, 400, 0, "Arial Rounded MT Bold") ;~ GUISetState(@SW_SHOW) ;~ #EndRegion ### END Koda GUI section ### ;~ While 1 ;~ $nMsg = GUIGetMsg() ;~ Switch $nMsg ;~ Case $GUI_EVENT_CLOSE ;~ Exit ;~ EndSwitch ;~ WEnd ; $vcWidth and $vcHeight set the rectangular dimensions of the control ; Button numbers = Left, Top, Width, Height ;Global $vcWidth = 800, $shuttleWidth = 24, $sliderLength = $vcWidth-$shuttleWidth, $vcHeight = 800 Global $outerBorder = 10 Global $exitHeight = 20 Global $exitWidth = 50 Global $buttonGap = 50 Global $vcWidth = 800, $vcHeight = 800 Global $pauseWidth = $vcWidth-$outerBorder*2 Global $prevnextHeight=80 Global $pauseHeight = $vcHeight - $prevnextHeight - 2*$buttonGap - $exitHeight Global $prevnextTop = $vcHeight -$buttonGap - $prevnextHeight -$outerBorder Global $vcGUI = GUICreate("zPlayer_Carl by C Y Cho", $vcWidth, $vcHeight, -1, -1) Global $vcPause = GUICtrlCreateButton("Pause", $outerBorder, $exitHeight+$buttonGap, $pauseWidth, $pauseHeight) GUICtrlSetFont(-1, 100, 900) GUICtrlSetColor(-1, 0x666666) GUICtrlSetCursor(-1, 0) Global $vcPrevious = GUICtrlCreateButton("Previous", $outerBorder, $prevnextTop+$buttonGap, $vcWidth/2-$buttonGap, $prevnextHeight) GUICtrlSetFont(-1, 40, 900) GUICtrlSetColor(-1, 0x666666) GUICtrlSetCursor(-1, 0) Global $vcNext = GUICtrlCreateButton("Next", $vcWidth/2+$buttonGap, $prevnextTop+$buttonGap, $vcWidth/2 - $buttonGap -$outerBorder, $prevnextHeight) GUICtrlSetFont(-1, 40, 900) GUICtrlSetColor(-1, 0x666666) GUICtrlSetCursor(-1, 0) Global $vcExit = GUICtrlCreateButton("Exit", ($vcWidth-$exitWidth)/2, $outerBorder,$exitWidth,$exitHeight) GUICtrlSetFont(-1, 10, 900) GUICtrlSetColor(-1, 0x666666) GUICtrlSetCursor(-1, 0) GUISetState(@SW_SHOW, $vcGUI) WinSetOnTop($vcGUI, "", 1) Run($vlcPath & " " & @ScriptDir & "\VLC-Playlist.m3u") Sleep(1000) $hWnd = WinGetHandle("[CLASS:Qt5QWindowIcon]", "VLC") ; Please check if your VLC window class matches with this ;WinMove($hWnd, "", @DesktopWidth, 0) ; This line should be uncommented when using dual monitors WinSetState($hWnd, "", @SW_MAXIMIZE) While 1 $guiMsg = GUIGetMsg() Switch $guiMsg Case $vcNext WinActivate($hWnd) Send("{MEDIA_NEXT}") If $lPaused = True Then GUICtrlSetData($vcPause, "Pause") $lPaused = False EndIf Case $vcPrevious WinActivate($hWnd) Send("{MEDIA_PREV}") If $lPaused = True Then GUICtrlSetData($vcPause, "Pause") $lPaused = False EndIf Case $vcPause WinActivate($hWnd) If $lPaused = False Then GUICtrlSetData($vcPause, "Play") $lPaused = True Else GUICtrlSetData($vcPause, "Pause") $lPaused = False EndIf Send("{MEDIA_PLAY_PAUSE}") Case $vcExit, $GUI_EVENT_CLOSE MyExit() EndSwitch If Not WinExists($hWnd) Then MyExit() WEnd Func FileGetProperty($iIndex) Local $sDir = StringTrimRight($aList[$i], (StringLen($aList[$i]) - StringInStr($aList[$i], "\", 0, -1))) Local $sFile = StringTrimLeft($aList[$i], StringInStr($aList[$i], "\", 0, -1)) Local $oDir = $oShellApp.NameSpace($sDir) Local $oFile = $oDir.Parsename($sFile) Local $sProperty = $oDir.GetDetailsOf($oFile, $iIndex) If $iIndex = 21 And $sProperty = "" Then ; Title $sProperty = $sFile ElseIf $iIndex = 27 And StringInStr($sProperty, ":") Then ; Duration Local $aProperty = StringSplit($sProperty, ":") $sProperty = $aProperty[1]*3600 + $aProperty[2]*60 + $aProperty[3] EndIf Return $sProperty EndFunc Func URLEncode($sFileName) ; encodes file names to UTF-8 Local $sBinary = StringToBinary($sFileName, 4) Local $sEncodedName = "" For $j = 1 To BinaryLen($sBinary) Local $sByte = StringTrimLeft(BinaryMid($sBinary, $j, 1), 2) Local $ascii = Dec($sByte) If ($ascii >= 48 And $ascii <= 57) Or ($ascii >= 65 And $ascii <= 90) Or ($ascii >= 97 And $ascii <= 122) _ Or StringInStr("45 46 58 91 93 95", StringRight(1000+$ascii, 2)) Then $sEncodedName &= Chr($ascii) ElseIf $ascii = 92 Then $sEncodedName &= "/" Else $sEncodedName &= "%" & $sByte EndIf Next Return $sEncodedName EndFunc Func MyExit() ; Playlist is saved, with current file on the top $winTitle = WinGetTitle($hWnd) $winTitle = StringLeft($winTitle, StringInStr($winTitle, " - VLC")-1) $playList = FileReadToArray(@ScriptDir & "\VLC-Playlist.m3u") $fh = FileOpen(@ScriptDir & "\VLC-Playlist.m3u", 2) FileWriteLine($fh, "#EXTM3U") For $i = 1 To UBound($playList)-1 ; determine the current file by comparing window title to playlist $sTitle = StringMid($playList[$i], StringInStr($playList[$i], ",")+1) If StringInStr($playList[$i], "#EXTINF:") And StringInStr($winTitle, $sTitle) Then ExitLoop Next _FileWriteFromArray($fh, $playList, $i) ; from current file to last file _FileWriteFromArray($fh, $playList, 1, $i-1) ; from first file to file before the current file FileClose($fh) ProcessClose("vlc.exe") GUIDelete() Exit EndFunc