External file open

 From:  Michael Gibson
4064.2 In reply to 4064.1 
Hi Burr, yeah it's not something that's part of MoI's own API but you can use JavaScript to call the Windows system ShellExecute function, see here:

http://msdn.microsoft.com/en-us/library/bb774148%28VS.85%29.aspx

Actually pretty much anything you find in the Windows documentation about how you can call stuff from script will also work from scripts in MoI as well.

In this case, the documentation seems to have a typo, to use the Windows system ShellExecute function (which can take any .exe name or document name, it's the equivalent of typing what you put there into the "Run" dialog that you can get on the Start menu) you need some script like this:

var WinShell = new ActiveXObject('Shell.Application');
WinShell.ShellExecute( 'notepad.exe' );

So a command button that does this could be set up like so:

code:
<moi:CommandButton
	style="icon:(your icon here).png"
	onbuttonclick="var WinShell = new ActiveXObject('Shell.Application'); WinShell.ShellExecute( 'notepad.exe' );">
		Notepad
</moi:CommandButton>


There are numerous other Windows API calls that you can make from script in a similar way, so you can use them for various kinds of things that MoI's API does not have a custom function to handle on its own.

You can find a lot of reference information about this stuff if you look for stuff like "Windows script host" under google. Examples that you find that run JavaScript (the Microsoft version is called "JScript") code can be used in MoI as well.

So JScript can be a good keyword to use in a search as well, for example using this search in Google: "jscript open notepad" would give you some results that showed the script code as above.

- Michael