We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Open with... Processing application
Page Index Toggle Pages: 1
Open with... Processing application (Read 823 times)
Open with... Processing application
Apr 25th, 2009, 11:45am
 
Hi, I wrote a program - "PicEffects" in Processing, that makes some operations with pictures(actually with pixels). Is it possible, to select a picture(in Windows), and select "open with... PicEffects" in context menu? My program is to open after that and make some operations width this picture. Actually, an adress of this picture must be passed to my program after it's launching. Please help meee Undecided
Re: Open with... Processing application
Reply #1 - Apr 26th, 2009, 2:12am
 
I haven't tried much the Application Export feature, even less with passing parameters.
Perhaps if you write you own main() method (as explained in the above linked page), you might find the image name in the String args[] parameters.
To have "Open in PicEffects" context menu, you have to tweak the registry. Perhaps something like:
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\PicEffects\command]
@="\"C:\\Path\\To\\PicEffects.exe\" \"%1\""

but it will open for all files, not just graphics files.
You might research OpenWithList registry key to do more targeted operations.
Re: Open with... Processing application
Reply #2 - Apr 26th, 2009, 3:07am
 
i found there:
If running in "Java" mode, where your code starts "public class blah extends PApplet", you'll need to write your own main() method in order for Export to Application to work. It should look something like this:
static public void main(String args[]) {
 PApplet.main(new String[] { "YourClassName" });
}


But I dont understand this.  I tried to insert main function to my sketch, but I can't operate with this array, because it is static.
I can't find any article, how to do this.
As I undrestand, If I click on some Image-> Open withh..., it's adress is passed to my program as String args[](in main function). The only thing I have to do - is to create an PImage variable and assign pass adress as parameter.
If somebody can write an example, please, I realy need it.
Re: Open with... Processing application
Reply #3 - Apr 26th, 2009, 4:56pm
 
This works by dragging a file onto the .exe created from exporting as application. It should also work as PhiLho suggested with the registry.

I have only tried this on Windows...

Code:

public class sketchname extends PApplet {
 
 static String[] fromCommandLine = null;
 
 PImage loaded = null;
 
 public void setup() {
   size(640,480);
   
   if (fromCommandLine != null)
     loaded = loadImage(fromCommandLine[0]);
   
 }
 
 
 public void draw() {
   
   if (loaded != null)
     image(loaded, 0, 0);
   
   
 }
 
 
 
 static public void main(String args[]) {
   
   fromCommandLine = args;
   
   PApplet.main(new String[] { "sketchname" });
 }
}
Re: Open with... Processing application
Reply #4 - Apr 27th, 2009, 12:33am
 
Yes!! It's what I really needed. Thank you very much!!!
Re: Open with... Processing application
Reply #5 - Apr 27th, 2009, 2:29am
 
Page Index Toggle Pages: 1