; File name: BigPause-118-m3u.au3 ; This file was mostly made by CYCho and minimally modified by carlvanwormer. ; It is the dumbest remote control possible, with the .exe set up to auto-run on a tablet at boot-up. ; It was desiged to be a control for my minimally functional dad so he could control the 8 seasons ; of the Monk series. It works great for his needs. ; It needed to run the VLC player to access the second channel English sound and captioning. ; Many thanks to the significant support that CYCho gave as I struggled on my simple details. ; The other physical control was modified to have a single, giant (4" diameter" button to power the TV on and off. ; ; note: the play-pause button changes color to indicate activity, but I couldn't use Play changing to Pause with the ; color changes because the command could get out-of-sync with rapid activation. Since I couldn't fugure out how to ; issue separate play and pause commands, I used this cop-out solution. ; #include #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 ; $vcWidth and $vcHeight set the rectangular dimensions of the control ; Button numbers = Left, Top, Width, Height ; set control and button sizes Global $vcWidth = 1260, $vcHeight = 700 ; main control dimensions Global $outerBorder = 10 ; gap between buttons and border Global $buttonGap = 50 ; gap between buttons Global $exitHeight = 20 ; Exit button (small to minimize accidental activation) Global $exitWidth = 50 ; Exit button Global $prevnextHeight=70 ; Height of Previous and Next ; then calculate other button values Global $pauseWidth = $vcWidth-2*$outerBorder ; pause fills width Global $pauseHeight = $vcHeight - $prevnextHeight - $buttonGap - $exitHeight - $outerBorder ; Pause fills remaining height Global $prevnextTop = $exitHeight - $buttonGap + $outerBorder ; position for uniform spacing Global $vcGUI = GUICreate("zPlayer_Simple by C Y Cho (CBV mods V1.0)", $vcWidth, $vcHeight, -1, -1) Global $vcPause = GUICtrlCreateButton("Play-Pause", $outerBorder, $exitHeight+$buttonGap + $prevnextHeight, $pauseWidth, $pauseHeight) GUICtrlSetFont(-1, $vcWidth/8, 900) GUICtrlSetColor(-1, 0x000000) ;GUICtrlSetBkColor(-1, 0x666666) GUICtrlSetBkColor($vcPause, $COLOR_RED) 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) Global $pid, $hWnd, $seconds, $h $h = TimerInit() $pid = Run($vlcPath & " " & @ScriptDir & "\VLC-Playlist.m3u") While 1 If $pid <> "" Then ConsoleWrite ("**PID obtained after " & TimerDiff($h) & " milliseconds = " & $pid & @CRLF) ExitLoop EndIf If $seconds > 10 Then ConsoleWrite ("**VLC launch timeeout after 10 seconds" & @CRLF) GUIDelete() Exit EndIf Sleep(10) WEnd $h = TimerInit() While 1 $hWnd = WinGetHandle(" - VLC ") If $hWnd <> "" Then ExitLoop If TimerDiff($h) > 10000 Then ProcessClose("vlc.exe") ConsoleWrite ("**WinGetHandle() timedout after 10 seconds" & @CRLF) GUIDelete() Exit EndIf Sleep(100) WEnd ConsoleWrite ("**Window handle obtained after " & TimerDiff($h) & " milliseconds = " & $hWnd & @CRLF) WinMove($hWnd, "", @DesktopWidth, 0) ; This line should be uncommented when using dual monitors WinSetState($hWnd, "", @SW_MAXIMIZE) ;note - the play/pause button can get out of sync since it is a toggle. try to ficd out if there is a vlc status byte to indicate pause state While 1 $guiMsg = GUIGetMsg() Switch $guiMsg Case $vcNext WinActivate($hWnd) Send("{MEDIA_NEXT}") If $lPaused = True Then GUICtrlSetData($vcPause, "Play-Pause") GUICtrlSetBkColor($vcPause, $COLOR_RED) $lPaused = False EndIf Case $vcPrevious WinActivate($hWnd) Send("{MEDIA_PREV}") If $lPaused = True Then GUICtrlSetData($vcPause, "Play-Pause") GUICtrlSetBkColor($vcPause, $COLOR_RED) $lPaused = False EndIf Case $vcPause WinActivate($hWnd) If $lPaused = False Then GUICtrlSetData($vcPause, "Play-Pause") GUICtrlSetBkColor($vcPause, $COLOR_GREEN) $lPaused = True Else GUICtrlSetData($vcPause, "Play-Pause") GUICtrlSetBkColor($vcPause, $COLOR_RED) $lPaused = False EndIf Send("{MEDIA_PLAY_PAUSE}") Case $vcExit, $GUI_EVENT_CLOSE MyExit() EndSwitch 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