Wiki

Clone wiki

dsair / InvokeManager

HOWTO: InvokeManager: Starting the app with files/commands

Introduction

The InvokeManager lets you recover the files passed into the app if the app is started by dragging and dropping (multiple) files over the icon. Also, in Windows7, if an app is pinned to the taskbar, when you drag files over that icon, you can pin the files to it, making it easy to start apps with files that are frequently used.

If you start the app through the command line, you can also pass arguments to the app that way.

Details

Check out the TestInvoke.as file for the full details.

As with all examples, you need to init the framework before doing anything:

#!actionscript

DSAir.init( this ); // "this" is your Document class

Checking if we have files

Calling

#!actionscript

InvokeManager.instance.hasFiles

will return true if the app was started with some files, and false otherwise.

Getting the files that we started with

Simply check the files Vector for the File objects:

#!actionscript

for each( var file:File in InvokeManager.instance.files )
    trace( "We were started with the file '" + file.nativePath + "'" );

Checking for commands

You can also access the raw args that the app was started with (to recover commands etc) by going through the rawArgs Vector:

#!actionscript

for each( var arg:String in InvokeManager.instance.rawArgs )
    trace( this, "Started with raw arg '" + arg + "'" );

Updated