Jump to content

Recommended Posts

Posted

Hello!

i am new to autoit and want to simplify my task.

for now i am writing a commandline:

c:\vlc\vlc.exe c:\media\wildlife.mp4 c:\media\nature.mp4 --loop --fullscreen --video-on-top

and i want to create a programm which does:

c:\myApp.exe wildlife.mp4 nature.mp4

so the application will insert the  path to vlc.exe and the path to the media folder (c:\media) and parameters (--loop --fullscreen --video-on-top) at the end, for me

 

can anybody give me some help please?

 

marco

 

 

 

 

 

 

 

  • Moderators
Posted

@imagica welcome to the forum. Look at Run, RunWait, ShellExecute, and ShellExecuteWait in the help file. All four entries have great examples to get you started.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

So now i have:

#include <Array.au3>

$vlc="c:\vlc\vlc.exe"
$media="c:\vlc\"
$params="--loop --fullscreen --video-on-top"


if $CmdLine[0] >0 then
ShellExecute($vlc,$media & $CmdLine[1] & " " & $params)
endif

this works when i have only one movie:

c:\myApp Wildlife.mp4

but what to change if there are two or more movies, $CmdLine[0] does not work...

Posted

yes, i need to know how to get all passed movienames to my $cmdline, and then i guess i have to put it into a for ... next loop

 

Yes, Marco is Italien...

Posted

@imagica
You can do it in several ways...
How do you want to launch your command line? You will prompt the path and the filename for each file?
By the way, if you intend to do it in that way, you can pass 63 parameters maximum, enclosing each film in double quotes and dividing them by a space.
Something like this:

YourScript.exe "Film1" "Film2" "FilmN" --parameters

:)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Posted

but then i have to insert the fullpath to the moviefile...

i want to set the path to the movies, e.g. "c:\media\" into my app, also the parameters

 

 

Posted (edited)

You could do something like this:

#include <Array.au3>
#include <File.au3>

$vlc="c:\vlc\vlc.exe"
$media="c:\vlc\"
$params="--loop --fullscreen --video-on-top"
$files = _FileListToArray($media, "*.mp4", $FLTA_FILES, True)

For $f = 1 To $files[0]
RunWait($vlc&' '&$files[$f] &' '& $params)
Next

Untested, but i think you get the idea, else, we're here to guide you.

There are no error checks or anything, it's more of a proof of concept.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

so when i type:

c:\myApp.exe Movie1.mp4 Movie2.mp4

it actually does:

c:\vlc.exe c:\media\Movie1.mp4 c:\media\Movie2.mp4  --loop --fullscreen --video-on-top

Posted
19 minutes ago, careca said:

You could do something like this:

#include <Array.au3>
#include <File.au3>

$vlc="c:\vlc\vlc.exe"
$media="c:\vlc\"
$params="--loop --fullscreen --video-on-top"
$files = _FileListToArray($media, "*.mp4", $FLTA_FILES, True)

For $f = 1 To $files[0]
RunWait($vlc&' '&$files[$f] &' '& $params)
Next

Untested, but i think you get the idea, else, we're here to guide you.

There are no error checks or anything, it's more of a proof of concept.

this adds a list of *.mp4 files but i cannot set the playback order that way 

Posted

no dialog please...

 

so, when i type:

c:\myApp.exe Movie1.mp4 Movie2.mp4

 

it actually should do:

c:\vlc.exe c:\media\Movie1.mp4 c:\media\Movie2.mp4  --loop --fullscreen --video-on-top

 

inserting the bold text automatically...

anyone, please?

Posted

I didn't think it would work if you give vlc multiple media files at once, does it?

#include <Array.au3>

$vlc="c:\vlc\vlc.exe"
$media="c:\vlc\"
$params="--loop --fullscreen --video-on-top"
Local $files[3]
$files[0] = 'abc.mp4'
$files[1] = 'def.mp4'
$files[2] = 'ghj.mp4'

ConsoleWrite($vlc&' '&$media&$files[0]&' '&$media&$files[1]&' '&$media&$files[2] &' '& $params &@CRLF)
;RunWait($vlc&' '&$media&$files[0]&' '&$media&$files[1]&' '&$media&$files[2] &' '& $params)

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

@careca

thanks, but the filenames are coming from a Database, i cannot hardcode them and the number of Movies are different each time.

But $cmdline is in my opinion which holds the passed parameters?

