Launching other applications from within MOI

Next
 From:  pior (PIOR_O)
10174.1 
Hello all, Michael -

Here is a somewhat unusual question : is it possible to launch an .exe, or a .bat, or any application link in script directly from within MOI3D ? For instance launching notepad or running a .ahk script at the press of a CommandButton or MenuItem, or from a hotkey.

(I find that having such links to other applications reachable directly from within the application currently being used is a great way to maintain focus and flow. Of course one can always click an icon or make a system search, but I'd be curious to know if I can make my own little buttons for this as that is something I am doing already - to launch MOI from within Photoshop, to launch Photoshop from within Blender, and so on).

I hope this makes (some) sense :)

P.O.
  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:  Michael Gibson
10174.2 In reply to 10174.1 
Hi pior, yes you can launch an external program using:
moi.filesystem.shellExecute( Path, Parameters /*optional - command line parameters to pass to program*/, false /*optional - wait for process to finish*/ );

So for example to launch notepad:
moi.filesystem.shellExecute( 'notepad.exe' );

- 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:  Michael Gibson
10174.3 In reply to 10174.1 
Note that if you have any backslash \ characters in a string you'll need to put in 2 of them like: 'c:\\path\\program.exe' .

That's because the backslash is an escape character for Javascript code, like \n is the escape code for making a newline character. To do a backslash in a string you need \\ .

- 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:  Frenchy Pilou (PILOU)
10174.4 
You have also a Console ;)
http://sites.google.com/site/nakanosoramemo/software/moi3d/script-console

but alas seems not more existing! :(

  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:  pior (PIOR_O)
10174.5 In reply to 10174.3 
Hello Michael, thank you so much for the help ! This was perfectly clear and worked right away, thanks. It really makes for a nice uninterrupted workflow.



(BTW this custom UI revolves around the idea of every tool being available directly under the span of one single mouse scroll. Quite different from the default paradigm of expandable buttons, but maybe it can spark some ideas. And BTW the Set Style/Hide Style/Show Style commands turned out to be very useful, so thanks again for the code that you provided a few weeks ago).

Also, in passing : what would be the commands for the "Show Grid" and "Show Grid Axis" tickboxes ? I constantly have to toggle these on and off and having to go and reach them from the Gird Snap button and from the Preferences panel is a bit tiresome. So I'd like to put them within reach in my UI as well.

@FP : Sorry I do not quite understand what you mean. Is this console available in V4 ? And regardless I assume that it lets one run scripts/commands, which is handy of course ... but that's irrelevant here as I have no problem with running scripts in and of themselves - it is the specific command for launching exes that I was looking for ...

EDITED: 18 Feb 2021 by PIOR_O


Image Attachments:
Size: 2.3 KB, Downloaded: 3 times, Dimensions: 131x48px
  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:  Michael Gibson
10174.6 In reply to 10174.5 
Hi Pior, for show grid and show grid axes try these:

moi.grid.display = !moi.grid.display;

moi.grid.showXYAxes = !moi.grid.showXYAxes;

- 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
 From:  pior (PIOR_O)
10174.7 In reply to 10174.6 
That's brilliant - thank you so much as usual !
  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