ryantollefson Posted September 2, 2007 Share Posted September 2, 2007 Sorry if this has been asked before, I tried searching, but couldn't find it. I'm wondering how I can open a file with a specified application (like when you right click on a file and can choose "Open With"). For example, if I wanted to open song.mp3 with winamp instead of it's default application. Link to comment Share on other sites More sharing options...
weaponx Posted September 2, 2007 Share Posted September 2, 2007 ShellExecute?? Link to comment Share on other sites More sharing options...
ryantollefson Posted September 2, 2007 Author Share Posted September 2, 2007 (edited) ShellExecute??That will just use the default program though. Edited September 2, 2007 by ryantollefson Link to comment Share on other sites More sharing options...
Nahuel Posted September 2, 2007 Share Posted September 2, 2007 I really don't know if this would work, since I'm using Win98 and it doesn't have that option. ShellExecute("filename","","","Open with") If it does work, I suppose all it'll do is show you the window where you are supposed to choose the program. It should be a quite interesting function to make. Link to comment Share on other sites More sharing options...
ryantollefson Posted September 2, 2007 Author Share Posted September 2, 2007 I tried this: ShellExecute("myfile.txt", "", @ScriptDir, "Open With") And I get this error: ...Unable to execute the external program.: ShellExecute("myfile.txt", "", @ScriptDir, "Open With") No application is associated with the specified file for this operation. Link to comment Share on other sites More sharing options...
weaponx Posted September 2, 2007 Share Posted September 2, 2007 If you are wanting to open a file somewhere other than it's default app, then you should just be using Run() to execute the desired program directly and pass your file as a parameter. Link to comment Share on other sites More sharing options...
Dieuz Posted September 2, 2007 Share Posted September 2, 2007 (edited) I tried this: ShellExecute("myfile.txt", "", @ScriptDir, "Open With") And I get this error: ...Unable to execute the external program.: ShellExecute("myfile.txt", "", @ScriptDir, "Open With") No application is associated with the specified file for this operation. Did you even replace "myfile.txt" and "Open with" by something!? Edited September 2, 2007 by Dieuz Link to comment Share on other sites More sharing options...
ryantollefson Posted September 3, 2007 Author Share Posted September 3, 2007 weaponx, can you give me an example of how to do this? I tried: Run("c:\Program Files\Windows NT\Accessories\wordpad.exe -C:\Users\Ryan\Documents\AutoIT\examples\myfile.txt") but this just opens Wordpad, not the .txt file with it. Dieuz, yes I replaced Open With with the program path, and "myfile.txt" is a file I am using to test this. Link to comment Share on other sites More sharing options...
herewasplato Posted September 3, 2007 Share Posted September 3, 2007 Run('c:\Program Files\Windows NT\Accessories\wordpad.exe "New Text document.txt"')I had New Text document.txt in the same folder as the script - you might want the entire path to your text file. -MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 3, 2007 Share Posted September 3, 2007 You don't put a - before a parameter. Putting the parameter in quotes is better though. Run('c:\Program Files\Windows NT\Accessories\wordpad.exe "C:\Users\Ryan\Documents\AutoIT\examples\myfile.txt"') Link to comment Share on other sites More sharing options...
ryantollefson Posted September 3, 2007 Author Share Posted September 3, 2007 (edited) You don't put a - before a parameter.Thanks (to herewasplato too), that worked for the .txt file... But now how can I do it for something like this (this doesn't work - it will open Windows Media Player, but not the file)? Run('C:\Program Files\Windows Media Player\wmplayer.exe "Triangle.wma"') I tried this with the full path to Triangle.wma also, but that didn't work either. Edited September 3, 2007 by ryantollefson Link to comment Share on other sites More sharing options...
herewasplato Posted September 3, 2007 Share Posted September 3, 2007 Try adding the entire path to the WMA file. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
ryantollefson Posted September 3, 2007 Author Share Posted September 3, 2007 Try adding the entire path to the WMA file.Tried that, no luck Link to comment Share on other sites More sharing options...
herewasplato Posted September 4, 2007 Share Posted September 4, 2007 Just so we are on the same page here (playing the same file):Download this WMA file from here:http://www.triviaproducer.com/TB4_2_Playing_a_Game.wmaor, if you prefer the site, then link route:http://www.triviaproducer.com/support.htmlthen "right mouse click/save file as" the "Playing a Game:" linkthen run this code - changing the path as needed:Run('C:\Program Files\Windows Media Player\wmplayer.exe "C:\Temp\TB4_2_Playing_a_Game.wma"')It starts Windows Media Player (WMP), version 11.0.5721.5230, on a computer running the XP SP2 OS and plays the file as expected.What happens for you?What version of WMP are you using?What OS?-MSP- [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
MrCreatoR Posted September 4, 2007 Share Posted September 4, 2007 Maybe also there is need to use working dir.. Run('"C:\Program Files\Windows Media Player\wmplayer.exe" "Path\to\file\Triangle.wma"', '"Path\to\file"')oÝ÷ Ø Ýj[(¶¼¢ë²+¶«¢+ÙIÕ¸ ÌäìÅÕ½ÐìÌäìµÀ쥱ÑM¡½ÉÑ9µ ÌäíèÀäÈíAɽɴ¥±ÌÀäÈí]¥¹½ÝÌ5¥A±åÈÀäÈíݵÁ±åȹáÌä줵ÀìÌäìÅÕ½ÐìÌäìµÀ쥱ÑM¡½ÉÑ9µ ÌäíAÑ ÀäÈíѼÀäÈí¥±ÀäÈíQÉ¥¹±¹ÝµÌä줰ÌäìÅÕ½ÐíAÑ ÀäÈíѼÀäÈí¥±ÅÕ½ÐìÌäì¤ Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
ryantollefson Posted September 4, 2007 Author Share Posted September 4, 2007 (edited) So I'm an idiot and can't type. :"> Thanks for all the help guys, and herewasplato, thanks for the (properly) spelled out example Edited September 4, 2007 by ryantollefson 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