So i only have to Go through that array and add it to a variable... but here i am stuck...

 

Posted (edited)

Your problem is you need multiple things but nobody understand your underlying needs are.  So we all trying to suggest you a solution, but no solution is perfect for you since we do not understand what you really intend to do.  So I suggest you start scripting and we can see what you mean....

Edited by Nine
Posted

This is the solution for you, compile the program into exe and select the videos you want to run and drag and drop into the program icon. Good luck!

#NoTrayIcon
Global $sPath_vlc_EXE = "VLC.exe" ; Change your VLC path here!
Global $iParams = "--loop --fullscreen --video-on-top"

If $sPath_vlc_EXE == "" Or Not FileExists($sPath_vlc_EXE) Then $sPath_vlc_EXE = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC", "")
If $sPath_vlc_EXE == "" Or Not FileExists($sPath_vlc_EXE) Then $sPath_vlc_EXE = @HomeDrive&"\Program Files (x86)\VideoLAN\VLC\VLC.exe"
If $sPath_vlc_EXE == "" Or Not FileExists($sPath_vlc_EXE) Then $sPath_vlc_EXE = @HomeDrive&"\Program Files\VideoLAN\VLC\VLC.exe"
If $sPath_vlc_EXE == "" Or Not FileExists($sPath_vlc_EXE) Then Exit MsgBox(16 + 262144, "VLC Play", "VLC.exe is Not Found !" & @CRLF & "Make sure you have installed VLC or configure the VLC path correctly!")

Global $aCmdLineRaw = StringReplace($CmdLineRaw, '/ErrorStdOut "' & @ScriptFullPath & '"', "")
Global $iNewCMD, $aCmdLine = _WinAPI_CommandLineToArgv($aCmdLineRaw)
If IsArray($aCmdLine) And $aCmdLine[0] > 0 Then
    For $i = 1 To $aCmdLine[0]
        If FileExists($aCmdLine[$i]) Then
            $iNewCMD &= '"' & $aCmdLine[$i] & '" '
        EndIf
    Next
EndIf
If $iNewCMD <>"" Then
    ShellExecute($sPath_vlc_EXE, $iNewCMD & $iParams)
Else
    MsgBox(16 + 262144, "VLC Play", "No File for Play !")
EndIf
Exit

Func _WinAPI_CommandLineToArgv($sCmd)
    Local $aResult[1] = [0]
    $sCmd = StringStripWS($sCmd, 1 + 2)
    If Not $sCmd Then
        Return $aResult
    EndIf
    Local $aRet = DllCall('shell32.dll', 'ptr', 'CommandLineToArgvW', 'wstr', $sCmd, 'int*', 0)
    If @error Or Not $aRet[0] Or (Not $aRet[2]) Then Return SetError(@error + 10, @extended, 0)
    Local $tPtr = DllStructCreate('ptr[' & $aRet[2] & ']', $aRet[0])
    Dim $aResult[$aRet[2] + 1] = [$aRet[2]]
    For $i = 1 To $aRet[2]
        $aResult[$i] = _WinAPI_GetString(DllStructGetData($tPtr, 1, $i))
    Next
    DllCall("kernel32.dll", "handle", "LocalFree", "handle", $aRet[0])
    Return $aResult
EndFunc   ;==>_WinAPI_CommandLineToArgv
Func _WinAPI_StrLen($pString, $bUnicode = True)
    Local $W = ''
    If $bUnicode Then $W = 'W'
    Local $aRet = DllCall('kernel32.dll', 'int', 'lstrlen' & $W, 'struct*', $pString)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aRet[0]
EndFunc   ;==>_WinAPI_StrLen
Func _WinAPI_GetString($pString, $bUnicode = True)
    Local $iLength = _WinAPI_StrLen($pString, $bUnicode)
    If @error Or Not $iLength Then Return SetError(@error + 10, @extended, '')
    Local $tString = DllStructCreate(__Iif($bUnicode, 'wchar', 'char') & '[' & ($iLength + 1) & ']', $pString)
    If @error Then Return SetError(@error, @extended, '')
    Return SetExtended($iLength, DllStructGetData($tString, 1))
EndFunc   ;==>_WinAPI_GetString
Func __Iif($bTest, $vTrue, $vFalse)
    Return $bTest ? $vTrue : $vFalse
