Author Topic: scripting process icons?  (Read 4770 times)

Offline troypiggo

  • PixInsight Addict
  • ***
  • Posts: 258
scripting process icons?
« on: 2012 May 26 16:02:52 »
To further make BatchPreProcessing even more user friendly, I have created 2 process icons.  One for a CosmeticCorrection template that just has autodetect ticked, and one for BatchPreProcessing that already points to my bias and dark library masters and points to the CC template process icon for me.  So all I have to do is add the lights and flats for the session.

I have saved the execution of this as a very basic scp script:

Code: [Select]
open /Users/troy/Applications/pixinsight/BatchPP_template.xpsm
instance --icon=BatchPP_template -execute-global

There are a couple of things I'm trying to figure out how to do and have some questions.

1.  I can't see how to feature the scp script, so can't add it as a favourite etc.  I have to go to the menu, scripts, execture script, change filetype option to scp, then click it.  Am I missing something or is this the only way to do it?

2.  Depending on the answer to 1. above, would I be better off converting to js script?  Not sure how to do that, so would appreciate some pointers in the right direction.

3.  After the scp script executes, the BPP script has done its thing, and I close the BPP window, the BPP process icon's window is still open.  Ideally I'd like my script to close this window, and then remove the 2 process icons from the desktop.  Any ideas how to achieve that too?

I would think that others would benefit from this template idea, so once I get this working I intend to post what I have done in more detail in the tips and tricks or tutorials section.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: scripting process icons?
« Reply #1 on: 2012 June 07 02:02:13 »
Quote
1.  I can't see how to feature the scp script, so can't add it as a favourite etc.  I have to go to the menu, scripts, execture script, change filetype option to scp, then click it.  Am I missing something or is this the only way to do it?

To be featured, a script requires a #feature-id directive. For example:

Code: [Select]
#feature-id    My Scripts > My BatchPreprocessing Icon

#feature-info  This script executes BatchPreprocessing with my CosmeticCorrection icons \
               and other magic.

open /Users/troy/Applications/pixinsight/BatchPP_template.xpsm
instance --icon=BatchPP_template -execute-global

The #feature-info directive is optional, but it will help you identify the script more easily on the Feature Scripts dialog. The above #feature-id directive will create a "My Scripts" menu item in the Script menu, and will add a "My BatchPreprocessing Icon" sub-menu item to launch your script.

Quote
2.  Depending on the answer to 1. above, would I be better off converting to js script?  Not sure how to do that, so would appreciate some pointers in the right direction.

The .scp shell script you have written should work without problems. You can also execute an existing Script instance from a JavaScript script. Of course, JavaScript gives you much more control and power. For example:

Code: [Select]
var instance = ProcessInstance.fromIcon( "BatchPP_template" );
if ( instance instanceof Script )
   instance.executeGlobal();

For security reasons, the Script object is sealed. This means that you cannot change an existing Script instance, and you cannot create a new Script instance from a script because its properties are read-only. The only way to execute a Script from a script is through an icon.

Quote
3.  After the scp script executes, the BPP script has done its thing, and I close the BPP window, the BPP process icon's window is still open.  Ideally I'd like my script to close this window, and then remove the 2 process icons from the desktop.  Any ideas how to achieve that too?

This can't be done in PixInsight 1.7.x because the current version of PJSR provides no direct access to PI's workspace. The incoming version 1.8.0 includes a Workspace JavaScript object that allows you to do this type of things.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline troypiggo

  • PixInsight Addict
  • ***
  • Posts: 258
Re: scripting process icons?
« Reply #2 on: 2012 June 07 06:48:27 »
Awesome.  Thanks Juan.  That should give me what I need.