Jump to content

parameters & quotes when running external programs


daedo
 Share

Recommended Posts

I am new to Autoit having used autohotkey before. I am stuck on how to  select a video file and play it with mplayer,

I searched the forums but couldnt find the answer. here is my simplified script 

#include <GUIConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <Constants.au3>
#include <File.au3>

;global $playingfile = '"C:\some file.mp4"'

global $selectedfile = FileOpenDialog ( "open","","All (*.*)") 


;$mplayerpid = Run ( "mplayer.exe -slave -quiet " & '"C:\some file.mp4"' );this works
;$mplayerpid = Run ( 'mplayer.exe -slave -quiet ' & $playingfile ); this works
$mplayerpid = Run ( 'mplayer.exe -slave -quiet ' & '"'& $selectedfile &'"' ); this and many variations doesnt

The problem is selecting the file, taking account of the fact it and  / or the path may have a space in it so it must have quotes around it to work

I have remarked out 'fixed' options that do actually work

Thanks in advance for any help

Link to comment
Share on other sites

$mplayerpid = Run ('mplayer.exe -slave -quiet "' & $selectedfile & '"')

should work fine.

can you go Start>Run>mplayer.exe and it launches mplayer?  perhaps mplayer is not on your PATH environment variable.

Try pointing directly to the mplayer executable:

$mplayerpid = Run ('C:\path\goes\here\mplayer.exe -slave -quiet "' & $selectedfile & '"')

or if there's spaces in the path to your mplayer.exe

$mplayerpid = Run ('"C:\path with spaces\goes\here\mplayer.exe" -slave -quiet "' & $selectedfile & '"')
Edited by gruntydatsun
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...