EndFunc   ;==>__Iif
; Script by Dao Vann Trong - Trong.LIVE

 

Regards,
 

Posted

GUI version with drag and drop:

#NoTrayIcon

Global Const $iPath_vlc_EXE = "VLC.exe" ; Change your VLC path here!
Global Const $iParams = "--loop --fullscreen --video-on-top"

Global $VLC_Params, $sPath_vlc_EXE = _Read_VLC_Path()
Global Const $__WINVER = __WINVER()
Global $AppWindows = GUICreate("=== VLC PLAY TOOL  ===", 523, 193, -1, -1, -1, BitOR(0x00000010, 0x00000100))
GUISetBkColor(0xFFFFFF, $AppWindows)
GUICtrlCreateLabel("VLC.exe path (option)", 24, 8, 106, 17, -1, 0x00100000)
GUICtrlSetState(-1, 8)
Global $Input_VLC_Path = GUICtrlCreateInput($sPath_vlc_EXE, 144, 8, 289, 21)
Global $Button_Select_PathVLC = GUICtrlCreateButton("...", 440, 8, 75, 25)
GUICtrlCreateLabel("VLC Params (option)", 24, 40, 116, 17, -1, 0x00100000)
GUICtrlSetState(-1, 8)
Global $Input_VLC_Params = GUICtrlCreateInput($iParams, 144, 40, 369, 21)
Global $Button_Select_MediaFiles = GUICtrlCreateButton("Drag and drop media files to here | OR | Press here for select media file to PLAY", 8, 72, 505, 113)
GUICtrlSetState(-1, 8)
Global $aCmdLineRaw = StringReplace($CmdLineRaw, '/ErrorStdOut "' & @ScriptFullPath & '"', "")
Global $iNewCMD, $aCmdLine = _WinAPI_CommandLineToArgv($aCmdLineRaw)
If IsArray($aCmdLine) And $aCmdLine[0] > 0 Then
    For $i = 1 To $aCmdLine[0]
        If FileExists($aCmdLine[$i]) Then
            $iNewCMD &= '"' & $aCmdLine[$i] & '" '
        EndIf
    Next
EndIf
If ($iNewCMD <> "") And FileExists($sPath_vlc_EXE) Then
    ShellExecute($sPath_vlc_EXE, $iNewCMD & $iParams)
    Exit
EndIf
If IsAdmin() Then
    _WinAPI_ChangeWindowMessageFilterEx($AppWindows, 0x0233, 1)
    _WinAPI_ChangeWindowMessageFilterEx($AppWindows, 0x004A, 1)
    _WinAPI_ChangeWindowMessageFilterEx($AppWindows, 0x0049, 1)
