External file open
All  1  2-4

Previous
Next
 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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  BurrMan
4064.3 In reply to 4064.2 
Hi Michael,
Thanks for that... Seems everything is leading me to the windows api... I was trying to avoid it because I'm just not overly familiar with it....I was trying stuff and ended up with ie opening with this type of address:

moi://ui/hello_world.txt

Just getting my head around that working inside of the MoI command interface is a bit different..

I dont expect you to get to involved in this, thanks for the heads up on using the windows api with javascript.... What I am doing is not that complicated so I should be able to figure it out...

Thanks again.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
4064.4 In reply to 4064.3 
Hi Burr,

> I was trying stuff and ended up with ie opening with this type of address:
>
> moi://ui/hello_world.txt

So that probably means that you were trying interfaces that actually belong to the Internet Explorer API, those are for controlling the browser and can do some things like opening up a new browser window.

But the APIs in that area are more focused on stuff that you can do from a web browser.

Could you describe a little more about what you're trying to do? If I had a bit more of an idea I might be able to point you towards some particular areas of the Windows API that are relevant. But for launching programs or opening documents ShellExecute that is part of the windows shell functions is the main one for that.


> Just getting my head around that working inside
> of the MoI command interface is a bit different..

Well, one part that is the same though is that if you find any JScript code examples for doing various stuff you can run that same code in MoI as well. There is quite a bit of JScript code out there because it's frequently used as a way to automate tasks in Windows, there is a mechanism in Windows called the "Windows Script Host" that lets you run scripts in a few various different scripting languages, and JScript is one of the most commonly used languages.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1  2-4