brian873 Posted May 15, 2007 Share Posted May 15, 2007 Hi, I am new to the wonders of autoIT and after two days of searching through the forums I need help! Im stuck and digging a deepr hole for myself by the hour. I have a small script I wrote that lists all the powerpoint files in a folder through a gui and then should pass on the selected file to a command that it will run with the external pptview application. I can get the script to work if I manually type the file name. with the two methods below but I am stuck on how to pass the variable to the command line. I have tried numerous ways and now I feel I am going round in circles. Run('pptview.exe /s copy of presentaion1.ppt', @scriptdir) Run(@ComSpec & " /c " & 'pptview.exe /s "copy of presentation1.ppt"', "", @SW_HIDE) I would imagine it to be something like Run('pptview.exe /s & $SelctedFile, @scriptdir) But I cant get it to work.!!!! Any help would be appreciated. Thanks brian Link to comment Share on other sites More sharing options...
brian873 Posted May 15, 2007 Author Share Posted May 15, 2007 Hi hubertus, thanks for the reply. Yes this works fine for files with no spaces in the name ShellExecute('pptview.exe', "/s " & $s_text) I never made clear in my last post that I need it to be able to handle file names with spaces ect (copy of presentation1.ppt) Thanks again Link to comment Share on other sites More sharing options...
brian873 Posted May 15, 2007 Author Share Posted May 15, 2007 I have manage to complete what I want but I have to write the vairable to a txt file and use a batch command to run it using FileWrite($file,$s_text) FileClose($file) Run(@ComSpec & " /c " & 'play.bat', "", @SW_HIDE) I woudl love for AutoIT to be able to complete all this internally. Anyone? Link to comment Share on other sites More sharing options...
lordofthestrings Posted May 15, 2007 Share Posted May 15, 2007 how about $var_to_evaluate = "test test123" if stringinstr($var_to_evaluate," ") then $var_to_evaluate = '"' & $var_to_evaluate & '"' Else $var_to_evaluate = $var_to_evaluate EndIf Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 15, 2007 Share Posted May 15, 2007 (edited) Hi hubertus, thanks for the reply. Yes this works fine for files with no spaces in the name ShellExecute('pptview.exe', "/s " & $s_text) I never made clear in my last post that I need it to be able to handle file names with spaces ect (copy of presentation1.ppt) Thanks againUse single quotes to include double quotes as part of the string: $s_text = 'copy of presentaion1.ppt' ShellExecute('pptview.exe', ' /s "' & $s_text & '"')oÝ÷ Ù8^¥ªÚë^®ÊZ²Ç¶i¶øÁì^Â¥u·¡×¿³~¢¨~Þ±éíj*'ÖmßÜ¡×I8^½ªâi¹^˧ç²Æ«Ê'ò¢çhmÁ©í¶¬z+[ºÛ-Ygyçm¢ë²)àꮢ׬¶§rZ,zØ^+^©]¢æåz«¨µëºÚ"µÍÚ[^XÝ]J ÌÎNÜY]Ë^IÌÎNË ÌÎNÈÜÈ ][ÝØÛÜHÙÙ[Z[ÛK ][ÝÉÌÎNÊ Edited May 15, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
brian873 Posted May 15, 2007 Author Share Posted May 15, 2007 Thanks Lord of the strings. I have played about with that code but I am unsure what it is meant to do for me, can you explain to a auto it newbie. thanks Link to comment Share on other sites More sharing options...
brian873 Posted May 16, 2007 Author Share Posted May 16, 2007 Many Thanks to Hubertus72 & PsaltyDS I have go it working now without external batch files ! This is the part that had me stuck... Use single quotes to include double quotes as part of the string: Thanks again brian Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 16, 2007 Share Posted May 16, 2007 This is the part that had me stuck... Use single quotes to include double quotes as part of the string: Just for completeness, I'll mention another good fix: FileGetShortName() Returns the 8.3 format short name of the file that can use without double quotes: $s_file = FileGetShortName(@ScriptDir & '\copy of presentaion1.ppt') ShellExecute('pptview.exe', ' /s ' & $s_file) ; no double quotes needed Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Shevilie Posted May 16, 2007 Share Posted May 16, 2007 You couls actually do this ShellExecute("pptview.exe", " /s ""ttt ttt.ppt""") Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 16, 2007 Share Posted May 16, 2007 Where'd you find the :ninja; smiley? That's cool, and it doesn't come up in my smiley list in the forum editor... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
lordofthestrings Posted May 21, 2007 Share Posted May 21, 2007 (edited) $var_to_evaluate = "test test123" ; var to evaluate, put space in it or not. if stringinstr($var_to_evaluate," ") then ; if in the string variable you find a space $var_to_evaluate = '"' & $var_to_evaluate & '"' ; enclose var to evaluate with double quotes Else ; otherwise $var_to_evaluate = $var_to_evaluate ; leave variable intact EndIf ; end conditional statement. sorry for late reply. hope this code does what you need.. Edited May 21, 2007 by lordofthestrings Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now