EndIf
Global $__aDropFiles
GUIRegisterMsg(0x0233, "WM_DROPFILES")
Global $nMsg
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -13
            If $__aDropFiles[0] > 0 Then
                $sPath_vlc_EXE = _Read_VLC_Path($Input_VLC_Path)
                $VLC_Params = GUICtrlRead($Input_VLC_Params)
                For $i = 1 To $__aDropFiles[0]
                    ConsoleWrite($__aDropFiles[$i] & @CRLF)
                    $iNewCMD &= '"' & $__aDropFiles[$i] & '" '
                Next
                If $iNewCMD <> "" And FileExists($sPath_vlc_EXE) Then ShellExecute($sPath_vlc_EXE, $iNewCMD & $VLC_Params)
            EndIf
        Case $Button_Select_PathVLC
            Local $sFileOpenDialog = FileOpenDialog("Hold down Ctrl or Shift to choose multiple files.", @ProgramFilesDir, "VLC Execute (vlc.exe)|All files (*.exe)", 1, "vlc.exe", $AppWindows)
            If @error Then
                ContinueLoop
            Else
                GUICtrlSetData($Input_VLC_Path, $sFileOpenDialog)
            EndIf
        Case $Button_Select_MediaFiles
            Local $sFileOpenDialog = FileOpenDialog("Hold down Ctrl or Shift to choose multiple files.", @MyDocumentsDir, "MP4 File (*.mp4)|MKV File (*.MKV)|All files (*.*)", BitOR(1, 4), "", $AppWindows)
            If @error Then
                ContinueLoop
            Else
                $sPath_vlc_EXE = _Read_VLC_Path($Input_VLC_Path)
                $VLC_Params = GUICtrlRead($Input_VLC_Params)
                If StringInStr($sFileOpenDialog, "|") Then
                    Local $aFileOpenDialog = StringSplit($sFileOpenDialog & "|", "|", 1)
                    For $i = 2 To $aFileOpenDialog[0] - 1
                        If FileExists($aFileOpenDialog[1] & "\" & $aFileOpenDialog[$i]) Then $iNewCMD &= '"' & $aFileOpenDialog[1] & "\" & $aFileOpenDialog[$i] & '" '
                    Next
                Else
                    If FileExists($sFileOpenDialog) Then $iNewCMD = '"' & $sFileOpenDialog & '" '
                EndIf
                If ($iNewCMD <> "") And FileExists($sPath_vlc_EXE) Then
                    ShellExecute($sPath_vlc_EXE, $iNewCMD & $iParams)
                    Exit
                EndIf
            EndIf
        Case -3
            Exit
    EndSwitch
WEnd
Exit
Func _Read_VLC_Path($iCONTROL = 0)
    Local $xPath_vlc_EXE
    If $iCONTROL Then $xPath_vlc_EXE = GUICtrlRead($iCONTROL)
    If $xPath_vlc_EXE == "" Or Not FileExists($xPath_vlc_EXE) Then $xPath_vlc_EXE = $iPath_vlc_EXE
    If $xPath_vlc_EXE == "" Or Not FileExists($xPath_vlc_EXE) Then $xPath_vlc_EXE = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC", "")
    If $xPath_vlc_EXE == "" Or Not FileExists($xPath_vlc_EXE) Then $xPath_vlc_EXE = @HomeDrive & "\Program Files (x86)\VideoLAN\VLC\VLC.exe"
    If $xPath_vlc_EXE == "" Or Not FileExists($xPath_vlc_EXE) Then $xPath_vlc_EXE = @HomeDrive & "\Program Files\VideoLAN\VLC\VLC.exe"
    If $xPath_vlc_EXE == "" Or Not FileExists($xPath_vlc_EXE) Then MsgBox(16 + 262144, "VLC Play", "VLC.exe is Not Found !" & @CRLF & "Make sure you have installed VLC or configure the VLC path correctly!")
    Return $xPath_vlc_EXE
EndFunc   ;==>_Read_VLC_Path
Func WM_DROPFILES($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $ilParam
    Switch $iMsg
        Case 0x0233
            Local $aReturn = _WinAPI_DragQueryFileEx($iwParam)
            If IsArray($aReturn) Then
                $__aDropFiles = $aReturn
            Else
                Local $aError[1] = [0]
                $__aDropFiles = $aError
            EndIf
    EndSwitch
    Return 'GUI_RUNDEFMSG'
EndFunc   ;==>WM_DROPFILES

Func __WINVER()
    Local $tOSVI = DllStructCreate('struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct')
    DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI))
    Local $aRet = DllCall('kernel32.dll', 'bool', 'GetVersionExW', 'struct*', $tOSVI)
    If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0)
    Return BitOR(BitShift(DllStructGetData($tOSVI, 2), -8), DllStructGetData($tOSVI, 3))
EndFunc   ;==>__WINVER
Func _WinAPI_CommandLineToArgv($sCmd)
    Local $aResult[1] = [0]
    $sCmd = StringStripWS($sCmd, 1 + 2)
    If Not $sCmd Then
        Return $aResult
    EndIf
    Local $aRet = DllCall('shell32.dll', 'ptr', 'CommandLineToArgvW', 'wstr', $sCmd, 'int*', 0)
    If @error Or Not $aRet[0] Or (Not $aRet[2]) Then Return SetError(@error + 10, @extended, 0)
    Local $tPtr = DllStructCreate('ptr[' & $aRet[2] & ']', $aRet[0])
    Dim $aResult[$aRet[2] + 1] = [$aRet[2]]
    For $i = 1 To $aRet[2]
        $aResult[$i] = _WinAPI_GetString(DllStructGetData($tPtr, 1, $i))
    Next
    DllCall("kernel32.dll", "handle", "LocalFree", "handle", $aRet[0])
    Return $aResult
EndFunc   ;==>_WinAPI_CommandLineToArgv

Func _WinAPI_GetString($pString, $bUnicode = True)
    Local $iLength = _WinAPI_StrLen($pString, $bUnicode)
    If @error Or Not $iLength Then Return SetError(@error + 10, @extended, '')
    Local $tString = DllStructCreate(($bUnicode ? 'wchar' : 'char') & '[' & ($iLength + 1) & ']', $pString)
    If @error Then Return SetError(@error, @extended, '')
    Return SetExtended($iLength, DllStructGetData($tString, 1))
EndFunc   ;==>_WinAPI_GetString
Func _WinAPI_PathIsDirectory($sFilePath)
    Local $aRet = DllCall('shlwapi.dll', 'bool', 'PathIsDirectoryW', 'wstr', $sFilePath)
    If @error Then Return SetError(@error, @extended, False)
    Return $aRet[0]
EndFunc   ;==>_WinAPI_PathIsDirectory
Func _WinAPI_StrLen($pString, $bUnicode = True)
    Local $W = ''
    If $bUnicode Then $W = 'W'
    Local $aRet = DllCall('kernel32.dll', 'int', 'lstrlen' & $W, 'struct*', $pString)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aRet[0]
EndFunc   ;==>_WinAPI_StrLen
Func __Inc(ByRef $aData, $iIncrement = 100)
    Select
        Case UBound($aData, 2)
            If $iIncrement < 0 Then
                ReDim $aData[$aData[0][0] + 1][UBound($aData, 2)]
            Else
                $aData[0][0] += 1
                If $aData[0][0] > UBound($aData) - 1 Then
                    ReDim $aData[$aData[0][0] + $iIncrement][UBound($aData, 2)]
                EndIf
            EndIf
        Case UBound($aData, 1)
            If $iIncrement < 0 Then
                ReDim $aData[$aData[0] + 1]
            Else
                $aData[0] += 1
                If $aData[0] > UBound($aData) - 1 Then
                    ReDim $aData[$aData[0] + $iIncrement]
                EndIf
            EndIf
        Case Else
            Return 0
    EndSelect
    Return 1
EndFunc   ;==>__Inc
Func _WinAPI_ChangeWindowMessageFilterEx($hWnd, $iMsg, $iAction)
    Local $tCFS, $aRet
    If $hWnd And ($__WINVER > 0x0600) Then
        Local Const $tagCHANGEFILTERSTRUCT = 'dword cbSize; dword ExtStatus'
        $tCFS = DllStructCreate($tagCHANGEFILTERSTRUCT)
        DllStructSetData($tCFS, 1, DllStructGetSize($tCFS))
        $aRet = DllCall('user32.dll', 'bool', 'ChangeWindowMessageFilterEx', 'hwnd', $hWnd, 'uint', $iMsg, 'dword', $iAction, 'struct*', $tCFS)
    Else
        $tCFS = 0
        $aRet = DllCall('user32.dll', 'bool', 'ChangeWindowMessageFilter', 'uint', $iMsg, 'dword', $iAction)
    EndIf
    If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0)
    Return SetExtended(DllStructGetData($tCFS, 2), 1)
EndFunc   ;==>_WinAPI_ChangeWindowMessageFilterEx
Func _WinAPI_DragQueryFileEx($hDrop, $iFlag = 0)
    Local $aRet = DllCall('shell32.dll', 'uint', 'DragQueryFileW', 'handle', $hDrop, 'uint', -1, 'ptr', 0, 'uint', 0)
    If @error Then Return SetError(@error, @extended, 0)
    If Not $aRet[0] Then Return SetError(10, 0, 0)
    Local $iCount = $aRet[0]
    Local $aResult[$iCount + 1]
    For $i = 0 To $iCount - 1
        $aRet = DllCall('shell32.dll', 'uint', 'DragQueryFileW', 'handle', $hDrop, 'uint', $i, 'wstr', '', 'uint', 4096)
        If Not $aRet[0] Then Return SetError(11, 0, 0)
        If $iFlag Then
            Local $bDir = _WinAPI_PathIsDirectory($aRet[3])
            If (($iFlag = 1) And $bDir) Or (($iFlag = 2) And Not $bDir) Then
                ContinueLoop
            EndIf
        EndIf
        $aResult[$i + 1] = $aRet[3]
        $aResult[0] += 1
    Next
    If Not $aResult[0] Then Return SetError(12, 0, 0)
    __Inc($aResult, -1)
    Return $aResult
EndFunc   ;==>_WinAPI_DragQueryFileEx

 

Regards,
 

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
  • Recently Browsing   0 members

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